mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 22:21:18 +02:00
multi: skip range check in pathfinder and switch for custom htlc payments
This commit is contained in:
@@ -24,9 +24,9 @@ type bandwidthHints interface {
|
||||
availableChanBandwidth(channelID uint64,
|
||||
amount lnwire.MilliSatoshi) (lnwire.MilliSatoshi, bool)
|
||||
|
||||
// firstHopCustomBlob returns the custom blob for the first hop of the
|
||||
// payment, if available.
|
||||
firstHopCustomBlob() fn.Option[tlv.Blob]
|
||||
// isCustomHTLCPayment returns true if this payment is a custom payment.
|
||||
// For custom payments policy checks might not be needed.
|
||||
isCustomHTLCPayment() bool
|
||||
}
|
||||
|
||||
// getLinkQuery is the function signature used to lookup a link.
|
||||
@@ -205,8 +205,27 @@ func (b *bandwidthManager) availableChanBandwidth(channelID uint64,
|
||||
return bandwidth, true
|
||||
}
|
||||
|
||||
// firstHopCustomBlob returns the custom blob for the first hop of the payment,
|
||||
// if available.
|
||||
func (b *bandwidthManager) firstHopCustomBlob() fn.Option[tlv.Blob] {
|
||||
return b.firstHopBlob
|
||||
// isCustomHTLCPayment returns true if this payment is a custom payment.
|
||||
// For custom payments policy checks might not be needed.
|
||||
func (b *bandwidthManager) isCustomHTLCPayment() bool {
|
||||
var isCustomHTLCPayment bool
|
||||
|
||||
b.firstHopBlob.WhenSome(func(blob tlv.Blob) {
|
||||
customRecords, err := lnwire.ParseCustomRecords(blob)
|
||||
if err != nil {
|
||||
log.Warnf("failed to parse custom records when "+
|
||||
"checking if payment is custom: %v", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
isCustomHTLCPayment = fn.MapOptionZ(
|
||||
b.trafficShaper,
|
||||
func(s htlcswitch.AuxTrafficShaper) bool {
|
||||
return s.IsCustomHTLC(customRecords)
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
return isCustomHTLCPayment
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/lightningnetwork/lnd/kvdb"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -36,8 +35,8 @@ func (m *mockBandwidthHints) availableChanBandwidth(channelID uint64,
|
||||
return balance, ok
|
||||
}
|
||||
|
||||
func (m *mockBandwidthHints) firstHopCustomBlob() fn.Option[tlv.Blob] {
|
||||
return fn.None[tlv.Blob]()
|
||||
func (m *mockBandwidthHints) isCustomHTLCPayment() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// integratedRoutingContext defines the context in which integrated routing
|
||||
|
@@ -251,12 +251,13 @@ func (u *edgeUnifier) getEdgeLocal(netAmtReceived lnwire.MilliSatoshi,
|
||||
// Add inbound fee to get to the amount that is sent over the
|
||||
// local channel.
|
||||
amt := netAmtReceived + lnwire.MilliSatoshi(inboundFee)
|
||||
|
||||
// Check valid amount range for the channel. We skip this test
|
||||
// for payments with custom HTLC data, as the amount sent on
|
||||
// the BTC layer may differ from the amount that is actually
|
||||
// forwarded in custom channels.
|
||||
if bandwidthHints.firstHopCustomBlob().IsNone() &&
|
||||
|
||||
// for payments with custom htlc data we skip the amount range
|
||||
// check because the amt of the payment does not relate to the
|
||||
// actual amount carried by the HTLC but instead in encoded in
|
||||
// the blob data.
|
||||
if !bandwidthHints.isCustomHTLCPayment() &&
|
||||
!edge.amtInRange(amt) {
|
||||
|
||||
log.Debugf("Amount %v not in range for edge %v",
|
||||
|
Reference in New Issue
Block a user