multi: apply the new type lntypes.WeightUnit

This commit is contained in:
yyforyongyu committed 2024-05-25 13:37:13 +08:00
1 parent dc9a0b31c0
commit 8da68bb7db
36 files changed
+178 -133

No files matched your search

+7 -3
View File
@@ -13,6 +13,7 @@ import (
"github.com/lightningnetwork/lnd/input"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lntest/wait"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/lnwire"
@@ -212,8 +213,9 @@ func CalcStaticFee(c lnrpc.CommitmentType, numHTLCs int) btcutil.Amount {
anchors = anchorSize
}
return feePerKw.FeeForWeight(int64(commitWeight+htlcWeight*numHTLCs)) +
anchors
totalWeight := commitWeight + htlcWeight*numHTLCs
return feePerKw.FeeForWeight(lntypes.WeightUnit(totalWeight)) + anchors
}
// CalculateMaxHtlc re-implements the RequiredRemoteChannelReserve of the
@@ -266,8 +268,10 @@ func CalcStaticFeeBuffer(c lnrpc.CommitmentType, numHTLCs int) btcutil.Amount {
// Account for the HTLC which will be required when sending an htlc.
numHTLCs++
totalWeight := commitWeight + numHTLCs*htlcWeight
feeBuffer := lnwallet.CalcFeeBuffer(
feePerKw, int64(commitWeight+numHTLCs*htlcWeight),
feePerKw, lntypes.WeightUnit(totalWeight),
)
return feeBuffer.ToSatoshis()