lnwallet+sweep: calculate max allowed feerate on BumpResult

This commit adds the method `MaxFeeRateAllowed` to calculate the max fee
rate. The caller may specify a large MaxFeeRate value, which cannot be
cover by the budget. In that case, we default to use the max feerate
calculated using `budget/weight`.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:29 +08:00
1 parent f85661d94a
commit ecd471ac75
3 files changed
+183

No files matched your search

+5
View File
@@ -58,6 +58,11 @@ func (s SatPerKVByte) String() string {
// SatPerKWeight represents a fee rate in sat/kw.
type SatPerKWeight btcutil.Amount
// NewSatPerKWeight creates a new fee rate in sat/kw.
func NewSatPerKWeight(fee btcutil.Amount, weight uint64) SatPerKWeight {
return SatPerKWeight(fee.MulF64(1000 / float64(weight)))
}
// FeeForWeight calculates the fee resulting from this fee rate and the given
// weight in weight units (wu).
func (s SatPerKWeight) FeeForWeight(wu int64) btcutil.Amount {