From eaa043f585ba292e9659528cc0384590cb6215f8 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 18 Jun 2019 17:04:59 -0700 Subject: [PATCH] lnwallet/btcwallet: use relay fee not tx fee rate for dust check In this commit we fix a hidden bug in the transaction creating logic that was only manifested recently due to higher fees on Bitcoin's mainnet. Before this commit, we would use the target fee rate to determine if an output was dust or not. However, this is incorrect, as instead the relay fee should be used as this matches the policy checks widely deployed in Bitcoin full node today. To fix this issue we now properly use the relay fee when computing dust. This fixes the issue for the `EstimateFee` call, but the `SendOutputs` call also has a similar issue. However, this must be fixed within `btcwallet` itself, so it has been left out of this commit Fixes #3217. --- lnwallet/btcwallet/btcwallet.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 966cbb5b..268d8dd4 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -330,7 +330,14 @@ func (b *BtcWallet) CreateSimpleTx(outputs []*wire.TxOut, return nil, lnwallet.ErrNoOutputs } for _, output := range outputs { - err := txrules.CheckOutput(output, feeSatPerKB) + // When checking an output for things like dusty-ness, we'll + // use the default mempool relay fee rather than the target + // effective fee rate to ensure accuracy. Otherwise, we may + // mistakenly mark small-ish, but not quite dust output as + // dust. + err := txrules.CheckOutput( + output, txrules.DefaultRelayFeePerKb, + ) if err != nil { return nil, err }