htlcswitch+routing: PaymentBandwidth accepts channel peer pubkey argument

This commit is contained in:
George Tsagkarelis
2025-06-26 12:11:56 +02:00
committed by Oliver Gugger
parent ab036990b5
commit 128b23e813
3 changed files with 13 additions and 3 deletions

View File

@@ -522,7 +522,8 @@ type AuxTrafficShaper interface {
PaymentBandwidth(fundingBlob, htlcBlob,
commitmentBlob fn.Option[tlv.Blob],
linkBandwidth, htlcAmt lnwire.MilliSatoshi,
htlcView lnwallet.AuxHtlcView) (lnwire.MilliSatoshi, error)
htlcView lnwallet.AuxHtlcView,
peer route.Vertex) (lnwire.MilliSatoshi, error)
// IsCustomHTLC returns true if the HTLC carries the set of relevant
// custom records to put it under the purview of the traffic shaper,

View File

@@ -31,6 +31,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/queue"
"github.com/lightningnetwork/lnd/record"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/ticker"
"github.com/lightningnetwork/lnd/tlv"
)
@@ -3503,11 +3504,19 @@ func (l *channelLink) AuxBandwidth(amount lnwire.MilliSatoshi,
})
}
peerBytes := l.cfg.Peer.PubKey()
peer, err := route.NewVertexFromBytes(peerBytes[:])
if err != nil {
return fn.Err[OptionalBandwidth](fmt.Errorf("failed to decode "+
"peer pub key: %v", err))
}
// Ask for a specific bandwidth to be used for the channel.
commitmentBlob := l.CommitmentCustomBlob()
auxBandwidth, err := ts.PaymentBandwidth(
fundingBlob, htlcBlob, commitmentBlob, l.Bandwidth(), amount,
l.channel.FetchLatestAuxHTLCView(),
l.channel.FetchLatestAuxHTLCView(), peer,
)
if err != nil {
return fn.Err[OptionalBandwidth](fmt.Errorf("failed to get "+