From b8bed9a67752f35cc079ef98cf77c40b8a322424 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 30 Nov 2017 22:12:50 -0800 Subject: [PATCH] lnwallet: in BtcdFeeEstimator is sat/byte is too low, fallback to default rate In this commit, we fix an existing bug within the EstimateFeePerWeight method for the BtcdFeeEstimator. If the sat/byte value returned was too low, then it was possible for us to end up with a zero valued sat/weight. We correct this issue by detecting, and falling back to the default fee rate if so. --- lnwallet/fee_estimator.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lnwallet/fee_estimator.go b/lnwallet/fee_estimator.go index 845d98ab..567b7b6d 100644 --- a/lnwallet/fee_estimator.go +++ b/lnwallet/fee_estimator.go @@ -159,7 +159,15 @@ func (b *BtcdFeeEstimator) EstimateFeePerWeight(numBlocks uint32) (btcutil.Amoun // We'll scale down the fee per byte to fee per weight, as for each raw // byte, there's 1/4 unit of weight mapped to it. - return btcutil.Amount(feePerByte / blockchain.WitnessScaleFactor), nil + satWeight := feePerByte / blockchain.WitnessScaleFactor + + // If this ends up scaling down to a zero sat/weight amount, then we'll + // use the default fallback fee rate. + if satWeight == 0 { + return b.fallBackFeeRate / blockchain.WitnessScaleFactor, nil + } + + return satWeight, nil } // fetchEstimate returns a fee estimate for a transaction be be confirmed in