mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-28 13:52:55 +02:00
lncli: add ignore_pair flag to queryroutes
This commit is contained in:
@@ -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 " +
|
||||
"<node1>:<node2>. 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 pub key>:<node2 pub key>")
|
||||
}
|
||||
|
||||
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)
|
||||
|
Reference in New Issue
Block a user