Modify create-monero-wallet command to accept wallet name and password args

This commit is contained in:
silverpill 2022-08-27 23:34:57 +00:00
parent 2eb7ec2f64
commit 703cae0a43
2 changed files with 12 additions and 7 deletions

View file

@ -294,7 +294,10 @@ impl UpdateCurrentBlock {
/// Create Monero wallet /// Create Monero wallet
#[derive(Parser)] #[derive(Parser)]
pub struct CreateMoneroWallet; pub struct CreateMoneroWallet {
name: String,
password: Option<String>,
}
impl CreateMoneroWallet { impl CreateMoneroWallet {
pub async fn execute( pub async fn execute(
@ -304,7 +307,11 @@ impl CreateMoneroWallet {
let monero_config = config.blockchain() let monero_config = config.blockchain()
.and_then(|conf| conf.monero_config()) .and_then(|conf| conf.monero_config())
.ok_or(anyhow!("monero configuration not found"))?; .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"); println!("wallet created");
Ok(()) Ok(())
} }

View file

@ -11,13 +11,11 @@ pub enum MoneroError {
/// http://monerotoruzizulg5ttgat2emf4d6fbmiea25detrmmy7erypseyteyd.onion/resources/developer-guides/wallet-rpc.html#create_wallet /// http://monerotoruzizulg5ttgat2emf4d6fbmiea25detrmmy7erypseyteyd.onion/resources/developer-guides/wallet-rpc.html#create_wallet
pub async fn create_monero_wallet( pub async fn create_monero_wallet(
config: &MoneroConfig, config: &MoneroConfig,
name: String,
password: Option<String>,
) -> Result<(), MoneroError> { ) -> Result<(), MoneroError> {
let wallet_client = RpcClient::new(config.wallet_url.clone()).wallet(); let wallet_client = RpcClient::new(config.wallet_url.clone()).wallet();
let language = "English".to_string(); let language = "English".to_string();
wallet_client.create_wallet( wallet_client.create_wallet(name, password, language).await?;
config.wallet_name.clone(),
config.wallet_password.clone(),
language,
).await?;
Ok(()) Ok(())
} }