Skip to main content

SubscribeState

SubscribeState subscribes to the state of the wallet. The current wallet state will always be delivered immediately.

Source: stateservice.proto

gRPC

info

This is a server-streaming RPC

rpc SubscribeState (SubscribeStateRequest) returns (stream SubscribeStateResponse);

REST

HTTP MethodPath
GET /v1/state/subscribe

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 = {};
let call = client.subscribeState(request);
call.on('data', function(response) {
// A response was received from the server.
console.log(response);
});
call.on('status', function(status) {
// The current status of the stream.
});
call.on('end', function() {
// The server has closed the stream.
});
// Console output:
// {
// "state": <WalletState>,
// }

Messages

lnrpc.SubscribeStateRequest

Source: stateservice.proto

note

This request has no parameters.

lnrpc.SubscribeStateResponse

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