mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
2b1bb3bce0
This updates the description that is provided for `lncli state` to match the states that are currently returned by lnd. `RPC_READY` no longer exists and is replaced by `RPC_ACTIVE` with a revised description, and `SERVER_ACTIVE` is added as the status that indicates lnd is fully ready to accept RPC calls. See `enum WalletState` in `stateservice.proto`.
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/lightningnetwork/lnd/lnrpc"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var getStateCommand = cli.Command{
|
|
Name: "state",
|
|
Category: "Startup",
|
|
Usage: "Get the current state of the wallet and RPC",
|
|
Description: `
|
|
Get the current state of the wallet. The possible states are:
|
|
- WAITING_TO_START: node is waiting to become the leader in a cluster
|
|
and is not started yet.
|
|
- NON_EXISTING: wallet has not yet been initialized.
|
|
- LOCKED: wallet is locked.
|
|
- UNLOCKED: wallet was unlocked successfully, but RPC server isn't ready.
|
|
- RPC_ACTIVE: RPC server is active but not fully ready for calls.
|
|
- SERVER_ACTIVE: RPC server is available and ready to accept calls.
|
|
`,
|
|
Flags: []cli.Flag{},
|
|
Action: actionDecorator(getState),
|
|
}
|
|
|
|
func getState(ctx *cli.Context) error {
|
|
ctxb := context.Background()
|
|
client, cleanUp := getStateServiceClient(ctx)
|
|
defer cleanUp()
|
|
|
|
req := &lnrpc.SubscribeStateRequest{}
|
|
stream, err := client.SubscribeState(ctxb, req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Get a single state, then exit.
|
|
resp, err := stream.Recv()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
printRespJSON(resp)
|
|
return nil
|
|
}
|