From 8535a11e3774d79de2ebeaa5540567ccb4988f81 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Thu, 1 Oct 2020 20:40:16 +0200 Subject: [PATCH] fix command --- lib/src/commands.rs | 4 ++-- lib/src/lightclient.rs | 2 +- lib/src/lightwallet.rs | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/src/commands.rs b/lib/src/commands.rs index 9f00664..732235c 100644 --- a/lib/src/commands.rs +++ b/lib/src/commands.rs @@ -668,7 +668,7 @@ impl Command for ImportCommand { } let key = args[0]; - + let r = match lightclient.do_import_key(key.to_string(), 0) { Ok(r) => r.pretty(2), Err(e) => return format!("Error: {}", e), @@ -701,7 +701,7 @@ impl Command for TImportCommand { } let key = args[0]; - + let r = match lightclient.do_import_tk(key.to_string(), 0) { Ok(r) => r.pretty(2), Err(e) => return format!("Error: {}", e), diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index fcc980d..fa181a1 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -1018,7 +1018,7 @@ impl LightClient { } let new_address = { - let wallet = self.wallet.write().unwrap(); + let mut wallet = self.wallet.write().unwrap(); let addr = wallet.import_taddr(sk, birthday); if addr.starts_with("Error") { diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index c92373e..9c66639 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -628,7 +628,7 @@ impl LightWallet { address } - pub fn import_taddr(&self, sk: String, birthday: u64) -> String { + pub fn import_taddr(&mut self, sk: String, birthday: u64) -> String { if !self.unlocked { return "Error: Can't add key while wallet is locked".to_string(); } @@ -657,6 +657,11 @@ impl LightWallet { //// Add to tkeys self.tkeys.write().unwrap().push(WalletTKey::import_hdkey(sk_raw , address.clone())); + // Adjust wallet birthday + if birthday < self.birthday { + self.birthday = if birthday < self.config.sapling_activation_height {self.config.sapling_activation_height} else {birthday}; + } + address }