From 0b9dc45c7f3b34e67cb6695466d5666d1a9b2c73 Mon Sep 17 00:00:00 2001 From: fryorcraken Date: Tue, 6 Jan 2026 15:28:17 +1100 Subject: [PATCH 1/2] add `wallet account keys` command to display ipk/npk ipk and npk are needed to receive funds from an external account on a private account. They are currently only displayed at account creation (`wallet account new private`). With this command, it is now possible to print them at any time. --- wallet/src/cli/account.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/wallet/src/cli/account.rs b/wallet/src/cli/account.rs index d10c8c5..b6202c1 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) + } } } } From 04209159d297233600888cdaf569c0c6a2fd391d Mon Sep 17 00:00:00 2001 From: fryorcraken Date: Wed, 7 Jan 2026 10:07:44 +1100 Subject: [PATCH 2/2] Move the feature to `get --keys` --- wallet/src/cli/account.rs | 56 ++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/wallet/src/cli/account.rs b/wallet/src/cli/account.rs index b6202c1..ad6548f 100644 --- a/wallet/src/cli/account.rs +++ b/wallet/src/cli/account.rs @@ -20,6 +20,9 @@ pub enum AccountSubcommand { /// Flag to get raw account data #[arg(short, long)] raw: bool, + /// Display keys (npk, ipk) for private accounts + #[arg(short, long)] + keys: bool, /// Valid 32 byte base58 string with privacy prefix #[arg(short, long)] account_id: String, @@ -32,12 +35,6 @@ 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 @@ -163,7 +160,11 @@ impl WalletSubcommand for AccountSubcommand { wallet_core: &mut WalletCore, ) -> Result { match self { - AccountSubcommand::Get { raw, account_id } => { + AccountSubcommand::Get { + raw, + keys, + account_id, + } => { let (account_id, addr_kind) = parse_addr_with_privacy_prefix(&account_id)?; let account_id = account_id.parse()?; @@ -228,6 +229,24 @@ impl WalletSubcommand for AccountSubcommand { println!("{}", acc_view); + if keys { + if addr_kind != AccountPrivacyKind::Private { + anyhow::bail!("--keys option only works for private accounts"); + } + + 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) } AccountSubcommand::New(new_subcommand) => { @@ -289,29 +308,6 @@ 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) - } } } }