mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-08-01 12:51:28 +00:00
Add lock command
This commit is contained in:
@@ -332,6 +332,44 @@ impl Command for UnlockCommand {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct LockCommand {}
|
||||
impl Command for LockCommand {
|
||||
fn help(&self) -> String {
|
||||
let mut h = vec![];
|
||||
h.push("Lock a wallet that's been temporarily unlocked. You should already have encryption enabled.");
|
||||
h.push("Note 1: This will remove all spending keys from memory. The wallet remains encrypted on disk");
|
||||
h.push("Note 2: If you've forgotten the password, the only way to recover the wallet is to restore");
|
||||
h.push(" from the seed phrase.");
|
||||
h.push("Usage:");
|
||||
h.push("lock");
|
||||
h.push("");
|
||||
h.push("Example:");
|
||||
h.push("lock");
|
||||
|
||||
h.join("\n")
|
||||
}
|
||||
|
||||
fn short_help(&self) -> String {
|
||||
"Lock a wallet that's been temporarily unlocked".to_string()
|
||||
}
|
||||
|
||||
fn exec(&self, args: &[&str], lightclient: &LightClient) -> String {
|
||||
if args.len() != 0 {
|
||||
return self.help();
|
||||
}
|
||||
|
||||
match lightclient.wallet.write().unwrap().lock() {
|
||||
Ok(_) => object!{ "result" => "success" },
|
||||
Err(e) => object!{
|
||||
"result" => "error",
|
||||
"error" => e.to_string()
|
||||
}
|
||||
}.pretty(2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct SendCommand {}
|
||||
impl Command for SendCommand {
|
||||
fn help(&self) -> String {
|
||||
@@ -666,6 +704,7 @@ pub fn get_commands() -> Box<HashMap<String, Box<dyn Command>>> {
|
||||
map.insert("encrypt".to_string(), Box::new(EncryptCommand{}));
|
||||
map.insert("decrypt".to_string(), Box::new(DecryptCommand{}));
|
||||
map.insert("unlock".to_string(), Box::new(UnlockCommand{}));
|
||||
map.insert("lock".to_string(), Box::new(LockCommand{}));
|
||||
map.insert("fixbip39bug".to_string(), Box::new(FixBip39BugCommand{}));
|
||||
|
||||
Box::new(map)
|
||||
|
Reference in New Issue
Block a user