Skip to content

Commit

Permalink
tapchannel: add chan reserve check on PaymentBandwidth method
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeTsagk committed Sep 10, 2024
1 parent accd57a commit 3e4f920
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tapchannel/aux_traffic_shaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ func (s *AuxTrafficShaper) PaymentBandwidth(htlcBlob,
return linkBandwidth, nil
}

htlcAmountMSat := lnwire.NewMSatFromSatoshis(DefaultOnChainHtlcAmount)

// Todo: grab actual channel reserve
chanReserve := lnwire.MilliSatoshi(0)

// Check if the current link bandwidth can afford sending our default
// htlc amount without dipping into the channel reserve. If it goes
// below the reserve, we report zero bandwdith as we cannot push the
// htlc amount.
if linkBandwidth-htlcAmountMSat <= chanReserve {
return 0, nil
}

commitment, err := cmsg.DecodeCommitment(commitmentBytes)
if err != nil {
return 0, fmt.Errorf("error decoding commitment blob: %w", err)
Expand Down

0 comments on commit 3e4f920

Please sign in to comment.