PendingChannels
PendingChannels returns a list of all the channels that are currently considered "pending". A channel is pending if it has finished the funding workflow and is waiting for confirmations for the funding txn, or is in the process of closure, either initiated cooperatively or non-cooperatively.
Source: lightning.proto
gRPC
rpc PendingChannels (PendingChannelsRequest) returns (PendingChannelsResponse);
REST
HTTP Method | Path |
---|---|
GET | /v1/channels/pending |
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
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 = {
include_raw_tx: <bool>,
};
client.pendingChannels(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "total_limbo_balance": <int64>,
// "pending_open_channels": <PendingOpenChannel>,
// "pending_closing_channels": <ClosedChannel>,
// "pending_force_closing_channels": <ForceClosedChannel>,
// "waiting_close_channels": <WaitingCloseChannel>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the lightning.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import lightning_pb2 as lnrpc, lightning_pb2_grpc as lightningstub
GRPC_HOST = 'localhost:10009'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
# create macaroon credentials
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# combine macaroon and SSL credentials
combined_creds = grpc.composite_channel_credentials(ssl_creds, auth_creds)
# make the request
channel = grpc.secure_channel(GRPC_HOST, combined_creds)
stub = lightningstub.LightningStub(channel)
request = lnrpc.PendingChannelsRequest(
include_raw_tx=<bool>,
)
response = stub.PendingChannels(request)
print(response)
# {
# "total_limbo_balance": <int64>,
# "pending_open_channels": <PendingOpenChannel>,
# "pending_closing_channels": <ClosedChannel>,
# "pending_force_closing_channels": <ForceClosedChannel>,
# "waiting_close_channels": <WaitingCloseChannel>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8080'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
let options = {
url: `https://${REST_HOST}/v1/channels/pending`,
// Work-around for self-signed certificates.
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': fs.readFileSync(MACAROON_PATH).toString('hex'),
},
}
request.get(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "total_limbo_balance": <string>, // <int64>
// "pending_open_channels": <array>, // <PendingOpenChannel>
// "pending_closing_channels": <array>, // <ClosedChannel>
// "pending_force_closing_channels": <array>, // <ForceClosedChannel>
// "waiting_close_channels": <array>, // <WaitingCloseChannel>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8080'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/channels/pending'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
r = requests.get(url, headers=headers, verify=TLS_PATH)
print(r.json())
# {
# "total_limbo_balance": <int64>,
# "pending_open_channels": <PendingOpenChannel>,
# "pending_closing_channels": <ClosedChannel>,
# "pending_force_closing_channels": <ForceClosedChannel>,
# "waiting_close_channels": <WaitingCloseChannel>,
# }
$ lncli pendingchannels --help
NAME:
lncli pendingchannels - Display information pertaining to pending channels.
USAGE:
lncli pendingchannels [command options] [arguments...]
CATEGORY:
Channels
OPTIONS:
--include_raw_tx include the raw transaction hex for waiting_close_channels.
Messages
lnrpc.PendingChannelsRequest
Source: lightning.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
include_raw_tx | bool | boolean | query |
lnrpc.PendingChannelsResponse
Source: lightning.proto
Field | gRPC Type | REST Type |
---|---|---|
total_limbo_balance | int64 | string |
pending_open_channels | PendingOpenChannel[] | array |
pending_closing_channels deprecated | ClosedChannel[] | array |
pending_force_closing_channels | ForceClosedChannel[] | array |
waiting_close_channels | WaitingCloseChannel[] | array |
Nested Messages
lnrpc.PendingChannelsResponse.ClosedChannel
Field | gRPC Type | REST Type |
---|---|---|
channel | PendingChannel | unknown |
closing_txid | string | unknown |
lnrpc.PendingChannelsResponse.Commitments
Field | gRPC Type | REST Type |
---|---|---|
local_txid | string | unknown |
remote_txid | string | unknown |
remote_pending_txid | string | unknown |
local_commit_fee_sat | uint64 | unknown |
remote_commit_fee_sat | uint64 | unknown |
remote_pending_commit_fee_sat | uint64 | unknown |
lnrpc.PendingChannelsResponse.ForceClosedChannel
Field | gRPC Type | REST Type |
---|---|---|
channel | PendingChannel | unknown |
closing_txid | string | unknown |
limbo_balance | int64 | unknown |
maturity_height | uint32 | unknown |
blocks_til_maturity | int32 | unknown |
recovered_balance | int64 | unknown |
pending_htlcs | PendingHTLC[] | unknown |
anchor | AnchorState | unknown |
lnrpc.PendingChannelsResponse.PendingChannel
Field | gRPC Type | REST Type |
---|---|---|
remote_node_pub | string | unknown |
channel_point | string | unknown |
capacity | int64 | unknown |
local_balance | int64 | unknown |
remote_balance | int64 | unknown |
local_chan_reserve_sat | int64 | unknown |
remote_chan_reserve_sat | int64 | unknown |
initiator | Initiator | unknown |
commitment_type | CommitmentType | unknown |
num_forwarding_packages | int64 | unknown |
chan_status_flags | string | unknown |
private | bool | unknown |
memo | string | unknown |
custom_channel_data | bytes | unknown |
lnrpc.PendingChannelsResponse.PendingOpenChannel
Field | gRPC Type | REST Type |
---|---|---|
channel | PendingChannel | unknown |
commit_fee | int64 | unknown |
commit_weight | int64 | unknown |
fee_per_kw | int64 | unknown |
funding_expiry_blocks | int32 | unknown |
lnrpc.PendingChannelsResponse.WaitingCloseChannel
Field | gRPC Type | REST Type |
---|---|---|
channel | PendingChannel | unknown |
limbo_balance | int64 | unknown |
commitments | Commitments | unknown |
closing_txid | string | unknown |
closing_tx_hex | string | unknown |
lnrpc.PendingHTLC
Field | gRPC Type | REST Type |
---|---|---|
incoming | bool | boolean |
amount | int64 | string |
outpoint | string | string |
maturity_height | uint32 | integer |
blocks_til_maturity | int32 | integer |
stage | uint32 | integer |
Enums
lnrpc.CommitmentType
Name | Number |
---|---|
UNKNOWN_COMMITMENT_TYPE | 0 |
LEGACY | 1 |
STATIC_REMOTE_KEY | 2 |
ANCHORS | 3 |
SCRIPT_ENFORCED_LEASE | 4 |
SIMPLE_TAPROOT | 5 |
SIMPLE_TAPROOT_OVERLAY | 6 |
lnrpc.Initiator
Name | Number |
---|---|
INITIATOR_UNKNOWN | 0 |
INITIATOR_LOCAL | 1 |
INITIATOR_REMOTE | 2 |
INITIATOR_BOTH | 3 |
lnrpc.PendingChannelsResponse.ForceClosedChannel.AnchorState
Name | Number |
---|---|
LIMBO | 0 |
RECOVERED | 1 |
LOST | 2 |