mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-25 16:43:11 +00:00
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.
This commit is contained in:
parent
54cc214c33
commit
f4978c1bde
@ -36,6 +36,12 @@ pub enum AccountSubcommand {
|
||||
#[arg(short, long)]
|
||||
long: bool,
|
||||
},
|
||||
/// 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
|
||||
@ -351,6 +357,29 @@ impl WalletSubcommand for AccountSubcommand {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user