|
5 | 5 | "context"
|
6 | 6 | "crypto/rand"
|
7 | 7 | "encoding/hex"
|
| 8 | + "encoding/json" |
8 | 9 | "errors"
|
9 | 10 | "fmt"
|
10 | 11 | "io"
|
@@ -254,6 +255,13 @@ var SendPaymentCommand = cli.Command{
|
254 | 255 | Name: "keysend",
|
255 | 256 | Usage: "will generate a pre-image and encode it in the sphinx packet, a dest must be set [experimental]",
|
256 | 257 | },
|
| 258 | + cli.StringFlag{ |
| 259 | + Name: "route_hints", |
| 260 | + Usage: "route hints to reach the destination, " + |
| 261 | + "encoded as a JSON string. " + |
| 262 | + "See the RouteHint struct in the RPC " + |
| 263 | + "definition for the full format.", |
| 264 | + }, |
257 | 265 | ),
|
258 | 266 | Action: SendPayment,
|
259 | 267 | }
|
@@ -362,6 +370,19 @@ func SendPayment(ctx *cli.Context) error {
|
362 | 370 |
|
363 | 371 | req.PaymentAddr = payAddr
|
364 | 372 |
|
| 373 | + if ctx.IsSet("route_hints") { |
| 374 | + routeHintsJSON := ctx.String("route_hints") |
| 375 | + var routeHints []*lnrpc.RouteHint |
| 376 | + |
| 377 | + err := json.Unmarshal([]byte(routeHintsJSON), &routeHints) |
| 378 | + if err != nil { |
| 379 | + return fmt.Errorf("error unmarshaling route_hints "+ |
| 380 | + "json: %w", err) |
| 381 | + } |
| 382 | + |
| 383 | + req.RouteHints = routeHints |
| 384 | + } |
| 385 | + |
365 | 386 | return SendPaymentRequest(
|
366 | 387 | ctx, req, conn, conn, routerRPCSendPayment,
|
367 | 388 | )
|
@@ -473,6 +494,19 @@ func SendPayment(ctx *cli.Context) error {
|
473 | 494 |
|
474 | 495 | req.PaymentAddr = payAddr
|
475 | 496 |
|
| 497 | + if ctx.IsSet("route_hints") { |
| 498 | + routeHintsJSON := ctx.String("route_hints") |
| 499 | + var routeHints []*lnrpc.RouteHint |
| 500 | + |
| 501 | + err := json.Unmarshal([]byte(routeHintsJSON), &routeHints) |
| 502 | + if err != nil { |
| 503 | + return fmt.Errorf("error unmarshaling route_hints "+ |
| 504 | + "json: %w", err) |
| 505 | + } |
| 506 | + |
| 507 | + req.RouteHints = routeHints |
| 508 | + } |
| 509 | + |
476 | 510 | return SendPaymentRequest(ctx, req, conn, conn, routerRPCSendPayment)
|
477 | 511 | }
|
478 | 512 |
|
@@ -928,6 +962,19 @@ func payInvoice(ctx *cli.Context) error {
|
928 | 962 | Cancelable: ctx.Bool(cancelableFlag.Name),
|
929 | 963 | }
|
930 | 964 |
|
| 965 | + if ctx.IsSet("route_hints") { |
| 966 | + routeHintsJSON := ctx.String("route_hints") |
| 967 | + var routeHints []*lnrpc.RouteHint |
| 968 | + |
| 969 | + err := json.Unmarshal([]byte(routeHintsJSON), &routeHints) |
| 970 | + if err != nil { |
| 971 | + return fmt.Errorf("error unmarshaling route_hints "+ |
| 972 | + "json: %w", err) |
| 973 | + } |
| 974 | + |
| 975 | + req.RouteHints = routeHints |
| 976 | + } |
| 977 | + |
931 | 978 | return SendPaymentRequest(ctx, req, conn, conn, routerRPCSendPayment)
|
932 | 979 | }
|
933 | 980 |
|
@@ -1154,6 +1201,13 @@ var queryRoutesCommand = cli.Command{
|
1154 | 1201 | blindedBaseFlag,
|
1155 | 1202 | blindedPPMFlag,
|
1156 | 1203 | blindedCLTVFlag,
|
| 1204 | + cli.StringFlag{ |
| 1205 | + Name: "route_hints", |
| 1206 | + Usage: "route hints to reach the destination, " + |
| 1207 | + "encoded as a JSON string. " + |
| 1208 | + "See the RouteHint struct in the RPC " + |
| 1209 | + "definition for the full format.", |
| 1210 | + }, |
1157 | 1211 | },
|
1158 | 1212 | Action: actionDecorator(queryRoutes),
|
1159 | 1213 | }
|
@@ -1248,6 +1302,19 @@ func queryRoutes(ctx *cli.Context) error {
|
1248 | 1302 | BlindedPaymentPaths: blindedRoutes,
|
1249 | 1303 | }
|
1250 | 1304 |
|
| 1305 | + if ctx.IsSet("route_hints") { |
| 1306 | + routeHintsJSON := ctx.String("route_hints") |
| 1307 | + var routeHints []*lnrpc.RouteHint |
| 1308 | + |
| 1309 | + err := json.Unmarshal([]byte(routeHintsJSON), &routeHints) |
| 1310 | + if err != nil { |
| 1311 | + return fmt.Errorf("error unmarshaling route_hints "+ |
| 1312 | + "json: %w", err) |
| 1313 | + } |
| 1314 | + |
| 1315 | + req.RouteHints = routeHints |
| 1316 | + } |
| 1317 | + |
1251 | 1318 | route, err := client.QueryRoutes(ctxc, req)
|
1252 | 1319 | if err != nil {
|
1253 | 1320 | return err
|
|
0 commit comments