Skip to content

Commit

Permalink
fix: only decorate psbt inputs without an existing nonWitnessUtxo
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed May 10, 2024
1 parent 76fa95e commit aaf9edf
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ export function useUpdateLedgerSpecificNativeSegwitUtxoHexForAdddressIndexZero()
);

inputSigningConfig.forEach(({ index }) => {
// don't update nonWitnessUtxo if it already exists
if (tx.data.inputs.every(input => !isDefined(input.nonWitnessUtxo))) {
tx.updateInput(index, {
nonWitnessUtxo: Buffer.from(inputsTxHex[index], 'hex'),
});
void analytics.track('ledger_nativesegwit_add_nonwitnessutxo');
} else {
void analytics.track('ledger_nativesegwit_skip_add_nonwitnessutxo');
}
// decorate input with nonWitnessUtxo unless it already exists
tx.data.inputs.every(input => {
if (!isDefined(input.nonWitnessUtxo)) {
tx.updateInput(index, {
nonWitnessUtxo: Buffer.from(inputsTxHex[index], 'hex'),
});
void analytics.track('ledger_nativesegwit_add_nonwitnessutxo');
} else {
void analytics.track('ledger_nativesegwit_skip_add_nonwitnessutxo');
}
});
});
};
}
Expand Down

0 comments on commit aaf9edf

Please sign in to comment.