Skip to content

Commit b1b3c64

Browse files
authored
Merge pull request #9721 from appilon/appilon/6601
feat(lncli): Add --route_hints flag to sendpayment and queryroutes
2 parents 5c324c7 + 0437850 commit b1b3c64

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

cmd/commands/cmd_payments.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"crypto/rand"
77
"encoding/hex"
8+
"encoding/json"
89
"errors"
910
"fmt"
1011
"io"
@@ -254,6 +255,15 @@ var SendPaymentCommand = cli.Command{
254255
Name: "keysend",
255256
Usage: "will generate a pre-image and encode it in the sphinx packet, a dest must be set [experimental]",
256257
},
258+
cli.StringFlag{
259+
Name: "route_hints",
260+
Usage: `route hints for sending through private ` +
261+
`channels. eg: ` +
262+
`'[{"hop_hints":[{"node_id":"A","chan_id":1,` +
263+
`"fee_base_msat":2,` +
264+
`"fee_proportional_millionths":3,` +
265+
`"cltv_expiry_delta":4}]}]'`,
266+
},
257267
),
258268
Action: SendPayment,
259269
}
@@ -473,6 +483,20 @@ func SendPayment(ctx *cli.Context) error {
473483

474484
req.PaymentAddr = payAddr
475485

486+
if ctx.IsSet("route_hints") {
487+
// Parse the route hints JSON.
488+
routeHintsJSON := ctx.String("route_hints")
489+
var routeHints []*lnrpc.RouteHint
490+
491+
err := json.Unmarshal([]byte(routeHintsJSON), &routeHints)
492+
if err != nil {
493+
return fmt.Errorf("error unmarshaling route_hints "+
494+
"json: %w", err)
495+
}
496+
497+
req.RouteHints = routeHints
498+
}
499+
476500
return SendPaymentRequest(ctx, req, conn, conn, routerRPCSendPayment)
477501
}
478502

@@ -1154,6 +1178,15 @@ var queryRoutesCommand = cli.Command{
11541178
blindedBaseFlag,
11551179
blindedPPMFlag,
11561180
blindedCLTVFlag,
1181+
cli.StringFlag{
1182+
Name: "route_hints",
1183+
Usage: `route hints for searching through private ` +
1184+
`channels (and no blinded paths set). eg: ` +
1185+
`'[{"hop_hints":[{"node_id":"A","chan_id":1,` +
1186+
`"fee_base_msat":2,` +
1187+
`"fee_proportional_millionths":3,` +
1188+
`"cltv_expiry_delta":4}]}]'`,
1189+
},
11571190
},
11581191
Action: actionDecorator(queryRoutes),
11591192
}
@@ -1248,6 +1281,23 @@ func queryRoutes(ctx *cli.Context) error {
12481281
BlindedPaymentPaths: blindedRoutes,
12491282
}
12501283

1284+
if ctx.IsSet("route_hints") {
1285+
if len(blindedRoutes) > 0 {
1286+
return fmt.Errorf("--route_hints should not be used " +
1287+
"if blinded paths are set")
1288+
}
1289+
routeHintsJSON := ctx.String("route_hints")
1290+
var routeHints []*lnrpc.RouteHint
1291+
1292+
err := json.Unmarshal([]byte(routeHintsJSON), &routeHints)
1293+
if err != nil {
1294+
return fmt.Errorf("error unmarshaling route_hints "+
1295+
"json: %w", err)
1296+
}
1297+
1298+
req.RouteHints = routeHints
1299+
}
1300+
12511301
route, err := client.QueryRoutes(ctxc, req)
12521302
if err != nil {
12531303
return err

docs/release-notes/release-notes-0.20.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828

2929
## lncli Additions
3030

31+
* [`lncli sendpayment` and `lncli queryroutes` now support the
32+
`--route_hints` flag](https://github.com/lightningnetwork/lnd/pull/9721) to
33+
support routing through private channels.
34+
3135
# Improvements
3236
## Functional Updates
3337

0 commit comments

Comments
 (0)