diff --git a/cmd/lncli/cmd_payments.go b/cmd/lncli/cmd_payments.go index 7cfa9f656..e676784dc 100644 --- a/cmd/lncli/cmd_payments.go +++ b/cmd/lncli/cmd_payments.go @@ -1028,6 +1028,13 @@ var queryRoutesCommand = cli.Command{ Usage: "(optional) the channel id of the channel " + "that must be taken to the first hop", }, + cli.StringSliceFlag{ + Name: "ignore_pair", + Usage: "ignore directional node pair " + + ":. This flag can be specified " + + "multiple times if multiple node pairs are " + + "to be ignored", + }, timePrefFlag, cltvLimitFlag, }, @@ -1074,6 +1081,31 @@ func queryRoutes(ctx *cli.Context) error { return err } + pairs := ctx.StringSlice("ignore_pair") + ignoredPairs := make([]*lnrpc.NodePair, len(pairs)) + for i, pair := range pairs { + nodes := strings.Split(pair, ":") + if len(nodes) != 2 { + return fmt.Errorf("invalid node pair format. " + + "Expected :") + } + + node1, err := hex.DecodeString(nodes[0]) + if err != nil { + return err + } + + node2, err := hex.DecodeString(nodes[1]) + if err != nil { + return err + } + + ignoredPairs[i] = &lnrpc.NodePair{ + From: node1, + To: node2, + } + } + req := &lnrpc.QueryRoutesRequest{ PubKey: dest, Amt: amt, @@ -1083,6 +1115,7 @@ func queryRoutes(ctx *cli.Context) error { CltvLimit: uint32(ctx.Uint64(cltvLimitFlag.Name)), OutgoingChanId: ctx.Uint64("outgoing_chanid"), TimePref: ctx.Float64(timePrefFlag.Name), + IgnoredPairs: ignoredPairs, } route, err := client.QueryRoutes(ctxc, req) diff --git a/docs/release-notes/release-notes-0.15.1.md b/docs/release-notes/release-notes-0.15.1.md index 29b52df85..8e9b655a7 100644 --- a/docs/release-notes/release-notes-0.15.1.md +++ b/docs/release-notes/release-notes-0.15.1.md @@ -25,6 +25,11 @@ `updatechanstatus`](https://github.com/lightningnetwork/lnd/pull/6705) to offer a convenient way to specify the channel to be updated. +* [Add `ignore_pair` flag to + queryroutes](https://github.com/lightningnetwork/lnd/pull/6724) to allow a + user to request that specific directional node pairs be ignored during the + route search. + ## Database * [Delete failed payment attempts](https://github.com/lightningnetwork/lnd/pull/6438)