2019-05-10 11:39:16 +03:00
|
|
|
// +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.",
|
2019-05-10 11:39:16 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-07-29 16:10:58 +03:00
|
|
|
type displayPairHistory struct {
|
2019-07-29 15:20:06 +03:00
|
|
|
NodeFrom, NodeTo string
|
|
|
|
LastAttemptSuccessful bool
|
|
|
|
Timestamp int64
|
|
|
|
MinPenalizeAmtSat int64
|
2019-05-10 11:39:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
displayResp := struct {
|
2019-07-29 16:10:58 +03:00
|
|
|
Pairs []displayPairHistory
|
2019-05-10 11:39:16 +03:00
|
|
|
}{}
|
|
|
|
|
2019-07-29 16:10:58 +03:00
|
|
|
for _, n := range snapshot.Pairs {
|
|
|
|
displayResp.Pairs = append(
|
|
|
|
displayResp.Pairs,
|
|
|
|
displayPairHistory{
|
2019-07-29 15:20:06 +03:00
|
|
|
NodeFrom: hex.EncodeToString(n.NodeFrom),
|
|
|
|
NodeTo: hex.EncodeToString(n.NodeTo),
|
2019-09-30 10:12:50 +03:00
|
|
|
LastAttemptSuccessful: n.History.LastAttemptSuccessful,
|
|
|
|
Timestamp: n.History.Timestamp,
|
|
|
|
MinPenalizeAmtSat: n.History.MinPenalizeAmtSat,
|
2019-05-10 11:39:16 +03:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
printJSON(displayResp)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|