From 74b20de700bbe07fa5fa37c012511c4a17cd8b33 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:34:55 -0500 Subject: [PATCH] Fix after merging with main --- cmd/soroban-cli/src/commands/keys/address.rs | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/cmd/soroban-cli/src/commands/keys/address.rs b/cmd/soroban-cli/src/commands/keys/address.rs index 145d8c30a..dd7818d49 100644 --- a/cmd/soroban-cli/src/commands/keys/address.rs +++ b/cmd/soroban-cli/src/commands/keys/address.rs @@ -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)] @@ -40,15 +40,20 @@ impl Cmd { Ok(()) } + pub fn private_key(&self) -> Result { + Ok(self + .locator + .read_identity(&self.name)? + .key_pair(self.hd_path)?) + } + pub fn public_key(&self) -> Result { - 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(), + )?) } } }