mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 23:21:12 +02:00
Merge pull request #9721 from appilon/appilon/6601
feat(lncli): Add --route_hints flag to sendpayment and queryroutes
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -254,6 +255,15 @@ var SendPaymentCommand = cli.Command{
|
|||||||
Name: "keysend",
|
Name: "keysend",
|
||||||
Usage: "will generate a pre-image and encode it in the sphinx packet, a dest must be set [experimental]",
|
Usage: "will generate a pre-image and encode it in the sphinx packet, a dest must be set [experimental]",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "route_hints",
|
||||||
|
Usage: `route hints for sending through private ` +
|
||||||
|
`channels. eg: ` +
|
||||||
|
`'[{"hop_hints":[{"node_id":"A","chan_id":1,` +
|
||||||
|
`"fee_base_msat":2,` +
|
||||||
|
`"fee_proportional_millionths":3,` +
|
||||||
|
`"cltv_expiry_delta":4}]}]'`,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
Action: SendPayment,
|
Action: SendPayment,
|
||||||
}
|
}
|
||||||
@@ -473,6 +483,20 @@ func SendPayment(ctx *cli.Context) error {
|
|||||||
|
|
||||||
req.PaymentAddr = payAddr
|
req.PaymentAddr = payAddr
|
||||||
|
|
||||||
|
if ctx.IsSet("route_hints") {
|
||||||
|
// Parse the route hints JSON.
|
||||||
|
routeHintsJSON := ctx.String("route_hints")
|
||||||
|
var routeHints []*lnrpc.RouteHint
|
||||||
|
|
||||||
|
err := json.Unmarshal([]byte(routeHintsJSON), &routeHints)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error unmarshaling route_hints "+
|
||||||
|
"json: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req.RouteHints = routeHints
|
||||||
|
}
|
||||||
|
|
||||||
return SendPaymentRequest(ctx, req, conn, conn, routerRPCSendPayment)
|
return SendPaymentRequest(ctx, req, conn, conn, routerRPCSendPayment)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,6 +1178,15 @@ var queryRoutesCommand = cli.Command{
|
|||||||
blindedBaseFlag,
|
blindedBaseFlag,
|
||||||
blindedPPMFlag,
|
blindedPPMFlag,
|
||||||
blindedCLTVFlag,
|
blindedCLTVFlag,
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "route_hints",
|
||||||
|
Usage: `route hints for searching through private ` +
|
||||||
|
`channels (and no blinded paths set). eg: ` +
|
||||||
|
`'[{"hop_hints":[{"node_id":"A","chan_id":1,` +
|
||||||
|
`"fee_base_msat":2,` +
|
||||||
|
`"fee_proportional_millionths":3,` +
|
||||||
|
`"cltv_expiry_delta":4}]}]'`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: actionDecorator(queryRoutes),
|
Action: actionDecorator(queryRoutes),
|
||||||
}
|
}
|
||||||
@@ -1248,6 +1281,23 @@ func queryRoutes(ctx *cli.Context) error {
|
|||||||
BlindedPaymentPaths: blindedRoutes,
|
BlindedPaymentPaths: blindedRoutes,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.IsSet("route_hints") {
|
||||||
|
if len(blindedRoutes) > 0 {
|
||||||
|
return fmt.Errorf("--route_hints should not be used " +
|
||||||
|
"if blinded paths are set")
|
||||||
|
}
|
||||||
|
routeHintsJSON := ctx.String("route_hints")
|
||||||
|
var routeHints []*lnrpc.RouteHint
|
||||||
|
|
||||||
|
err := json.Unmarshal([]byte(routeHintsJSON), &routeHints)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("error unmarshaling route_hints "+
|
||||||
|
"json: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
req.RouteHints = routeHints
|
||||||
|
}
|
||||||
|
|
||||||
route, err := client.QueryRoutes(ctxc, req)
|
route, err := client.QueryRoutes(ctxc, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
## lncli Additions
|
## lncli Additions
|
||||||
|
|
||||||
|
* [`lncli sendpayment` and `lncli queryroutes` now support the
|
||||||
|
`--route_hints` flag](https://github.com/lightningnetwork/lnd/pull/9721) to
|
||||||
|
support routing through private channels.
|
||||||
|
|
||||||
# Improvements
|
# Improvements
|
||||||
## Functional Updates
|
## Functional Updates
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user