Skip to content

Commit

Permalink
Only use ledger for outputs that have managed keys
Browse files Browse the repository at this point in the history
  • Loading branch information
brianp committed Apr 10, 2024
1 parent 93e9f09 commit 41c1c99
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions base_layer/core/src/transactions/key_manager/inner.rs
Expand Up @@ -439,10 +439,11 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
// -----------------------------------------------------------------------------------------------------------------

pub async fn get_script_private_key(&self, script_key_id: &TariKeyId) -> Result<PrivateKey, TransactionError> {
let k = self.get_private_key(script_key_id).await.map_err(|e| e.into());
match self.wallet_type {
WalletType::Software => k,
WalletType::Ledger(account) => {
match (self.wallet_type, script_key_id) {
(WalletType::Software, _) | (WalletType::Ledger(_), TariKeyId::Imported { .. } | TariKeyId::Zero) => {
self.get_private_key(script_key_id).await.map_err(|e| e.into())
},
(WalletType::Ledger(account), TariKeyId::Managed { branch: _, index }) => {
#[cfg(not(feature = "ledger"))]
return Err(TransactionError::LedgerDeviceError(LedgerDeviceError::NotSupported));

Expand All @@ -452,7 +453,7 @@ where TBackend: KeyManagerBackend<PublicKey> + 'static
.map_err(|e| LedgerDeviceError::HidApi(e.to_string()))?;

let mut data = (account as u64).to_le_bytes().to_vec();
data.extend_from_slice(k?.as_bytes()); // Static index. Fix this.
data.extend_from_slice(&index.to_le_bytes()); // Static index. Fix this.
let command = APDUCommand {
cla: 0x80,
ins: 0x03,
Expand Down

0 comments on commit 41c1c99

Please sign in to comment.