cmd/litcli: commands for status server

Note that the client connection for these commands does not require a
macaroon.
This commit is contained in:
Elle Mouton 2023-05-02 20:40:16 +02:00
parent 143876d1ec
commit 4e2ec08767
No known key found for this signature in database
GPG key ID: D7D916376026F177
2 changed files with 50 additions and 0 deletions

View file

@ -77,6 +77,7 @@ func main() {
app.Commands = append(app.Commands, autopilotCommands)
app.Commands = append(app.Commands, litCommands...)
app.Commands = append(app.Commands, helperCommands)
app.Commands = append(app.Commands, statusCommands...)
err := app.Run(os.Args)
if err != nil {

49
cmd/litcli/status.go Normal file
View file

@ -0,0 +1,49 @@
package main
import (
"context"
"github.com/lightninglabs/lightning-terminal/litrpc"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/urfave/cli"
)
var statusCommands = []cli.Command{
{
Name: "status",
Usage: "info about litd status",
Category: "Status",
Action: getStatus,
},
}
func getStatus(ctx *cli.Context) error {
clientConn, cleanup, err := connectClient(ctx, true)
if err != nil {
return err
}
defer cleanup()
litClient := litrpc.NewStatusClient(clientConn)
// Get LiT's status.
ctxb := context.Background()
litResp, err := litClient.SubServerStatus(
ctxb, &litrpc.SubServerStatusReq{},
)
if err != nil {
return err
}
printRespJSON(litResp)
// Get LND's state.
lndClient := lnrpc.NewStateClient(clientConn)
lndResp, err := lndClient.GetState(ctxb, &lnrpc.GetStateRequest{})
if err != nil {
return err
}
printRespJSON(lndResp)
return nil
}