From 980c341d0e42c9967f25c78ead28d2a8c51138e4 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Thu, 1 Oct 2020 20:23:43 +0200 Subject: [PATCH] sync for imported privkeys from 0 --- lib/src/commands.rs | 9 ++++++--- lib/src/lightclient.rs | 4 ++-- lib/src/lightwallet.rs | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/src/commands.rs b/lib/src/commands.rs index 9f1934e..9f00664 100644 --- a/lib/src/commands.rs +++ b/lib/src/commands.rs @@ -696,10 +696,13 @@ impl Command for TImportCommand { } fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { - - let key = args[0]; + if args.len() < 1 || args.len() > 2 { + return format!("Insufficient arguments\n\n{}", self.help()); + } - let r = match lightclient.do_import_tk(key.to_string()){ + 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 1e4d668..fcc980d 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -1011,7 +1011,7 @@ impl LightClient { } /// Import a new private key - pub fn do_import_tk(&self, sk: String) -> Result { + pub fn do_import_tk(&self, sk: String, birthday: u64) -> Result { if !self.wallet.read().unwrap().is_unlocked_for_spending() { error!("Wallet is locked"); return Err("Wallet is locked".to_string()); @@ -1020,7 +1020,7 @@ impl LightClient { let new_address = { let wallet = self.wallet.write().unwrap(); - let addr = wallet.import_taddr(sk); + let addr = wallet.import_taddr(sk, birthday); if addr.starts_with("Error") { let e = format!("Error creating new address{}", addr); error!("{}", e); diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index e8f24b9..c92373e 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) -> String { + pub fn import_taddr(&self, sk: String, birthday: u64) -> String { if !self.unlocked { return "Error: Can't add key while wallet is locked".to_string(); }