lnd.xprv/cmd/lncli/cmd_query_mission_control.go

63 lines
1.3 KiB
Go
Raw Normal View History

// +build routerrpc
package main
import (
"context"
"encoding/hex"
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
"github.com/urfave/cli"
)
var queryMissionControlCommand = cli.Command{
Name: "querymc",
Category: "Payments",
2019-06-19 10:20:58 +03:00
Usage: "Query the internal mission control state.",
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
}
type displayPairHistory struct {
NodeFrom, NodeTo string
LastAttemptSuccessful bool
Timestamp int64
AmtSat, AmtMsat int64
}
displayResp := struct {
Pairs []displayPairHistory
}{}
for _, n := range snapshot.Pairs {
displayResp.Pairs = append(
displayResp.Pairs,
displayPairHistory{
NodeFrom: hex.EncodeToString(n.NodeFrom),
NodeTo: hex.EncodeToString(n.NodeTo),
LastAttemptSuccessful: n.History.LastAttemptSuccessful,
Timestamp: n.History.Timestamp,
AmtMsat: n.History.AmtMsat,
AmtSat: n.History.AmtSat,
},
)
}
printJSON(displayResp)
return nil
}