@@ -630,6 +630,11 @@ func CreateAllocations(chanState *channeldb.OpenChannel, ourBalance,
630630 leaseExpiry = chanState .ThawHeight
631631 }
632632
633+ dustLimit := chanState .LocalChanCfg .DustLimit
634+ if ! isOurCommit {
635+ dustLimit = chanState .RemoteChanCfg .DustLimit
636+ }
637+
633638 // The "local" and "remote" notations are always from the perspective of
634639 // the local node. So if we want to find out the asset balance of the
635640 // _initiator_ of the channel, we just need to take into account the
@@ -707,6 +712,19 @@ func CreateAllocations(chanState *channeldb.OpenChannel, ourBalance,
707712 allocType = CommitAllocationHtlcIncoming
708713 }
709714
715+ // If HTLC is dust, do not create allocation for it.
716+ isDust := lnwallet .HtlcIsDust (
717+ chanState .ChanType , isIncoming , isOurCommit ,
718+ filteredView .FeePerKw , htlc .Amount .ToSatoshis (),
719+ dustLimit ,
720+ )
721+ if isDust {
722+ // We need to error out, as a dust HTLC carrying assets
723+ // should not be expected.
724+ return fmt .Errorf ("error creating asset HTLC " +
725+ "allocation, HTLC is dust" )
726+ }
727+
710728 allocations = append (allocations , & Allocation {
711729 Type : allocType ,
712730 Amount : rfqmsg .Sum (htlc .AssetBalances ),
@@ -773,6 +791,16 @@ func CreateAllocations(chanState *channeldb.OpenChannel, ourBalance,
773791 "sibling: %w" , err )
774792 }
775793
794+ // If HTLC is dust, do not create allocation for it.
795+ isDust := lnwallet .HtlcIsDust (
796+ chanState .ChanType , isIncoming , isOurCommit ,
797+ filteredView .FeePerKw , htlc .Amount .ToSatoshis (),
798+ dustLimit ,
799+ )
800+ if isDust {
801+ return nil
802+ }
803+
776804 allocations = append (allocations , & Allocation {
777805 Type : AllocationTypeNoAssets ,
778806 BtcAmount : htlc .Amount .ToSatoshis (),
0 commit comments