github.com/decred/dcrlnd@v0.7.6/cmd/dcrlncli/cmd_state.go (about) 1 package main 2 3 import ( 4 "context" 5 6 "github.com/decred/dcrlnd/lnrpc" 7 "github.com/urfave/cli" 8 ) 9 10 var getStateCommand = cli.Command{ 11 Name: "state", 12 Category: "Startup", 13 Usage: "Get the current state of the wallet and RPC", 14 Description: ` 15 Get the current state of the wallet. The possible states are: 16 - NON_EXISTING: wallet has not yet been initialized. 17 - LOCKED: wallet is locked. 18 - UNLOCKED: wallet has been unlocked successfully, but the full RPC is 19 not yet ready. 20 - RPC_READY: the daemon has started and the RPC is fully available. 21 `, 22 Flags: []cli.Flag{}, 23 Action: actionDecorator(getState), 24 } 25 26 func getState(ctx *cli.Context) error { 27 ctxb := context.Background() 28 client, cleanUp := getStateServiceClient(ctx) 29 defer cleanUp() 30 31 req := &lnrpc.SubscribeStateRequest{} 32 stream, err := client.SubscribeState(ctxb, req) 33 if err != nil { 34 return err 35 } 36 37 // Get a single state, then exit. 38 resp, err := stream.Recv() 39 if err != nil { 40 return err 41 } 42 43 printRespJSON(resp) 44 return nil 45 }