@@ -280,7 +280,7 @@ func (r *RouterBackend) parseQueryRoutesRequest(in *lnrpc.QueryRoutesRequest) (
280280 var (
281281 targetPubKey * route.Vertex
282282 routeHintEdges map [route.Vertex ][]routing.AdditionalEdge
283- blindedPmt * routing.BlindedPayment
283+ blindedPathSet * routing.BlindedPaymentPathSet
284284
285285 // finalCLTVDelta varies depending on whether we're sending to
286286 // a blinded route or an unblinded node. For blinded paths,
@@ -297,13 +297,14 @@ func (r *RouterBackend) parseQueryRoutesRequest(in *lnrpc.QueryRoutesRequest) (
297297 // Validate that the fields provided in the request are sane depending
298298 // on whether it is using a blinded path or not.
299299 if len (in .BlindedPaymentPaths ) > 0 {
300- blindedPmt , err = parseBlindedPayment (in )
300+ blindedPathSet , err = parseBlindedPaymentPaths (in )
301301 if err != nil {
302302 return nil , err
303303 }
304304
305- if blindedPmt .Features != nil {
306- destinationFeatures = blindedPmt .Features .Clone ()
305+ pathFeatures := blindedPathSet .Features ()
306+ if pathFeatures != nil {
307+ destinationFeatures = pathFeatures .Clone ()
307308 }
308309 } else {
309310 // If we do not have a blinded path, a target pubkey must be
@@ -387,10 +388,10 @@ func (r *RouterBackend) parseQueryRoutesRequest(in *lnrpc.QueryRoutesRequest) (
387388 fromNode , toNode , amt , capacity ,
388389 )
389390 },
390- DestCustomRecords : record .CustomSet (in .DestCustomRecords ),
391- CltvLimit : cltvLimit ,
392- DestFeatures : destinationFeatures ,
393- BlindedPayment : blindedPmt ,
391+ DestCustomRecords : record .CustomSet (in .DestCustomRecords ),
392+ CltvLimit : cltvLimit ,
393+ DestFeatures : destinationFeatures ,
394+ BlindedPaymentPathSet : blindedPathSet ,
394395 }
395396
396397 // Pass along an outgoing channel restriction if specified.
@@ -419,39 +420,24 @@ func (r *RouterBackend) parseQueryRoutesRequest(in *lnrpc.QueryRoutesRequest) (
419420
420421 return routing .NewRouteRequest (
421422 sourcePubKey , targetPubKey , amt , in .TimePref , restrictions ,
422- customRecords , routeHintEdges , blindedPmt , finalCLTVDelta ,
423+ customRecords , routeHintEdges , blindedPathSet ,
424+ finalCLTVDelta ,
423425 )
424426}
425427
426- func parseBlindedPayment (in * lnrpc.QueryRoutesRequest ) (
427- * routing.BlindedPayment , error ) {
428+ func parseBlindedPaymentPaths (in * lnrpc.QueryRoutesRequest ) (
429+ * routing.BlindedPaymentPathSet , error ) {
428430
429431 if len (in .PubKey ) != 0 {
430432 return nil , fmt .Errorf ("target pubkey: %x should not be set " +
431433 "when blinded path is provided" , in .PubKey )
432434 }
433435
434- if len (in .BlindedPaymentPaths ) != 1 {
435- return nil , errors .New ("query routes only supports a single " +
436- "blinded path" )
437- }
438-
439- blindedPath := in .BlindedPaymentPaths [0 ]
440-
441436 if len (in .RouteHints ) > 0 {
442437 return nil , errors .New ("route hints and blinded path can't " +
443438 "both be set" )
444439 }
445440
446- blindedPmt , err := unmarshalBlindedPayment (blindedPath )
447- if err != nil {
448- return nil , fmt .Errorf ("parse blinded payment: %w" , err )
449- }
450-
451- if err := blindedPmt .Validate (); err != nil {
452- return nil , fmt .Errorf ("invalid blinded path: %w" , err )
453- }
454-
455441 if in .FinalCltvDelta != 0 {
456442 return nil , errors .New ("final cltv delta should be " +
457443 "zero for blinded paths" )
@@ -466,7 +452,21 @@ func parseBlindedPayment(in *lnrpc.QueryRoutesRequest) (
466452 "be populated in blinded path" )
467453 }
468454
469- return blindedPmt , nil
455+ paths := make ([]* routing.BlindedPayment , len (in .BlindedPaymentPaths ))
456+ for i , paymentPath := range in .BlindedPaymentPaths {
457+ blindedPmt , err := unmarshalBlindedPayment (paymentPath )
458+ if err != nil {
459+ return nil , fmt .Errorf ("parse blinded payment: %w" , err )
460+ }
461+
462+ if err := blindedPmt .Validate (); err != nil {
463+ return nil , fmt .Errorf ("invalid blinded path: %w" , err )
464+ }
465+
466+ paths [i ] = blindedPmt
467+ }
468+
469+ return routing .NewBlindedPaymentPathSet (paths )
470470}
471471
472472func unmarshalBlindedPayment (rpcPayment * lnrpc.BlindedPaymentPath ) (
@@ -1001,28 +1001,24 @@ func (r *RouterBackend) extractIntentFromSendRequest(
10011001 payIntent .Metadata = payReq .Metadata
10021002
10031003 if len (payReq .BlindedPaymentPaths ) > 0 {
1004- // NOTE: Currently we only choose a single payment path.
1005- // This will be updated in a future PR to handle
1006- // multiple blinded payment paths.
1007- path := payReq .BlindedPaymentPaths [0 ]
1008- if len (path .Hops ) == 0 {
1009- return nil , fmt .Errorf ("a blinded payment " +
1010- "must have at least 1 hop" )
1004+ pathSet , err := BuildBlindedPathSet (
1005+ payReq .BlindedPaymentPaths ,
1006+ )
1007+ if err != nil {
1008+ return nil , err
10111009 }
1010+ payIntent .BlindedPathSet = pathSet
10121011
1013- finalHop := path .Hops [len (path .Hops )- 1 ]
1014-
1015- payIntent .BlindedPayment = MarshalBlindedPayment (path )
1016-
1017- // Replace the target node with the blinded public key
1018- // of the blinded path's final node.
1012+ // Replace the target node with the target public key
1013+ // of the blinded path set.
10191014 copy (
10201015 payIntent .Target [:],
1021- finalHop . BlindedNodePub .SerializeCompressed (),
1016+ pathSet . TargetPubKey () .SerializeCompressed (),
10221017 )
10231018
1024- if ! path .Features .IsEmpty () {
1025- payIntent .DestFeatures = path .Features .Clone ()
1019+ pathFeatures := pathSet .Features ()
1020+ if ! pathFeatures .IsEmpty () {
1021+ payIntent .DestFeatures = pathFeatures .Clone ()
10261022 }
10271023 }
10281024 } else {
@@ -1163,9 +1159,29 @@ func (r *RouterBackend) extractIntentFromSendRequest(
11631159 return payIntent , nil
11641160}
11651161
1166- // MarshalBlindedPayment marshals a zpay32.BLindedPaymentPath into a
1162+ // BuildBlindedPathSet marshals a set of zpay32.BlindedPaymentPath and uses
1163+ // the result to build a new routing.BlindedPaymentPathSet.
1164+ func BuildBlindedPathSet (paths []* zpay32.BlindedPaymentPath ) (
1165+ * routing.BlindedPaymentPathSet , error ) {
1166+
1167+ marshalledPaths := make ([]* routing.BlindedPayment , len (paths ))
1168+ for i , path := range paths {
1169+ paymentPath := marshalBlindedPayment (path )
1170+
1171+ err := paymentPath .Validate ()
1172+ if err != nil {
1173+ return nil , err
1174+ }
1175+
1176+ marshalledPaths [i ] = paymentPath
1177+ }
1178+
1179+ return routing .NewBlindedPaymentPathSet (marshalledPaths )
1180+ }
1181+
1182+ // marshalBlindedPayment marshals a zpay32.BLindedPaymentPath into a
11671183// routing.BlindedPayment.
1168- func MarshalBlindedPayment (
1184+ func marshalBlindedPayment (
11691185 path * zpay32.BlindedPaymentPath ) * routing.BlindedPayment {
11701186
11711187 return & routing.BlindedPayment {
0 commit comments