Skip to content

Commit

Permalink
fix: filter network dust amounts when sending all
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Nov 28, 2023
1 parent e9da651 commit b7a34a9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export function determineUtxosForSpendAll({

const txSizer = new BtcSizeFeeEstimator();

const filteredUtxos = utxos.filter(utxo => utxo.value >= BTC_P2WPKH_DUST_AMOUNT);

const sizeInfo = txSizer.calcTxSize({
input_script: 'p2wpkh',
input_count: utxos.length,
input_count: filteredUtxos.length,
[addressInfo.type + '_output_count']: 1,
});

Expand All @@ -37,8 +39,7 @@ export function determineUtxosForSpendAll({
const fee = Math.ceil(sizeInfo.txVBytes * feeRate);

return {
utxos,
inputs: utxos,
inputs: filteredUtxos,
outputs,
size: sizeInfo.txVBytes,
fee,
Expand Down

0 comments on commit b7a34a9

Please sign in to comment.