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:
parent
c27e87f168
commit
b8bed9a677
@ -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
|
// 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.
|
// 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
|
// fetchEstimate returns a fee estimate for a transaction be be confirmed in
|
||||||
|
Loading…
Reference in New Issue
Block a user