Skip to content

Commit

Permalink
fix: modify input payment type index for ledger also
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Mar 21, 2024
1 parent 46b8490 commit 80e70f4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/app/store/accounts/blockchain/bitcoin/bitcoin.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
getAssumedZeroIndexSigningConfig,
} from '@shared/crypto/bitcoin/signer-config';
import { allSighashTypes } from '@shared/rpc/methods/sign-psbt';
import { isNumber } from '@shared/utils';
import { isNumber, isUndefined } from '@shared/utils';

import { useAnalytics } from '@app/common/hooks/analytics/use-analytics';
import { useWalletType } from '@app/common/use-wallet-type';
Expand Down Expand Up @@ -130,14 +130,18 @@ export function useSignLedgerBitcoinTx() {

const btcSignerPsbtClone = btc.Transaction.fromPSBT(psbt.toBuffer());

const inputByPaymentType = signingConfig.map(config => [
config,
getInputPaymentType(
config.index,
btcSignerPsbtClone.getInput(config.index),
network.chain.bitcoin.bitcoinNetwork
),
]) as readonly [BitcoinInputSigningConfig, PaymentTypes][];
const inputByPaymentType = signingConfig.map(config => {
const inputIndex = btcSignerPsbtClone.getInput(config.index).index;
if (isUndefined(inputIndex)) throw new Error('Input must have an index for payment type');
return [
config,
getInputPaymentType(
inputIndex,
btcSignerPsbtClone.getInput(config.index),
network.chain.bitcoin.bitcoinNetwork
),
];
}) as readonly [BitcoinInputSigningConfig, PaymentTypes][];

//
// Taproot
Expand Down

0 comments on commit 80e70f4

Please sign in to comment.