mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-25 08:33:08 +00:00
Move the feature to get --keys
This commit is contained in:
parent
f4978c1bde
commit
562ab63735
@ -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,
|
||||
@ -36,12 +39,6 @@ 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
|
||||
@ -207,7 +204,11 @@ impl WalletSubcommand for AccountSubcommand {
|
||||
wallet_core: &mut WalletCore,
|
||||
) -> Result<SubcommandReturnValue> {
|
||||
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()?;
|
||||
@ -238,6 +239,24 @@ impl WalletSubcommand for AccountSubcommand {
|
||||
println!("{description}");
|
||||
println!("{json_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) => {
|
||||
@ -357,29 +376,6 @@ 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