-
Notifications
You must be signed in to change notification settings - Fork 2.3k
routing: Support Pathfinding to Blinded Routes #7267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
796f9a7
ac67879
b4570e0
927c941
e072895
7fa20c3
38fa4ff
2766922
a7109d8
0ddb1c2
600efc0
2a02be0
eb72400
9cc293b
e334fc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,6 +99,47 @@ var ( | |
| Name: "time_pref", | ||
| Usage: "(optional) expresses time preference (range -1 to 1)", | ||
| } | ||
|
|
||
| introductionNodeFlag = cli.StringFlag{ | ||
carlaKC marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Name: "introduction_node", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| Usage: "(blinded paths) the hex encoded, cleartext node ID " + | ||
| "of the node to use for queries to a blinded route", | ||
| } | ||
|
|
||
| blindingPointFlag = cli.StringFlag{ | ||
| Name: "blinding_point", | ||
| Usage: "(blinded paths) the hex encoded blinding point to " + | ||
| "use if querying a route to a blinded path, this " + | ||
| "value *must* be set for queries to a blinded path", | ||
| } | ||
|
|
||
| blindedHopsFlag = cli.StringSliceFlag{ | ||
| Name: "blinded_hops", | ||
| Usage: "(blinded paths) the blinded hops to include in the " + | ||
| "query, formatted as <blinded_node_id>:" + | ||
| "<hex_encrypted_data>. These hops must be provided " + | ||
| "*in order* starting with the introduction point and " + | ||
| "ending with the receiving node", | ||
| } | ||
|
|
||
| blindedBaseFlag = cli.Uint64Flag{ | ||
| Name: "blinded_base_fee", | ||
| Usage: "(blinded paths) the aggregate base fee for the " + | ||
| "blinded portion of the route, expressed in msat", | ||
| } | ||
|
|
||
| blindedPPMFlag = cli.Uint64Flag{ | ||
| Name: "blinded_ppm_fee", | ||
| Usage: "(blinded paths) the aggregate proportional fee for " + | ||
| "the blinded portion of the route, expressed in " + | ||
| "parts per million", | ||
| } | ||
|
|
||
| blindedCLTVFlag = cli.Uint64Flag{ | ||
| Name: "blinded_cltv", | ||
| Usage: "(blinded paths) the total cltv delay for the " + | ||
| "blinded portion of the route", | ||
| } | ||
| ) | ||
|
|
||
| // paymentFlags returns common flags for sendpayment and payinvoice. | ||
|
|
@@ -1056,6 +1097,12 @@ var queryRoutesCommand = cli.Command{ | |
| }, | ||
| timePrefFlag, | ||
| cltvLimitFlag, | ||
| introductionNodeFlag, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about creating a new cli, sth like |
||
| blindingPointFlag, | ||
| blindedHopsFlag, | ||
| blindedBaseFlag, | ||
| blindedPPMFlag, | ||
| blindedCLTVFlag, | ||
| }, | ||
| Action: actionDecorator(queryRoutes), | ||
| } | ||
|
|
@@ -1076,9 +1123,15 @@ func queryRoutes(ctx *cli.Context) error { | |
| switch { | ||
| case ctx.IsSet("dest"): | ||
| dest = ctx.String("dest") | ||
|
|
||
| case args.Present(): | ||
| dest = args.First() | ||
| args = args.Tail() | ||
|
|
||
| // If we have a blinded path set, we don't have to specify a | ||
| // destination. | ||
| case ctx.IsSet(introductionNodeFlag.Name): | ||
|
|
||
| default: | ||
| return fmt.Errorf("dest argument missing") | ||
| } | ||
|
|
@@ -1125,16 +1178,22 @@ func queryRoutes(ctx *cli.Context) error { | |
| } | ||
| } | ||
|
|
||
| blindedRoutes, err := parseBlindedPaymentParameters(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| req := &lnrpc.QueryRoutesRequest{ | ||
| PubKey: dest, | ||
| Amt: amt, | ||
| FeeLimit: feeLimit, | ||
| FinalCltvDelta: int32(ctx.Int("final_cltv_delta")), | ||
| UseMissionControl: ctx.Bool("use_mc"), | ||
| CltvLimit: uint32(ctx.Uint64(cltvLimitFlag.Name)), | ||
| OutgoingChanId: ctx.Uint64("outgoing_chan_id"), | ||
| TimePref: ctx.Float64(timePrefFlag.Name), | ||
| IgnoredPairs: ignoredPairs, | ||
| PubKey: dest, | ||
| Amt: amt, | ||
| FeeLimit: feeLimit, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we check this is not set for blinded routes?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic should apply as before for blinded paths?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly this feelimit still needs to be in place for blinded routes as well. |
||
| FinalCltvDelta: int32(ctx.Int("final_cltv_delta")), | ||
| UseMissionControl: ctx.Bool("use_mc"), | ||
| CltvLimit: uint32(ctx.Uint64(cltvLimitFlag.Name)), | ||
| OutgoingChanId: ctx.Uint64("outgoing_chan_id"), | ||
| TimePref: ctx.Float64(timePrefFlag.Name), | ||
| IgnoredPairs: ignoredPairs, | ||
| BlindedPaymentPaths: blindedRoutes, | ||
| } | ||
|
|
||
| route, err := client.QueryRoutes(ctxc, req) | ||
|
|
@@ -1146,6 +1205,82 @@ func queryRoutes(ctx *cli.Context) error { | |
| return nil | ||
| } | ||
|
|
||
| func parseBlindedPaymentParameters(ctx *cli.Context) ( | ||
| []*lnrpc.BlindedPaymentPath, error) { | ||
|
|
||
| // Return nil if we don't have a blinding set, as we don't have a | ||
| // blinded path. | ||
| if !ctx.IsSet(blindingPointFlag.Name) { | ||
| return nil, nil | ||
| } | ||
|
|
||
| // If any one of our blinding related flags is set, we expect the | ||
| // full set to be set and we'll error out accordingly. | ||
| introNode, err := route.NewVertexFromStr( | ||
| ctx.String(introductionNodeFlag.Name), | ||
| ) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("decode introduction node: %w", err) | ||
| } | ||
|
|
||
| blindingPoint, err := route.NewVertexFromStr(ctx.String( | ||
| blindingPointFlag.Name, | ||
| )) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("decode blinding point: %w", err) | ||
| } | ||
|
|
||
| blindedHops := ctx.StringSlice(blindedHopsFlag.Name) | ||
|
|
||
| pmt := &lnrpc.BlindedPaymentPath{ | ||
| BlindedPath: &lnrpc.BlindedPath{ | ||
| IntroductionNode: introNode[:], | ||
| BlindingPoint: blindingPoint[:], | ||
| BlindedHops: make( | ||
| []*lnrpc.BlindedHop, len(blindedHops), | ||
| ), | ||
| }, | ||
| BaseFeeMsat: ctx.Uint64( | ||
| blindedBaseFlag.Name, | ||
| ), | ||
| ProportionalFeeMsat: ctx.Uint64( | ||
| blindedPPMFlag.Name, | ||
| ), | ||
| TotalCltvDelta: uint32(ctx.Uint64( | ||
| blindedCLTVFlag.Name, | ||
| )), | ||
| } | ||
|
|
||
| for i, hop := range blindedHops { | ||
| parts := strings.Split(hop, ":") | ||
| if len(parts) != 2 { | ||
| return nil, fmt.Errorf("blinded hops should be "+ | ||
| "expressed as "+ | ||
| "blinded_node_id:hex_encrypted_data, got: %v", | ||
| hop) | ||
| } | ||
|
|
||
| hop, err := route.NewVertexFromStr(parts[0]) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("hop: %v node: %w", i, err) | ||
| } | ||
|
|
||
| data, err := hex.DecodeString(parts[1]) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("hop: %v data: %w", i, err) | ||
| } | ||
|
|
||
| pmt.BlindedPath.BlindedHops[i] = &lnrpc.BlindedHop{ | ||
| BlindedNode: hop[:], | ||
| EncryptedData: data, | ||
| } | ||
| } | ||
|
|
||
| return []*lnrpc.BlindedPaymentPath{ | ||
| pmt, | ||
| }, nil | ||
| } | ||
|
|
||
| // retrieveFeeLimitLegacy retrieves the fee limit based on the different fee | ||
| // limit flags passed. This function will eventually disappear in favor of | ||
| // retrieveFeeLimit and the new payment rpc. | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.