Skip to content

Commit 4e2ec08

Browse files
committed
cmd/litcli: commands for status server
Note that the client connection for these commands does not require a macaroon.
1 parent 143876d commit 4e2ec08

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

cmd/litcli/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func main() {
7777
app.Commands = append(app.Commands, autopilotCommands)
7878
app.Commands = append(app.Commands, litCommands...)
7979
app.Commands = append(app.Commands, helperCommands)
80+
app.Commands = append(app.Commands, statusCommands...)
8081

8182
err := app.Run(os.Args)
8283
if err != nil {

cmd/litcli/status.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package main
2+
3+
import (
4+
"context"
5+
6+
"github.com/lightninglabs/lightning-terminal/litrpc"
7+
"github.com/lightningnetwork/lnd/lnrpc"
8+
"github.com/urfave/cli"
9+
)
10+
11+
var statusCommands = []cli.Command{
12+
{
13+
Name: "status",
14+
Usage: "info about litd status",
15+
Category: "Status",
16+
Action: getStatus,
17+
},
18+
}
19+
20+
func getStatus(ctx *cli.Context) error {
21+
clientConn, cleanup, err := connectClient(ctx, true)
22+
if err != nil {
23+
return err
24+
}
25+
defer cleanup()
26+
litClient := litrpc.NewStatusClient(clientConn)
27+
28+
// Get LiT's status.
29+
ctxb := context.Background()
30+
litResp, err := litClient.SubServerStatus(
31+
ctxb, &litrpc.SubServerStatusReq{},
32+
)
33+
if err != nil {
34+
return err
35+
}
36+
37+
printRespJSON(litResp)
38+
39+
// Get LND's state.
40+
lndClient := lnrpc.NewStateClient(clientConn)
41+
lndResp, err := lndClient.GetState(ctxb, &lnrpc.GetStateRequest{})
42+
if err != nil {
43+
return err
44+
}
45+
46+
printRespJSON(lndResp)
47+
48+
return nil
49+
}

0 commit comments

Comments
 (0)