Skip to content

Commit

Permalink
lncli: add querymc command
Browse files Browse the repository at this point in the history
Adds querymc command to lncli to dump mission control state.
  • Loading branch information
joostjager committed May 10, 2019
1 parent 5b53df0 commit ae2bdfd
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/lncli/cmd_query_mission_control.go
@@ -0,0 +1,35 @@
// +build routerrpc

package main

import (
"context"

"github.com/lightningnetwork/lnd/lnrpc/routerrpc"

"github.com/urfave/cli"
)

var queryMissionControlCommand = cli.Command{
Name: "querymc",
Category: "Payments",
Action: actionDecorator(queryMissionControl),
}

func queryMissionControl(ctx *cli.Context) error {
conn := getClientConn(ctx, false)
defer conn.Close()

client := routerrpc.NewRouterClient(conn)

req := &routerrpc.QueryMissionControlRequest{}
rpcCtx := context.Background()
snapshot, err := client.QueryMissionControl(rpcCtx, req)
if err != nil {
return err
}

printRespJSON(snapshot)

return nil
}
1 change: 1 addition & 0 deletions cmd/lncli/main.go
Expand Up @@ -303,6 +303,7 @@ func main() {
// Add any extra autopilot commands determined by build flags.
app.Commands = append(app.Commands, autopilotCommands()...)
app.Commands = append(app.Commands, invoicesCommands()...)
app.Commands = append(app.Commands, routerCommands()...)

if err := app.Run(os.Args); err != nil {
fatal(err)
Expand Down
10 changes: 10 additions & 0 deletions cmd/lncli/routerrpc_active.go
@@ -0,0 +1,10 @@
// +build routerrpc

package main

import "github.com/urfave/cli"

// routerCommands will return nil for non-routerrpc builds.
func routerCommands() []cli.Command {
return []cli.Command{queryMissionControlCommand}
}
10 changes: 10 additions & 0 deletions cmd/lncli/routerrpc_default.go
@@ -0,0 +1,10 @@
// +build !routerrpc

package main

import "github.com/urfave/cli"

// routerCommands will return nil for non-routerrpc builds.
func routerCommands() []cli.Command {
return nil
}

0 comments on commit ae2bdfd

Please sign in to comment.