Skip to content

Commit

Permalink
Fix after merging with main
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman committed Dec 20, 2024
1 parent 03b84e8 commit 24269ce
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cmd/soroban-cli/src/commands/keys/address.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use clap::arg;

use crate::{
commands::config::{address, locator, secret},
xdr,
};
use crate::commands::config::{address, locator, secret};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand All @@ -24,7 +21,7 @@ pub enum Error {
#[group(skip)]
pub struct Cmd {
/// Name of identity to lookup, default test identity used if not provided
pub name: address::Address,
pub name: String,

/// If identity is a seed phrase use this hd path, default is 0
#[arg(long)]
Expand All @@ -40,15 +37,20 @@ impl Cmd {
Ok(())
}

pub fn private_key(&self) -> Result<ed25519_dalek::SigningKey, Error> {
Ok(self
.locator
.read_identity(&self.name)?
.key_pair(self.hd_path)?)
}

pub fn public_key(&self) -> Result<stellar_strkey::ed25519::PublicKey, Error> {
match self
.name
.resolve_muxed_account(&self.locator, self.hd_path)?
{
xdr::MuxedAccount::Ed25519(pk) => Ok(stellar_strkey::ed25519::PublicKey(pk.0)),
xdr::MuxedAccount::MuxedEd25519(xdr::MuxedAccountMed25519 { ed25519, .. }) => {
Ok(stellar_strkey::ed25519::PublicKey(ed25519.0))
}
if let Ok(key) = stellar_strkey::ed25519::PublicKey::from_string(&self.name) {
Ok(key)
} else {
Ok(stellar_strkey::ed25519::PublicKey::from_payload(
self.private_key()?.verifying_key().as_bytes(),
)?)
}
}
}

0 comments on commit 24269ce

Please sign in to comment.