@@ -138,6 +138,13 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID,
138138
139139 auxBandwidth lnwire.MilliSatoshi
140140 auxBandwidthDetermined bool
141+
142+ // htlcAmount is the amount we're going to use to check if we
143+ // can add another HTLC to the channel. If the external traffic
144+ // shaper is handling the channel, we'll use 0 to just sanity
145+ // check the number of HTLCs on the channel, since we don't know
146+ // the actual HTLC amount that will be sent.
147+ htlcAmount = amount
141148 )
142149 err = fn .MapOptionZ (b .trafficShaper , func (ts TlvTrafficShaper ) error {
143150 fundingBlob := link .FundingCustomBlob ()
@@ -171,6 +178,15 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID,
171178
172179 auxBandwidthDetermined = true
173180
181+ // We don't know the actual HTLC amount that will be sent using
182+ // the custom channel. But we'll still want to make sure we can
183+ // add another HTLC, using the MayAddOutgoingHtlc method below.
184+ // Passing 0 into that method will use the minimum HTLC value
185+ // for the channel, which is okay to just check we don't exceed
186+ // the max number of HTLCs on the channel. A proper balance
187+ // check is done elsewhere.
188+ htlcAmount = 0
189+
174190 return nil
175191 })
176192 if err != nil {
@@ -180,11 +196,11 @@ func (b *bandwidthManager) getBandwidth(cid lnwire.ShortChannelID,
180196 return 0
181197 }
182198
183- // If our link isn't currently in a state where it can add
184- // another outgoing htlc, treat the link as unusable.
185- if err := link .MayAddOutgoingHtlc (amount ); err != nil {
199+ // If our link isn't currently in a state where it can add another
200+ // outgoing htlc, treat the link as unusable.
201+ if err := link .MayAddOutgoingHtlc (htlcAmount ); err != nil {
186202 log .Warnf ("ShortChannelID=%v: cannot add outgoing " +
187- "htlc: %v" , cid , err )
203+ "htlc with amount %v : %v" , cid , htlcAmount , err )
188204 return 0
189205 }
190206
0 commit comments