From fbb3bc184db2aaed2b98227abc9d8897c461a2bf Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 13 Aug 2020 16:43:00 -0700 Subject: [PATCH] wallet/txauthor: fix bug in dust calculation In this commit, we fix a 3 year old bug in dust calculation. Before this commit, the target fee of the transaction to be crafted would be used to determine dust. If the target fee is very high, then this would cause over all higher fees, as we'd base that dust computation off of that fee rate, rather than the min relay fee. To fix this, we always use the min relay fee at all times when computing dust. --- wallet/txauthor/author.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallet/txauthor/author.go b/wallet/txauthor/author.go index 18f996c..34449b5 100644 --- a/wallet/txauthor/author.go +++ b/wallet/txauthor/author.go @@ -133,7 +133,7 @@ func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb btcutil.Amount, changeIndex := -1 changeAmount := inputAmount - targetAmount - maxRequiredFee if changeAmount != 0 && !txrules.IsDustAmount(changeAmount, - txsizes.P2WPKHPkScriptSize, relayFeePerKb) { + txsizes.P2WPKHPkScriptSize, txrules.DefaultRelayFeePerKb) { changeScript, err := fetchChange() if err != nil { return nil, err