From 634967c5c8091f72fa8c08fa19c3e0d52004c23a Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Fri, 24 May 2024 22:49:20 +0800 Subject: [PATCH] chainfee: add `FeeForVByte` on `SatPerKWeight` --- lnwallet/chainfee/rates.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lnwallet/chainfee/rates.go b/lnwallet/chainfee/rates.go index 98cefc13b..49711e31b 100644 --- a/lnwallet/chainfee/rates.go +++ b/lnwallet/chainfee/rates.go @@ -70,6 +70,12 @@ func (s SatPerKWeight) FeeForWeight(wu int64) btcutil.Amount { return btcutil.Amount(s) * btcutil.Amount(wu) / 1000 } +// FeeForVByte calculates the fee resulting from this fee rate and the given +// size in vbytes (vb). +func (s SatPerKWeight) FeeForVByte(vb int64) btcutil.Amount { + return s.FeePerKVByte().FeeForVSize(vb) +} + // FeePerKVByte converts the current fee rate from sat/kw to sat/kb. func (s SatPerKWeight) FeePerKVByte() SatPerKVByte { return SatPerKVByte(s * blockchain.WitnessScaleFactor)