diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 7e767d68..090f8f00 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -4031,7 +4031,7 @@ func (lc *LightningChannel) computeView(view *htlcView, remoteChain bool, } for _, htlc := range filteredHTLCView.theirUpdates { if htlcIsDust( - lc.channelState.ChanType, !remoteChain, !remoteChain, + lc.channelState.ChanType, true, !remoteChain, feePerKw, htlc.Amount.ToSatoshis(), dustLimit, ) { continue diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index 18d1c924..b69b2faf 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -5347,6 +5347,9 @@ func TestChanCommitWeightDustHtlcs(t *testing.T) { } defer cleanUp() + aliceDustlimit := lnwire.NewMSatFromSatoshis( + aliceChannel.channelState.LocalChanCfg.DustLimit, + ) bobDustlimit := lnwire.NewMSatFromSatoshis( bobChannel.channelState.LocalChanCfg.DustLimit, ) @@ -5354,6 +5357,9 @@ func TestChanCommitWeightDustHtlcs(t *testing.T) { feeRate := chainfee.SatPerKWeight( aliceChannel.channelState.LocalCommitment.FeePerKw, ) + htlcTimeoutFee := lnwire.NewMSatFromSatoshis( + HtlcTimeoutFee(aliceChannel.channelState.ChanType, feeRate), + ) htlcSuccessFee := lnwire.NewMSatFromSatoshis( HtlcSuccessFee(aliceChannel.channelState.ChanType, feeRate), ) @@ -5436,6 +5442,27 @@ func TestChanCommitWeightDustHtlcs(t *testing.T) { // Settle the HTLC, bringing commitment weight back to base. settleHtlc(preimg) + + // Now we do a similar check from Bob's POV. Start with getting his + // current view of Alice's commitment weight. + weight1 = remoteCommitWeight(bobChannel) + + // We'll add an HTLC from Alice to Bob, that is just above dust on + // Alice's commitment. Now we'll use the timeout fee. + aliceDustHtlc := aliceDustlimit + htlcTimeoutFee + preimg = addHtlc(aliceDustHtlc) + + // Get the current remote commitment weight from Bob's POV, and ensure + // it is now heavier, since Alice added a non-dust HTLC. + weight2 = remoteCommitWeight(bobChannel) + require.Greater(t, weight2, weight1) + + // Ensure the current remote commit has the expected commitfee. + calcFee = feeRate.FeeForWeight(weight2) + remoteCommitFee = bobChannel.channelState.RemoteCommitment.CommitFee + require.Equal(t, calcFee, remoteCommitFee) + + settleHtlc(preimg) } // TestSignCommitmentFailNotLockedIn tests that a channel will not attempt to