From a74c30fbdd09c4fb33d3066fb6c1a40527458094 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 1 Mar 2023 21:31:43 -0800 Subject: [PATCH] lnwallet: update HtlcSuccessFee + HtlcTimeoutFee for taproot chans There's no fee, as taproot channels are always zero fee HTLC. --- lnwallet/commitment.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lnwallet/commitment.go b/lnwallet/commitment.go index bd698b5e9..163ea6e5e 100644 --- a/lnwallet/commitment.go +++ b/lnwallet/commitment.go @@ -482,17 +482,18 @@ func CommitWeight(chanType channeldb.ChannelType) int64 { func HtlcTimeoutFee(chanType channeldb.ChannelType, feePerKw chainfee.SatPerKWeight) btcutil.Amount { + switch { // For zero-fee HTLC channels, this will always be zero, regardless of // feerate. - if chanType.ZeroHtlcTxFee() { + case chanType.ZeroHtlcTxFee() || chanType.IsTaproot(): return 0 - } - if chanType.HasAnchors() { + case chanType.HasAnchors(): return feePerKw.FeeForWeight(input.HtlcTimeoutWeightConfirmed) - } - return feePerKw.FeeForWeight(input.HtlcTimeoutWeight) + default: + return feePerKw.FeeForWeight(input.HtlcTimeoutWeight) + } } // HtlcSuccessFee returns the fee in satoshis required for an HTLC success @@ -500,19 +501,18 @@ func HtlcTimeoutFee(chanType channeldb.ChannelType, func HtlcSuccessFee(chanType channeldb.ChannelType, feePerKw chainfee.SatPerKWeight) btcutil.Amount { + switch { // For zero-fee HTLC channels, this will always be zero, regardless of // feerate. - if chanType.ZeroHtlcTxFee() { + case chanType.ZeroHtlcTxFee() || chanType.IsTaproot(): return 0 - } - // TODO(roasbeef): fee is still off here? - - if chanType.HasAnchors() { + case chanType.HasAnchors(): return feePerKw.FeeForWeight(input.HtlcSuccessWeightConfirmed) - } - return feePerKw.FeeForWeight(input.HtlcSuccessWeight) + default: + return feePerKw.FeeForWeight(input.HtlcSuccessWeight) + } } // CommitScriptAnchors return the scripts to use for the local and remote