Skip to content

Commit 3e4f920

Browse files
committed
tapchannel: add chan reserve check on PaymentBandwidth method
1 parent accd57a commit 3e4f920

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tapchannel/aux_traffic_shaper.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,19 @@ func (s *AuxTrafficShaper) PaymentBandwidth(htlcBlob,
140140
return linkBandwidth, nil
141141
}
142142

143+
htlcAmountMSat := lnwire.NewMSatFromSatoshis(DefaultOnChainHtlcAmount)
144+
145+
// Todo: grab actual channel reserve
146+
chanReserve := lnwire.MilliSatoshi(0)
147+
148+
// Check if the current link bandwidth can afford sending our default
149+
// htlc amount without dipping into the channel reserve. If it goes
150+
// below the reserve, we report zero bandwdith as we cannot push the
151+
// htlc amount.
152+
if linkBandwidth-htlcAmountMSat <= chanReserve {
153+
return 0, nil
154+
}
155+
143156
commitment, err := cmsg.DecodeCommitment(commitmentBytes)
144157
if err != nil {
145158
return 0, fmt.Errorf("error decoding commitment blob: %w", err)

0 commit comments

Comments
 (0)