Skip to main content

SubscribeChannelGraph

SubscribeChannelGraph launches a streaming RPC that allows the caller to receive notifications upon any changes to the channel graph topology from the point of view of the responding node. Events notified include: new nodes coming online, nodes updating their authenticated attributes, new channels being advertised, updates in the routing policy for a directional channel edge, and when channels are closed on-chain.

Source: lightning.proto

gRPC

info

This is a server-streaming RPC

rpc SubscribeChannelGraph (GraphTopologySubscription) returns (stream GraphTopologyUpdate);

REST

HTTP MethodPath
GET /v1/graph/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 MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
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', 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);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new lnrpc.Lightning(GRPC_HOST, creds);
let request = {};
let call = client.subscribeChannelGraph(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:
// {
// "node_updates": <NodeUpdate>,
// "channel_updates": <ChannelEdgeUpdate>,
// "closed_chans": <ClosedChannelUpdate>,
// }

Messages

lnrpc.GraphTopologySubscription

Source: lightning.proto

note

This request has no parameters.

lnrpc.GraphTopologyUpdate

Source: lightning.proto

FieldgRPC TypeREST Type
node_updates
NodeUpdate[]array
channel_updates
ChannelEdgeUpdate[]array
closed_chans
ClosedChannelUpdate[]array

Nested Messages

lnrpc.NodeUpdate

FieldgRPC TypeREST Type
addresses
string[]array
identity_key
stringstring
global_features
bytesstring
alias
stringstring
color
stringstring
node_addresses
NodeAddress[]array
features
FeaturesEntry[]object

lnrpc.NodeAddress

FieldgRPC TypeREST Type
network
stringstring
addr
stringstring

lnrpc.NodeUpdate.FeaturesEntry

FieldgRPC TypeREST Type
key
uint32unknown
value
Featureunknown

lnrpc.Feature

FieldgRPC TypeREST Type
name
stringstring
is_required
boolboolean
is_known
boolboolean

lnrpc.ChannelEdgeUpdate

FieldgRPC TypeREST Type
chan_id
uint64string
chan_point
ChannelPointobject
capacity
int64string
routing_policy
RoutingPolicyobject
advertising_node
stringstring
connecting_node
stringstring

lnrpc.ChannelPoint

FieldgRPC TypeREST Type
funding_txid_bytes
bytesstring
funding_txid_str
stringstring
output_index
uint32integer

lnrpc.RoutingPolicy

FieldgRPC TypeREST Type
time_lock_delta
uint32integer
min_htlc
int64string
fee_base_msat
int64string
fee_rate_milli_msat
int64string
disabled
boolboolean
max_htlc_msat
uint64string
last_update
uint32integer
custom_records
CustomRecordsEntry[]object

lnrpc.RoutingPolicy.CustomRecordsEntry

FieldgRPC TypeREST Type
key
uint64unknown
value
bytesunknown

lnrpc.ClosedChannelUpdate

FieldgRPC TypeREST Type
chan_id
uint64string
capacity
int64string
closed_height
uint32integer
chan_point
ChannelPointobject