diff --git a/src/app/features/ledger/flows/bitcoin-tx-signing/steps/approve-bitcoin-sign-ledger-tx.tsx b/src/app/features/ledger/flows/bitcoin-tx-signing/steps/approve-bitcoin-sign-ledger-tx.tsx index 0c6c9991395..26e7eee5513 100644 --- a/src/app/features/ledger/flows/bitcoin-tx-signing/steps/approve-bitcoin-sign-ledger-tx.tsx +++ b/src/app/features/ledger/flows/bitcoin-tx-signing/steps/approve-bitcoin-sign-ledger-tx.tsx @@ -1,6 +1,11 @@ import * as btc from '@scure/btc-signer'; -import { getPsbtTxInputs, getPsbtTxOutputs } from '@shared/crypto/bitcoin/bitcoin.utils'; +import { + getBitcoinInputValue, + getPsbtTxInputs, + getPsbtTxOutputs, +} from '@shared/crypto/bitcoin/bitcoin.utils'; +import { isDefined } from '@shared/utils'; import { useLedgerTxSigningContext } from '@app/features/ledger/generic-flows/tx-signing/ledger-sign-tx.context'; import { ApproveLedgerOperationLayout } from '@app/features/ledger/generic-steps/approve-ledger-operation/approve-ledger-operation.layout'; @@ -20,7 +25,7 @@ export function ApproveSignLedgerBitcoinTx() { [ ...getPsbtTxInputs(context.transaction as unknown as btc.Transaction).map((input, i) => [ `Input ${i + 1}`, - input.witnessUtxo?.amount?.toString() + ' sats', + getBitcoinInputValue(isDefined(input.index) ? input.index : 0, input) + ' sats', ]), ...getPsbtTxOutputs(context.transaction as unknown as btc.Transaction).map( (output, i) => [`Output ${i + 1}`, output.amount?.toString() + ' sats'] diff --git a/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts b/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts index 78effd995d5..3883cf3a556 100644 --- a/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts +++ b/src/app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks.ts @@ -15,7 +15,7 @@ import { getNativeSegwitAccountDerivationPath, } from '@shared/crypto/bitcoin/p2wpkh-address-gen'; import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config'; -import { reverseBytes } from '@shared/utils'; +import { isDefined, reverseBytes } from '@shared/utils'; import { mnemonicToRootNode } from '@app/common/keychain/keychain'; import { useBitcoinClient } from '@app/store/common/api-clients.hooks'; @@ -148,9 +148,12 @@ export function useUpdateLedgerSpecificNativeSegwitUtxoHexForAdddressIndexZero() ) ); inputSigningConfig.forEach(({ index }) => { - tx.updateInput(index, { - nonWitnessUtxo: Buffer.from(inputsTxHex[index], 'hex'), - }); + // don't update nonWitnessUtxo if it already exists + if (!tx.data.inputs.map(input => isDefined(input.nonWitnessUtxo))) { + tx.updateInput(index, { + nonWitnessUtxo: Buffer.from(inputsTxHex[index], 'hex'), + }); + } }); }; }