|
|
@ -475,7 +475,7 @@ impl Command for SendCommand { |
|
|
|
h.push("OR"); |
|
|
|
h.push("send '[{'address': <address>, 'amount': <amount in puposhis>, 'memo': <optional memo>}, ...]'"); |
|
|
|
h.push(""); |
|
|
|
h.push("NOTE: The fee required to send this transaction (currently HUSH 0.0001) is additionally detected from your balance."); |
|
|
|
h.push("NOTE: The fee required to send this transaction (currently HUSH 0.0001) is additionally deducted from your balance."); |
|
|
|
h.push("Example:"); |
|
|
|
h.push("send ztestsapling1x65nq4dgp0qfywgxcwk9n0fvm4fysmapgr2q00p85ju252h6l7mmxu2jg9cqqhtvzd69jwhgv8d 200000 \"Hello from the command line\""); |
|
|
|
h.push(""); |
|
|
@ -548,17 +548,12 @@ impl Command for SendCommand { |
|
|
|
return self.help() |
|
|
|
}; |
|
|
|
|
|
|
|
match lightclient.do_sync(true) { |
|
|
|
Ok(_) => { |
|
|
|
// Convert to the right format. String -> &str.
|
|
|
|
let tos = send_args.iter().map(|(a, v, m)| (a.as_str(), *v, m.clone()) ).collect::<Vec<_>>(); |
|
|
|
match lightclient.do_send(tos) { |
|
|
|
Ok(txid) => { object!{ "txid" => txid } }, |
|
|
|
Err(e) => { object!{ "error" => e } } |
|
|
|
}.pretty(2) |
|
|
|
}, |
|
|
|
Err(e) => e |
|
|
|
} |
|
|
|
// Convert to the right format. String -> &str.
|
|
|
|
let tos = send_args.iter().map(|(a, v, m)| (a.as_str(), *v, m.clone()) ).collect::<Vec<_>>(); |
|
|
|
match lightclient.do_send(tos) { |
|
|
|
Ok(txid) => { object!{ "txid" => txid } }, |
|
|
|
Err(e) => { object!{ "error" => e } } |
|
|
|
}.pretty(2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -673,30 +668,12 @@ impl Command for ImportCommand { |
|
|
|
} |
|
|
|
|
|
|
|
let key = args[0]; |
|
|
|
|
|
|
|
|
|
|
|
let rescan = if args.len() == 3 { |
|
|
|
if args[2] == "norescan" || args[2] == "false" || args[2] == "no" {
|
|
|
|
false
|
|
|
|
} else { |
|
|
|
return format!("Couldn't undestand the argument '{}'. Please pass 'norescan' to prevent rescanning the wallet", args[2]); |
|
|
|
} |
|
|
|
} else { |
|
|
|
true |
|
|
|
}; |
|
|
|
|
|
|
|
let r = match lightclient.do_import_key(key.to_string(), 0) { |
|
|
|
Ok(r) => r.pretty(2), |
|
|
|
Err(e) => return format!("Error: {}", e), |
|
|
|
}; |
|
|
|
|
|
|
|
if rescan { |
|
|
|
match lightclient.do_rescan() { |
|
|
|
Ok(_) => {}, |
|
|
|
Err(e) => return format!("Error: Rescan failed: {}", e), |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
@ -719,21 +696,53 @@ impl Command for TImportCommand { |
|
|
|
} |
|
|
|
|
|
|
|
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { |
|
|
|
|
|
|
|
if args.len() < 1 || args.len() > 2 { |
|
|
|
return format!("Insufficient arguments\n\n{}", self.help()); |
|
|
|
} |
|
|
|
|
|
|
|
let key = args[0]; |
|
|
|
|
|
|
|
let r = match lightclient.do_import_tk(key.to_string()){ |
|
|
|
let r = match lightclient.do_import_tk(key.to_string(), 0) { |
|
|
|
Ok(r) => r.pretty(2), |
|
|
|
Err(e) => return format!("Error: {}", e), |
|
|
|
}; |
|
|
|
|
|
|
|
match lightclient.do_rescan() { |
|
|
|
Ok(_) => {}, |
|
|
|
Err(e) => return format!("Error: Rescan failed: {}", e), |
|
|
|
}; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
struct ShieldCommand {} |
|
|
|
impl Command for ShieldCommand { |
|
|
|
fn help(&self) -> String { |
|
|
|
let mut h = vec![]; |
|
|
|
h.push("Shield all your transparent funds"); |
|
|
|
h.push("Usage:"); |
|
|
|
h.push("shield [optional address]"); |
|
|
|
h.push(""); |
|
|
|
h.push("NOTE: The fee required to send this transaction (currently HUSH 0.0001) is additionally deducted from your balance."); |
|
|
|
h.push("Example:"); |
|
|
|
h.push("shield"); |
|
|
|
h.push(""); |
|
|
|
|
|
|
|
return r; |
|
|
|
h.join("\n") |
|
|
|
} |
|
|
|
|
|
|
|
fn short_help(&self) -> String { |
|
|
|
"Shield your transparent HUSH into a sapling address".to_string() |
|
|
|
} |
|
|
|
|
|
|
|
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { |
|
|
|
// Parse the address or amount
|
|
|
|
let address = if args.len() > 0 { |
|
|
|
Some(args[0].to_string()) |
|
|
|
} else { |
|
|
|
None |
|
|
|
}; |
|
|
|
|
|
|
|
match lightclient.do_shield(address) { |
|
|
|
Ok(txid) => { object!{ "txid" => txid } }, |
|
|
|
Err(e) => { object!{ "error" => e } } |
|
|
|
}.pretty(2) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -905,6 +914,7 @@ pub fn get_commands() -> Box<HashMap<String, Box<dyn Command>>> { |
|
|
|
map.insert("info".to_string(), Box::new(InfoCommand{})); |
|
|
|
map.insert("coinsupply".to_string(), Box::new(CoinsupplyCommand{})); |
|
|
|
map.insert("send".to_string(), Box::new(SendCommand{})); |
|
|
|
map.insert("shield".to_string(), Box::new(ShieldCommand{})); |
|
|
|
map.insert("save".to_string(), Box::new(SaveCommand{})); |
|
|
|
map.insert("quit".to_string(), Box::new(QuitCommand{})); |
|
|
|
map.insert("list".to_string(), Box::new(TransactionsCommand{})); |
|
|
|