From b7a34a9bc64d7f5fca205886bdc8519c164754d6 Mon Sep 17 00:00:00 2001 From: kyranjamie Date: Thu, 16 Nov 2023 12:24:55 +0100 Subject: [PATCH] fix: filter network dust amounts when sending all --- .../bitcoin/coinselect/local-coin-selection.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts b/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts index e06fdae6d67..b90723e03a4 100644 --- a/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts +++ b/src/app/common/transactions/bitcoin/coinselect/local-coin-selection.ts @@ -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, }); @@ -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,