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:
Elle Mouton committed 2024-07-26 09:54:37 +02:00
1 parent 34d8fff5f9
commit 735d7d9738
4 files changed
+104 -2

No files matched your search

+28
View File
@@ -5110,6 +5110,7 @@ type rpcPaymentIntent struct {
paymentAddr *[32]byte
payReq []byte
metadata []byte
blindedPayment *routing.BlindedPayment
destCustomRecords record.CustomSet
@@ -5245,6 +5246,32 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
payIntent.paymentAddr = payReq.PaymentAddr
payIntent.metadata = payReq.Metadata
if len(payReq.BlindedPaymentPaths) > 0 {
// NOTE: Currently we only choose a single payment path.
// This will be updated in a future PR to handle
// multiple blinded payment paths.
path := payReq.BlindedPaymentPaths[0]
if len(path.Hops) == 0 {
return payIntent, fmt.Errorf("a blinded " +
"payment must have at least 1 hop")
}
finalHop := path.Hops[len(path.Hops)-1]
payIntent.blindedPayment =
routerrpc.MarshalBlindedPayment(path)
// Replace the target node with the blinded public key
// of the blinded path's final node.
copy(
payIntent.dest[:],
finalHop.BlindedNodePub.SerializeCompressed(),
)
if !payReq.BlindedPaymentPaths[0].Features.IsEmpty() {
payIntent.destFeatures = path.Features.Clone()
}
}
if err := validateDest(payIntent.dest); err != nil {
return payIntent, err
}
@@ -5399,6 +5426,7 @@ func (r *rpcServer) dispatchPaymentIntent(
DestFeatures: payIntent.destFeatures,
PaymentAddr: payIntent.paymentAddr,
Metadata: payIntent.metadata,
BlindedPayment: payIntent.blindedPayment,
// Don't enable multi-part payments on the main rpc.
// Users need to use routerrpc for that.