From 703cae0a4364f1e46e1a99be5845a6171da52390 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 27 Aug 2022 23:34:57 +0000 Subject: [PATCH] Modify create-monero-wallet command to accept wallet name and password args --- src/cli.rs | 11 +++++++++-- src/monero/wallet.rs | 8 +++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index bc52d18..73afb18 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -294,7 +294,10 @@ impl UpdateCurrentBlock { /// Create Monero wallet #[derive(Parser)] -pub struct CreateMoneroWallet; +pub struct CreateMoneroWallet { + name: String, + password: Option, +} impl CreateMoneroWallet { pub async fn execute( @@ -304,7 +307,11 @@ impl CreateMoneroWallet { let monero_config = config.blockchain() .and_then(|conf| conf.monero_config()) .ok_or(anyhow!("monero configuration not found"))?; - create_monero_wallet(monero_config).await?; + create_monero_wallet( + monero_config, + self.name.clone(), + self.password.clone(), + ).await?; println!("wallet created"); Ok(()) } diff --git a/src/monero/wallet.rs b/src/monero/wallet.rs index 5ca092c..a50fd6a 100644 --- a/src/monero/wallet.rs +++ b/src/monero/wallet.rs @@ -11,13 +11,11 @@ pub enum MoneroError { /// http://monerotoruzizulg5ttgat2emf4d6fbmiea25detrmmy7erypseyteyd.onion/resources/developer-guides/wallet-rpc.html#create_wallet pub async fn create_monero_wallet( config: &MoneroConfig, + name: String, + password: Option, ) -> Result<(), MoneroError> { let wallet_client = RpcClient::new(config.wallet_url.clone()).wallet(); let language = "English".to_string(); - wallet_client.create_wallet( - config.wallet_name.clone(), - config.wallet_password.clone(), - language, - ).await?; + wallet_client.create_wallet(name, password, language).await?; Ok(()) }