Skip to content

Commit

Permalink
CLI - Import commands for watch-only accounts changed to: account wat…
Browse files Browse the repository at this point in the history
…ch bip32 and account watch multisig.
  • Loading branch information
1bananagirl committed Aug 10, 2024
1 parent d35efb7 commit 95c6a65
Showing 1 changed file with 34 additions and 26 deletions.
60 changes: 34 additions & 26 deletions cli/src/modules/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ impl Account {
"account import mnemonic multisig [additional keys]",
"Import mnemonic and additional keys for a multisig account",
),
("account import bip32-watch", "Import a extended public key for a watch-only bip32 account"),
("account import multisig-watch", "Import extended public keys for a watch-only multisig account"),
],
None,
)?;
Expand Down Expand Up @@ -177,36 +175,46 @@ impl Account {

return Ok(());
}
"bip32-watch" => {
let account_name = if argv.is_empty() {
None
} else {
let name = argv.remove(0);
let name = name.trim().to_string();
Some(name)
};

let account_name = account_name.as_deref();
wizards::account::bip32_watch(&ctx, account_name).await?;
_ => {
tprintln!(ctx, "unknown account import type: '{import_kind}'");
tprintln!(ctx, "supported import types are: 'mnemonic', 'legacy-data' or 'multisig-watch'\r\n");
return Ok(());
}
"multisig-watch" => {
let account_name = if argv.is_empty() {
None
} else {
let name = argv.remove(0);
let name = name.trim().to_string();
}
}
"watch" => {
if argv.is_empty() {
tprintln!(ctx, "usage: 'account watch <watch-type> [account name]'");
tprintln!(ctx, "");
tprintln!(ctx, "examples:");
tprintln!(ctx, "");
ctx.term().help(
&[
("account watch bip32", "Import a extended public key for a watch-only bip32 account"),
("account watch multisig", "Import extended public keys for a watch-only multisig account"),
],
None,
)?;

return Ok(());
}

Some(name)
};
let watch_kind = argv.remove(0);

let account_name = account_name.as_deref();
wizards::account::multisig_watch(&ctx, account_name).await?;
let account_name = argv.first().map(|name| name.trim()).filter(|name| !name.is_empty()).map(|name| name.to_string());

return Ok(());
let account_name = account_name.as_deref();

match watch_kind.as_ref() {
"bip32" => {
wizards::account::bip32_watch(&ctx, account_name).await?;
}
"multisig" => {
wizards::account::multisig_watch(&ctx, account_name).await?;
}
_ => {
tprintln!(ctx, "unknown account import type: '{import_kind}'");
tprintln!(ctx, "supported import types are: 'mnemonic', 'legacy-data' or 'multisig-watch'\r\n");
tprintln!(ctx, "unknown account watch type: '{watch_kind}'");
tprintln!(ctx, "supported watch types are: 'bip32' or 'multisig'\r\n");
return Ok(());
}
}
Expand Down

0 comments on commit 95c6a65

Please sign in to comment.