Skip to main content

ListChannels

ListChannels returns a description of all the open channels that this node is a participant in.

Source: lightning.proto

gRPC

rpc ListChannels (ListChannelsRequest) returns (ListChannelsResponse);

REST

HTTP MethodPath
GET /v1/channels

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 = {
active_only: <bool>,
inactive_only: <bool>,
public_only: <bool>,
private_only: <bool>,
peer: <bytes>,
peer_alias_lookup: <bool>,
};
client.listChannels(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "channels": <Channel>,
// }

Messages

lnrpc.ListChannelsRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
active_only
boolbooleanquery
inactive_only
boolbooleanquery
public_only
boolbooleanquery
private_only
boolbooleanquery
peer
bytesstringquery
peer_alias_lookup
boolbooleanquery

lnrpc.ListChannelsResponse

Source: lightning.proto

FieldgRPC TypeREST Type
channels
Channel[]array

Nested Messages

lnrpc.Channel

FieldgRPC TypeREST Type
active
boolboolean
remote_pubkey
stringstring
channel_point
stringstring
chan_id
uint64string
capacity
int64string
local_balance
int64string
remote_balance
int64string
commit_fee
int64string
commit_weight
int64string
fee_per_kw
int64string
unsettled_balance
int64string
total_satoshis_sent
int64string
total_satoshis_received
int64string
num_updates
uint64string
pending_htlcs
HTLC[]array
csv_delaydeprecated
uint32integer
private
boolboolean
initiator
boolboolean
chan_status_flags
stringstring
local_chan_reserve_satdeprecated
int64string
remote_chan_reserve_satdeprecated
int64string
static_remote_keydeprecated
boolboolean
commitment_type
CommitmentTypestring
lifetime
int64string
uptime
int64string
close_address
stringstring
push_amount_sat
uint64string
thaw_height
uint32integer
local_constraints
ChannelConstraintsobject
remote_constraints
ChannelConstraintsobject
alias_scids
uint64[]array
zero_conf
boolboolean
zero_conf_confirmed_scid
uint64string
peer_alias
stringstring
peer_scid_alias
uint64string
memo
stringstring
custom_channel_data
bytesstring

lnrpc.ChannelConstraints

FieldgRPC TypeREST Type
csv_delay
uint32integer
chan_reserve_sat
uint64string
dust_limit_sat
uint64string
max_pending_amt_msat
uint64string
min_htlc_msat
uint64string
max_accepted_htlcs
uint32integer

lnrpc.HTLC

FieldgRPC TypeREST Type
incoming
boolboolean
amount
int64string
hash_lock
bytesstring
expiration_height
uint32integer
htlc_index
uint64string
forwarding_channel
uint64string
forwarding_htlc_index
uint64string

Enums

lnrpc.CommitmentType

NameNumber
UNKNOWN_COMMITMENT_TYPE
0
LEGACY
1
STATIC_REMOTE_KEY
2
ANCHORS
3
SCRIPT_ENFORCED_LEASE
4
SIMPLE_TAPROOT
5
SIMPLE_TAPROOT_OVERLAY
6