Skip to content

Commit accd57a

Browse files
committed
tapchannel: add dust checks for allocations
1 parent 72551b4 commit accd57a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tapchannel/commitment.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,20 @@ func CreateAllocations(chanState *channeldb.OpenChannel, ourBalance,
707707
allocType = CommitAllocationHtlcIncoming
708708
}
709709

710+
// If HTLC is dust, do not create allocation for it.
711+
isDust := lnwallet.HtlcIsDust(chanState.ChanType, isIncoming,
712+
isOurCommit, filteredView.FeePerKw,
713+
htlc.Amount.ToSatoshis(),
714+
chanState.LocalChanCfg.DustLimit)
715+
if isDust {
716+
// We need to error out, as a dust HTLC carrying assets
717+
// should not be expected.
718+
return fmt.Errorf("error creating asset HTLC " +
719+
"allocation, HTLC is dust")
720+
}
721+
722+
log.Infof("### isDust=%v, amt=%v, dustLimit=%v", isDust, htlc.Amount.ToSatoshis(), chanState.LocalChanCfg.DustLimit)
723+
710724
allocations = append(allocations, &Allocation{
711725
Type: allocType,
712726
Amount: rfqmsg.Sum(htlc.AssetBalances),
@@ -773,6 +787,15 @@ func CreateAllocations(chanState *channeldb.OpenChannel, ourBalance,
773787
"sibling: %w", err)
774788
}
775789

790+
// If HTLC is dust, do not create allocation for it.
791+
isDust := lnwallet.HtlcIsDust(chanState.ChanType, isIncoming,
792+
isOurCommit, filteredView.FeePerKw,
793+
htlc.Amount.ToSatoshis(),
794+
chanState.LocalChanCfg.DustLimit)
795+
if isDust {
796+
return nil
797+
}
798+
776799
allocations = append(allocations, &Allocation{
777800
Type: AllocationTypeNoAssets,
778801
BtcAmount: htlc.Amount.ToSatoshis(),

0 commit comments

Comments
 (0)