2023-05-02 20:40:16 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/lightninglabs/lightning-terminal/litrpc"
|
|
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var statusCommands = []cli.Command{
|
|
|
|
|
{
|
2023-10-26 12:31:40 -06:00
|
|
|
Name: "status",
|
|
|
|
|
Usage: "View info about litd status",
|
|
|
|
|
Description: "View info about litd status.\n",
|
|
|
|
|
Category: "LiT",
|
2023-12-19 09:28:34 +01:00
|
|
|
Action: getStatus,
|
2023-05-02 20:40:16 +02:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-13 09:07:30 +02:00
|
|
|
func getStatus(cli *cli.Context) error {
|
|
|
|
|
clientConn, cleanup, err := connectClient(cli, true)
|
2023-05-02 20:40:16 +02:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
defer cleanup()
|
|
|
|
|
litClient := litrpc.NewStatusClient(clientConn)
|
|
|
|
|
|
|
|
|
|
// Get LiT's status.
|
2025-01-13 09:07:30 +02:00
|
|
|
ctx := getContext()
|
2023-05-02 20:40:16 +02:00
|
|
|
litResp, err := litClient.SubServerStatus(
|
2025-01-13 09:07:30 +02:00
|
|
|
ctx, &litrpc.SubServerStatusReq{},
|
2023-05-02 20:40:16 +02:00
|
|
|
)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printRespJSON(litResp)
|
|
|
|
|
|
|
|
|
|
// Get LND's state.
|
|
|
|
|
lndClient := lnrpc.NewStateClient(clientConn)
|
2025-01-13 09:07:30 +02:00
|
|
|
lndResp, err := lndClient.GetState(ctx, &lnrpc.GetStateRequest{})
|
2023-05-02 20:40:16 +02:00
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printRespJSON(lndResp)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|