Skip to main content

BatchOpenChannel

BatchOpenChannel attempts to open multiple single-funded channels in a single transaction in an atomic way. This means either all channel open requests succeed at once or all attempts are aborted if any of them fail. This is the safer variant of using PSBTs to manually fund a batch of channels through the OpenChannel RPC.

Source: lightning.proto

gRPC

rpc BatchOpenChannel (BatchOpenChannelRequest) returns (BatchOpenChannelResponse);

REST

HTTP MethodPath
POST /v1/channels/batch

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 = {
channels: <BatchOpenChannel>,
target_conf: <int32>,
sat_per_vbyte: <int64>,
min_confs: <int32>,
spend_unconfirmed: <bool>,
label: <string>,
};
client.batchOpenChannel(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "pending_channels": <PendingUpdate>,
// }

Messages

lnrpc.BatchOpenChannelRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
channels
BatchOpenChannel[]arraybody
target_conf
int32integerbody
sat_per_vbyte
int64stringbody
min_confs
int32integerbody
spend_unconfirmed
boolbooleanbody
label
stringstringbody

lnrpc.BatchOpenChannelResponse

Source: lightning.proto

FieldgRPC TypeREST Type
pending_channels
PendingUpdate[]array

Nested Messages

lnrpc.BatchOpenChannel

FieldgRPC TypeREST Type
node_pubkey
bytesstring
local_funding_amount
int64string
push_sat
int64string
private
boolboolean
min_htlc_msat
int64string
remote_csv_delay
uint32integer
close_address
stringstring
pending_chan_id
bytesstring
commitment_type
CommitmentTypestring

lnrpc.PendingUpdate

FieldgRPC TypeREST Type
txid
bytesstring
output_index
uint32integer

Enums

lnrpc.CommitmentType

NameNumber
UNKNOWN_COMMITMENT_TYPE
0
LEGACY
1
STATIC_REMOTE_KEY
2
ANCHORS
3
SCRIPT_ENFORCED_LEASE
4