@@ -2727,15 +2727,10 @@ func (l *channelLink) MayAddOutgoingHtlc(amt lnwire.MilliSatoshi) error {
27272727// method.
27282728//
27292729// NOTE: Part of the dustHandler interface.
2730- func (l * channelLink ) getDustSum (remote bool ,
2730+ func (l * channelLink ) getDustSum (whoseCommit lntypes. ChannelParty ,
27312731 dryRunFee fn.Option [chainfee.SatPerKWeight ]) lnwire.MilliSatoshi {
27322732
2733- party := lntypes .Local
2734- if remote {
2735- party = lntypes .Remote
2736- }
2737-
2738- return l .channel .GetDustSum (party , dryRunFee )
2733+ return l .channel .GetDustSum (whoseCommit , dryRunFee )
27392734}
27402735
27412736// getFeeRate is a wrapper method that retrieves the underlying channel's
@@ -2789,8 +2784,8 @@ func (l *channelLink) exceedsFeeExposureLimit(
27892784
27902785 // Get the sum of dust for both the local and remote commitments using
27912786 // this "dry-run" fee.
2792- localDustSum := l .getDustSum (false , dryRunFee )
2793- remoteDustSum := l .getDustSum (true , dryRunFee )
2787+ localDustSum := l .getDustSum (lntypes . Local , dryRunFee )
2788+ remoteDustSum := l .getDustSum (lntypes . Remote , dryRunFee )
27942789
27952790 // Calculate the local and remote commitment fees using this dry-run
27962791 // fee.
@@ -2831,12 +2826,16 @@ func (l *channelLink) isOverexposedWithHtlc(htlc *lnwire.UpdateAddHTLC,
28312826 amount := htlc .Amount .ToSatoshis ()
28322827
28332828 // See if this HTLC is dust on both the local and remote commitments.
2834- isLocalDust := dustClosure (feeRate , incoming , true , amount )
2835- isRemoteDust := dustClosure (feeRate , incoming , false , amount )
2829+ isLocalDust := dustClosure (feeRate , incoming , lntypes . Local , amount )
2830+ isRemoteDust := dustClosure (feeRate , incoming , lntypes . Remote , amount )
28362831
28372832 // Calculate the dust sum for the local and remote commitments.
2838- localDustSum := l .getDustSum (false , fn .None [chainfee.SatPerKWeight ]())
2839- remoteDustSum := l .getDustSum (true , fn .None [chainfee.SatPerKWeight ]())
2833+ localDustSum := l .getDustSum (
2834+ lntypes .Local , fn .None [chainfee.SatPerKWeight ](),
2835+ )
2836+ remoteDustSum := l .getDustSum (
2837+ lntypes .Remote , fn .None [chainfee.SatPerKWeight ](),
2838+ )
28402839
28412840 // Grab the larger of the local and remote commitment fees w/o dust.
28422841 commitFee := l .getCommitFee (false )
@@ -2887,25 +2886,26 @@ func (l *channelLink) isOverexposedWithHtlc(htlc *lnwire.UpdateAddHTLC,
28872886// the HTLC is incoming (i.e. one that the remote sent), a boolean denoting
28882887// whether to evaluate on the local or remote commit, and finally an HTLC
28892888// amount to test.
2890- type dustClosure func (chainfee.SatPerKWeight , bool , bool , btcutil.Amount ) bool
2889+ type dustClosure func (feerate chainfee.SatPerKWeight , incoming bool ,
2890+ whoseCommit lntypes.ChannelParty , amt btcutil.Amount ) bool
28912891
28922892// dustHelper is used to construct the dustClosure.
28932893func dustHelper (chantype channeldb.ChannelType , localDustLimit ,
28942894 remoteDustLimit btcutil.Amount ) dustClosure {
28952895
2896- isDust := func (feerate chainfee.SatPerKWeight , incoming ,
2897- localCommit bool , amt btcutil.Amount ) bool {
2896+ isDust := func (feerate chainfee.SatPerKWeight , incoming bool ,
2897+ whoseCommit lntypes. ChannelParty , amt btcutil.Amount ) bool {
28982898
2899- if localCommit {
2900- return lnwallet . HtlcIsDust (
2901- chantype , incoming , lntypes . Local , feerate , amt ,
2902- localDustLimit ,
2903- )
2899+ var dustLimit btcutil. Amount
2900+ if whoseCommit . IsLocal () {
2901+ dustLimit = localDustLimit
2902+ } else {
2903+ dustLimit = remoteDustLimit
29042904 }
29052905
29062906 return lnwallet .HtlcIsDust (
2907- chantype , incoming , lntypes . Remote , feerate , amt ,
2908- remoteDustLimit ,
2907+ chantype , incoming , whoseCommit , feerate , amt ,
2908+ dustLimit ,
29092909 )
29102910 }
29112911
0 commit comments