diff --git a/wallet/src/cli/account.rs b/wallet/src/cli/account.rs index d10c8c50..b6202c1d 100644 --- a/wallet/src/cli/account.rs +++ b/wallet/src/cli/account.rs @@ -32,6 +32,12 @@ pub enum AccountSubcommand { /// List all accounts owned by the wallet #[command(visible_alias = "ls")] List {}, + /// Get keys (npk, ipk) for a private account + Keys { + /// Valid 32 byte base58 string with privacy prefix + #[arg(short, long)] + account_id: String, + }, } /// Represents generic register CLI subcommand @@ -283,6 +289,29 @@ impl WalletSubcommand for AccountSubcommand { println!("{accounts}"); Ok(SubcommandReturnValue::Empty) } + AccountSubcommand::Keys { account_id } => { + let (account_id, addr_kind) = parse_addr_with_privacy_prefix(&account_id)?; + + if addr_kind != AccountPrivacyKind::Private { + anyhow::bail!("Keys command only works for private accounts"); + } + + let account_id = account_id.parse()?; + + let (key, _) = wallet_core + .storage + .user_data + .get_private_account(&account_id) + .ok_or(anyhow::anyhow!("Private account not found in storage"))?; + + println!("npk {}", hex::encode(key.nullifer_public_key.0)); + println!( + "ipk {}", + hex::encode(key.incoming_viewing_public_key.to_bytes()) + ); + + Ok(SubcommandReturnValue::Empty) + } } } }