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 74b20de
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions cmd/soroban-cli/src/commands/keys/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 +40,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 74b20de

Please sign in to comment.