From 40d978e8f7530c2124b0d87869a2e5244d210ef1 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman <4752801+elizabethengelman@users.noreply.github.com> Date: Fri, 3 May 2024 11:42:45 -0400 Subject: [PATCH] Fix SignatureHint --- cmd/crates/stellar-ledger/src/lib.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cmd/crates/stellar-ledger/src/lib.rs b/cmd/crates/stellar-ledger/src/lib.rs index 7fb79c4c7..9226b6a30 100644 --- a/cmd/crates/stellar-ledger/src/lib.rs +++ b/cmd/crates/stellar-ledger/src/lib.rs @@ -302,9 +302,17 @@ impl Stellar for LedgerSigner { } })?; + let hint = source_account.to_string().into_bytes()[28..] + .try_into() + .map_err(|e| { + tracing::error!("Error converting source_account to string: {e}"); + Error::MissingSignerForAddress { + address: source_account.to_string(), + } + })?; let sig_bytes = signature.try_into()?; Ok(DecoratedSignature { - hint: SignatureHint([0u8; 4]), //FIXME + hint: SignatureHint(hint), signature: Signature(sig_bytes), }) } @@ -312,7 +320,7 @@ impl Stellar for LedgerSigner { fn sign_txn( &self, txn: Transaction, - _source_account: &stellar_strkey::Strkey, + source_account: &stellar_strkey::Strkey, ) -> Result { let signature = block_on(self.sign_transaction(self.hd_path.clone(), txn.clone())) .map_err(|e| { @@ -322,9 +330,17 @@ impl Stellar for LedgerSigner { } })?; + let hint = source_account.to_string().into_bytes()[28..] + .try_into() + .map_err(|e| { + tracing::error!("Error converting source_account to string: {e}"); + Error::MissingSignerForAddress { + address: source_account.to_string(), + } + })?; let sig_bytes = signature.try_into()?; let decorated_signature = DecoratedSignature { - hint: SignatureHint([0u8; 4]), //FIXME + hint: SignatureHint(hint), signature: Signature(sig_bytes), };