From 1e3107fe553769e0a85094123a6e4376947a9629 Mon Sep 17 00:00:00 2001 From: DenioD Date: Mon, 21 Oct 2019 13:21:49 +0200 Subject: [PATCH] manualy merged conflicts --- lib/src/commands.rs | 40 ---------------------------------------- lib/src/lightclient.rs | 11 ++++++----- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/lib/src/commands.rs b/lib/src/commands.rs index f50d960..58a2462 100644 --- a/lib/src/commands.rs +++ b/lib/src/commands.rs @@ -243,46 +243,6 @@ impl Command for EncryptCommand { } } -struct EncryptCommand {} -impl Command for EncryptCommand { - fn help(&self) -> String { - let mut h = vec![]; - h.push("Encrypt the wallet with a password"); - h.push("Note 1: This will encrypt the seed and the sapling and transparent private keys."); - h.push(" Use 'unlock' to temporarily unlock the wallet for spending or 'decrypt' "); - h.push(" to permanatly remove the encryption"); - h.push("Note 2: If you forget the password, the only way to recover the wallet is to restore"); - h.push(" from the seed phrase."); - h.push("Usage:"); - h.push("encrypt password"); - h.push(""); - h.push("Example:"); - h.push("encrypt my_strong_password"); - - h.join("\n") - } - - fn short_help(&self) -> String { - "Encrypt the wallet with a password".to_string() - } - - fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { - if args.len() != 1 { - return self.help(); - } - - let passwd = args[0].to_string(); - - match lightclient.wallet.write().unwrap().encrypt(passwd) { - Ok(_) => object!{ "result" => "success" }, - Err(e) => object!{ - "result" => "error", - "error" => e.to_string() - } - }.pretty(2) - } -} - struct DecryptCommand {} impl Command for DecryptCommand { fn help(&self) -> String { diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index bc4403b..fc82141 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -169,6 +169,7 @@ impl LightClientConfig { match &self.chain_name[..] { "main" => mainnet::B58_PUBKEY_ADDRESS_PREFIX, + c => panic!("Unknown chain {}", c) } } @@ -177,7 +178,8 @@ impl LightClientConfig { pub fn base58_script_address(&self) -> [u8; 1] { match &self.chain_name[..] { "main" => mainnet::B58_SCRIPT_ADDRESS_PREFIX, - + + c => panic!("Unknown chain {}", c) } } @@ -299,12 +301,10 @@ impl LightClient { } // Export private keys - pub fn do_export(&self, addr: Option) -> JsonValue { + pub fn do_export(&self, addr: Option) -> Result { if !self.wallet.read().unwrap().is_unlocked_for_spending() { error!("Wallet is locked"); - return object!{ - "error" => "Wallet is locked" - }; + return Err("Wallet is locked"); } // Clone address so it can be moved into the closure @@ -342,6 +342,7 @@ impl LightClient { pub fn do_address(&self) -> JsonValue { let wallet = self.wallet.read().unwrap(); + // Collect z addresses let z_addresses = wallet.zaddress.read().unwrap().iter().map( |ad| { encode_payment_address(self.config.hrp_sapling_address(), &ad)