Resolved merge conflict by incorporating both suggestions.
This commit is contained in:
@@ -203,6 +203,46 @@ impl Command for ExportCommand {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -309,11 +349,11 @@ impl Command for SendCommand {
|
||||
// 2 - A single argument in the form of a JSON string that is "[{address: address, value: value, memo: memo},...]"
|
||||
|
||||
// 1 - Destination address. T or Z address
|
||||
if args.len() < 1 || args.len() > 3 {
|
||||
if args.len() < 1 || args.len() > 3 {
|
||||
return self.help();
|
||||
}
|
||||
|
||||
// Check for a single argument that can be parsed as JSON
|
||||
// Check for a single argument that can be parsed as JSON
|
||||
if args.len() == 1 {
|
||||
// Sometimes on the command line, people use "'" for the quotes, which json::parse doesn't
|
||||
// understand. So replace it with double-quotes
|
||||
@@ -327,11 +367,11 @@ impl Command for SendCommand {
|
||||
}
|
||||
};
|
||||
|
||||
if !json_args.is_array() {
|
||||
if !json_args.is_array() {
|
||||
return format!("Couldn't parse argument as array\n{}", self.help());
|
||||
}
|
||||
|
||||
let maybe_send_args = json_args.members().map( |j| {
|
||||
let maybe_send_args = json_args.members().map( |j| {
|
||||
if !j.has_key("address") || !j.has_key("amount") {
|
||||
Err(format!("Need 'address' and 'amount'\n"))
|
||||
} else {
|
||||
@@ -359,7 +399,6 @@ impl Command for SendCommand {
|
||||
};
|
||||
|
||||
let memo = if args.len() == 3 { Some(args[2].to_string()) } else {None};
|
||||
|
||||
lightclient.do_sync(true);
|
||||
match lightclient.do_send(vec!((args[0], value, memo))) {
|
||||
Ok(txid) => { object!{ "txid" => txid } },
|
||||
|
||||
@@ -284,7 +284,7 @@ pub fn broadcast_raw_tx(uri: &http::Uri, no_cert: bool, tx_bytes: Box<[u8]>) ->
|
||||
txid = txid[1..txid.len()-1].to_string();
|
||||
}
|
||||
|
||||
Ok(txid)
|
||||
Ok(txid)
|
||||
} else {
|
||||
Err(format!("Error: {:?}", sendresponse))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user