Skip to content

Commit b8489a1

Browse files
committed
lncli: add queryicm
`queryicm` queries the internal state of the imputed cost manager.
1 parent 75d01e4 commit b8489a1

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

cmd/commands/cmd_imputed_cost.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package commands
2+
3+
import (
4+
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
5+
"github.com/urfave/cli"
6+
)
7+
8+
var queryImputedCostManagerCommand = cli.Command{
9+
Name: "queryicm",
10+
Category: "Imputed Costs", // TODO: subcommand for imputed costs?
11+
Usage: "Query the internal state of the imputed cost manager.",
12+
Description: `
13+
Query the internal state of the imputed cost manager.
14+
`,
15+
Flags: []cli.Flag{
16+
cli.StringSliceFlag{
17+
Name: "namespace",
18+
Usage: "(optional) name of the namespace. This flag " +
19+
"can be specified multiple times in the same " +
20+
"command.",
21+
},
22+
},
23+
Action: actionDecorator(queryImputedCostManager),
24+
}
25+
26+
func queryImputedCostManager(ctx *cli.Context) error {
27+
ctxc := getContext()
28+
conn := getClientConn(ctx, false)
29+
defer conn.Close()
30+
31+
client := routerrpc.NewRouterClient(conn)
32+
33+
req := &routerrpc.QueryImputedCostsRequest{}
34+
namespaces := ctx.StringSlice("namespace")
35+
if len(namespaces) > 0 {
36+
req.Namespaces = namespaces
37+
}
38+
39+
snapshot, err := client.XQueryImputedCosts(ctxc, req)
40+
if err != nil {
41+
return err
42+
}
43+
44+
printRespJSON(snapshot)
45+
46+
return nil
47+
}

cmd/commands/routerrpc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ func routerCommands() []cli.Command {
1414
getCfgCommand,
1515
setCfgCommand,
1616
updateChanStatusCommand,
17+
queryImputedCostManagerCommand,
1718
}
1819
}

0 commit comments

Comments
 (0)