sync for imported privkeys from 0
This commit is contained in:
@@ -696,10 +696,13 @@ impl Command for TImportCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String {
|
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String {
|
||||||
|
if args.len() < 1 || args.len() > 2 {
|
||||||
let key = args[0];
|
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),
|
Ok(r) => r.pretty(2),
|
||||||
Err(e) => return format!("Error: {}", e),
|
Err(e) => return format!("Error: {}", e),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1011,7 +1011,7 @@ impl LightClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Import a new private key
|
/// Import a new private key
|
||||||
pub fn do_import_tk(&self, sk: String) -> Result<JsonValue, String> {
|
pub fn do_import_tk(&self, sk: String, birthday: u64) -> Result<JsonValue, String> {
|
||||||
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
||||||
error!("Wallet is locked");
|
error!("Wallet is locked");
|
||||||
return Err("Wallet is locked".to_string());
|
return Err("Wallet is locked".to_string());
|
||||||
@@ -1020,7 +1020,7 @@ impl LightClient {
|
|||||||
let new_address = {
|
let new_address = {
|
||||||
let wallet = self.wallet.write().unwrap();
|
let wallet = self.wallet.write().unwrap();
|
||||||
|
|
||||||
let addr = wallet.import_taddr(sk);
|
let addr = wallet.import_taddr(sk, birthday);
|
||||||
if addr.starts_with("Error") {
|
if addr.starts_with("Error") {
|
||||||
let e = format!("Error creating new address{}", addr);
|
let e = format!("Error creating new address{}", addr);
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
|
|||||||
@@ -628,7 +628,7 @@ impl LightWallet {
|
|||||||
address
|
address
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_taddr(&self, sk: String) -> String {
|
pub fn import_taddr(&self, sk: String, birthday: u64) -> String {
|
||||||
if !self.unlocked {
|
if !self.unlocked {
|
||||||
return "Error: Can't add key while wallet is locked".to_string();
|
return "Error: Can't add key while wallet is locked".to_string();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user