-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* print_address as info log * Docs pages * Change package name and version * Build from source doc * Add Rust installation * Reorder files * Init doc * Reorganize account manager creation * Make command optional * Change account prompt * Clean up account args matching * Print error on account not found * Simplify main match * Remove change address boolean from logs
- Loading branch information
1 parent
595d609
commit 64bc616
Showing
12 changed files
with
186 additions
and
136 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The `cli-wallet` is a stateful Command Line Interface wallet that allows you to interact with the ledger. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# From release | ||
|
||
# From source | ||
|
||
## 1. Install Rust | ||
|
||
https://www.rust-lang.org/tools/install | ||
|
||
## 2. Compile | ||
|
||
```sh | ||
git clone [email protected]:iotaledger/cli-wallet.git -b develop | ||
cd cli-wallet | ||
cargo build --profile production | ||
``` | ||
|
||
Resulting binary will be located at `./target/production/wallet`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
The account manager interface allows you to: | ||
- Initialise the wallet with a mnemonic; | ||
- Create new accounts; | ||
- Select the account to use; | ||
- Synchronise the accounts; | ||
|
||
# Commands | ||
|
||
## `help` | ||
|
||
### Parameters | ||
|
||
### Example(s) | ||
|
||
## `init` | ||
|
||
The wallet can only be initialised once. | ||
|
||
### Parameters | ||
|
||
| Name | Optional | Default |Example | | ||
| ----------- | --------- | ------------------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `mnemonic` | ✓ | Randomly generated | "aunt middle impose faith ramp kid olive good practice motor grab ready group episode oven matrix silver rhythm avocado assume humble tiger shiver hurt" | | ||
| `node` | ✓ | "http://localhost:14265/" | "http://localhost:14265/" | | ||
|
||
### Example(s) | ||
|
||
Initialise the wallet with a randomly generated mnemonic and the default node. | ||
```sh | ||
./wallet init | ||
``` | ||
|
||
Initialise the wallet with a given mnemonic and the default node. | ||
```sh | ||
./wallet init --mnemonic "aunt middle impose faith ramp kid olive good practice motor grab ready group episode oven matrix silver rhythm avocado assume humble tiger shiver hurt" | ||
``` | ||
|
||
Initialise the wallet with a a randomly generated mnemonic and a given node. | ||
```sh | ||
./wallet init --node "http://localhost:14265/" | ||
``` | ||
|
||
## `new` | ||
|
||
### Parameters | ||
|
||
### Example(s) | ||
|
||
## `select` | ||
|
||
### Parameters | ||
|
||
### Example(s) | ||
|
||
## `set-node` | ||
|
||
### Parameters | ||
|
||
### Example(s) | ||
|
||
## `sync` | ||
|
||
### Parameters | ||
|
||
### Example(s) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,65 @@ | ||
// Copyright 2020-2022 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use iota_wallet::account_manager::AccountManager; | ||
use std::env::var_os; | ||
|
||
use clap::Parser; | ||
use iota_wallet::{ | ||
account_manager::AccountManager, | ||
secret::{stronghold::StrongholdSecretManager, SecretManager}, | ||
ClientOptions, | ||
}; | ||
|
||
use crate::{ | ||
command::account_manager::{ | ||
init_command, new_command, select_command, set_node_command, sync_command, AccountManagerCli, | ||
AccountManagerCommand, | ||
}, | ||
error::Error, | ||
helper::get_password, | ||
}; | ||
|
||
pub async fn match_account_manager_command( | ||
account_manager: &AccountManager, | ||
account_manager_cli: AccountManagerCli, | ||
) -> Result<(), Error> { | ||
match account_manager_cli.command { | ||
AccountManagerCommand::Init(mnemonic_url) => init_command(account_manager, mnemonic_url).await, | ||
AccountManagerCommand::New { alias } => new_command(account_manager, alias).await, | ||
AccountManagerCommand::Select { identifier } => select_command(account_manager, identifier).await, | ||
AccountManagerCommand::SetNode { url } => set_node_command(account_manager, url).await, | ||
AccountManagerCommand::Sync => sync_command(account_manager).await, | ||
pub async fn new_account_manager() -> Result<(AccountManager, Option<String>), Error> { | ||
let storage_path = var_os("WALLET_DATABASE_PATH") | ||
.map(|os_str| os_str.into_string().expect("invalid WALLET_DATABASE_PATH")) | ||
.unwrap_or_else(|| "./stardust-cli-wallet-db".to_string()); | ||
let stronghold_path = std::path::Path::new("./stardust-cli-wallet.stronghold"); | ||
|
||
match AccountManagerCli::try_parse() { | ||
Ok(account_manager_cli) => { | ||
let password = get_password(stronghold_path)?; | ||
let secret_manager = SecretManager::Stronghold( | ||
StrongholdSecretManager::builder() | ||
.password(&password) | ||
.snapshot_path(stronghold_path.to_path_buf()) | ||
.build(), | ||
); | ||
let account_manager = AccountManager::builder() | ||
.with_secret_manager(secret_manager) | ||
.with_client_options( | ||
ClientOptions::new() | ||
.with_node("http://localhost:14265")? | ||
.with_node_sync_disabled(), | ||
) | ||
.with_storage_path(&storage_path) | ||
.finish() | ||
.await?; | ||
|
||
if let Some(command) = account_manager_cli.command { | ||
match command { | ||
AccountManagerCommand::Init(mnemonic_url) => init_command(&account_manager, mnemonic_url).await, | ||
AccountManagerCommand::New { alias } => new_command(&account_manager, alias).await, | ||
AccountManagerCommand::Select { identifier } => select_command(&account_manager, identifier).await, | ||
AccountManagerCommand::SetNode { url } => set_node_command(&account_manager, url).await, | ||
AccountManagerCommand::Sync => sync_command(&account_manager).await, | ||
}?; | ||
} | ||
|
||
Ok((account_manager, account_manager_cli.account)) | ||
} | ||
Err(e) => { | ||
println!("{e}"); | ||
Err(Error::Help) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.