Skip to main content

GetState

GetState returns the current wallet state without streaming further changes.

Source: stateservice.proto

gRPC

rpc GetState (GetStateRequest) returns (GetStateResponse);

REST

HTTP MethodPath
GET /v1/state

Code Samples

const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const GRPC_HOST = 'localhost:10009'
const TLS_PATH = 'LND_DIR/tls.cert'

const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync(['lightning.proto', 'stateservice.proto'], loaderOptions);
const lnrpc = grpc.loadPackageDefinition(packageDefinition).lnrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
let client = new lnrpc.State(GRPC_HOST, sslCreds);
let request = {};
client.getState(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "state": <WalletState>,
// }

Messages

lnrpc.GetStateRequest

Source: stateservice.proto

note

This request has no parameters.

lnrpc.GetStateResponse

Source: stateservice.proto

FieldgRPC TypeREST Type
state
WalletStatestring

Enums

lnrpc.WalletState

NameNumber
NON_EXISTING
0
LOCKED
1
UNLOCKED
2
RPC_ACTIVE
3
SERVER_ACTIVE
4
WAITING_TO_START
255