Skip to content

Commit

Permalink
Account for potentially NaN sum in subtractFee
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed Jan 26, 2024
1 parent bcae575 commit db9c349
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- fixed: Check for NaN target totals in `subtractFee` style transactions

## 2.5.3 (2024-01-24)

- changed: Add insufficient funds check `subtractFee` style transactions
Expand Down
3 changes: 2 additions & 1 deletion src/common/utxobased/keymanager/utxopicker/subtractFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export function subtractFee(args: UtxoPickerArgs): UtxoPickerResult {
outputs[0].value -= fee

const targetValue = utils.sumOrNaN(targets)
if (fee > targetValue) return { inputs: utxos, fee, changeUsed: false }
if (isNaN(targetValue) || fee > targetValue)
return { inputs: utxos, fee, changeUsed: false }

return { inputs: utxos, outputs, fee, changeUsed: false }
}

0 comments on commit db9c349

Please sign in to comment.