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.
This commit is contained in:
Olaoluwa Osuntokun 2017-11-30 22:12:50 -08:00
parent c27e87f168
commit b8bed9a677
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
1 changed files with 9 additions and 1 deletions

View File

@ -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