Skip to content

Commit

Permalink
Update CLI readme and connect params (#453)
Browse files Browse the repository at this point in the history
* Update readme and connect params
* fixup! Update readme and connect params
  • Loading branch information
dangeross authored Sep 13, 2023
1 parent c5379fc commit 0022fad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
12 changes: 5 additions & 7 deletions tools/sdk-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ or to specify a custom data directory:
cargo run -- --data_dir <data directory>
```

Once the CLI is started, the first thing we need to do is create a node and there are three ways (commands) to do it:
* `register_node` - Registers a new node in the cloud. The node credentials and the BIP39 mnemonic seed are saved in the data directory (`creds` and `phrase` files). Use this as the first command if you have no seed and no wallet credentials.
* `recover_node` - Recovers a node from BIP39 mnemonics. Use this if you already have a seed (`phrase` file) and you wish to start using the node associated with that seed.
* `init` - Initializes an existing node from credentials. Use this if you already have the node credentials (`creds` file) and wish to start using the associated node.
Once the CLI is started, the first thing we need to do is create a node and there are three ways to do it:
* **With an invite code** - You can use a one-time invite code to register a new node. Use the command `connect -i <invite_code>` with your invite code.
* **With a partner certificate** - You can use a Greenlight Partner Certificate to register a new node. Use the command `connect -c <partner_cert> -k <partner_key>` with your Greenlight Partner Certificate and Key. This Partner Certificate can be reused to register multiple nodes.
* **With a mnemonic phrase** - Create a `phrase` file in the data directory containing the BIP39 mnemonic phase of an existing node. Use the command `connect` to recover the node.

Once the node is created we can start to send commands to the node. Press `Enter` to see a list of available commands.

Typically, on first run one would use `register_node` as the first command, and on subsequent runs one would start with `init`.
The node credentials and the BIP39 mnemonic seed are saved in the data directory (`creds` and `phrase` files). Once the node is created we can start to send commands to the node. Press `Enter` to see a list of available commands. When restarting the CLI, use `connect` to reconnect to the node and start sending commands to it.

Please note that the CLI is very simple and only intends to demonstrate the usage and investigate issues that are hard to debug on mobile platforms.
10 changes: 5 additions & 5 deletions tools/sdk-cli/src/command_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ pub(crate) async fn handle_command(
Ok(format!("Environment was set to {:?}", env))
}
Commands::Connect {
device_cert,
device_key,
partner_cert,
partner_key,
invite_code,
} => {
let mut config = persistence
.get_or_create_config()?
.to_sdk_config(&persistence.data_dir);
let mut partner_credentials: Option<GreenlightCredentials> = None;
if device_cert.is_some() && device_key.is_some() {
let cert = fs::read(device_cert.unwrap())?;
let key = fs::read(device_key.unwrap())?;
if partner_cert.is_some() && partner_key.is_some() {
let cert = fs::read(partner_cert.unwrap())?;
let key = fs::read(partner_key.unwrap())?;
partner_credentials = Some(GreenlightCredentials {
device_cert: cert,
device_key: key,
Expand Down
12 changes: 6 additions & 6 deletions tools/sdk-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ pub(crate) enum Commands {
},
/// Connect to the sdk services, make it operational
Connect {
/// The optional greenlight device certifiate
#[clap(name = "device_cert", short = 'c', long = "device_cert")]
device_cert: Option<std::path::PathBuf>,
/// The optional file location containing the greenlight partner certificate
#[clap(name = "partner_cert", short = 'c', long = "partner_cert")]
partner_cert: Option<std::path::PathBuf>,

/// The optional greenlight device key
#[clap(name = "device_key", short = 'k', long = "device_key")]
device_key: Option<std::path::PathBuf>,
/// The optional file location containing the greenlight partner key
#[clap(name = "partner_key", short = 'k', long = "partner_key")]
partner_key: Option<std::path::PathBuf>,

/// The optional greenlight invite code
#[clap(name = "invite_code", short = 'i', long = "invite_code")]
Expand Down

0 comments on commit 0022fad

Please sign in to comment.