mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-12 04:55:43 +02:00
multi: send to a blinded path in an invoice
Update the SendPayment flow so that it is able to send to an invoice containing a blinded path.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btclog"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/channeldb/models"
|
||||
@@ -205,6 +206,18 @@ func newPaymentSession(p *LightningPayment, selfNode route.Vertex,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if p.BlindedPayment != nil {
|
||||
if len(edges) != 0 {
|
||||
return nil, fmt.Errorf("cannot have both route hints " +
|
||||
"and blinded path")
|
||||
}
|
||||
|
||||
edges, err = p.BlindedPayment.toRouteHints()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
logPrefix := fmt.Sprintf("PaymentSession(%x):", p.Identifier())
|
||||
|
||||
return &paymentSession{
|
||||
@@ -389,6 +402,11 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var blindedPath *sphinx.BlindedPath
|
||||
if p.payment.BlindedPayment != nil {
|
||||
blindedPath = p.payment.BlindedPayment.BlindedPath
|
||||
}
|
||||
|
||||
// With the next candidate path found, we'll attempt to turn
|
||||
// this into a route by applying the time-lock and fee
|
||||
// requirements.
|
||||
@@ -401,7 +419,7 @@ func (p *paymentSession) RequestRoute(maxAmt, feeLimit lnwire.MilliSatoshi,
|
||||
records: p.payment.DestCustomRecords,
|
||||
paymentAddr: p.payment.PaymentAddr,
|
||||
metadata: p.payment.Metadata,
|
||||
}, nil,
|
||||
}, blindedPath,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user