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>,
coin_selection_strategy: <CoinSelectionStrategy>,
};
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
coin_selection_strategy
CoinSelectionStrategystringbody

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
remote_max_value_in_flight_msat
uint64string
remote_max_htlcs
uint32integer
max_local_csv
uint32integer
zero_conf
boolboolean
scid_alias
boolboolean
base_fee
uint64string
fee_rate
uint64string
use_base_fee
boolboolean
use_fee_rate
boolboolean
remote_chan_reserve_sat
uint64string
memo
stringstring

lnrpc.PendingUpdate

FieldgRPC TypeREST Type
txid
bytesstring
output_index
uint32integer

Enums

lnrpc.CoinSelectionStrategy

NameNumber
STRATEGY_USE_GLOBAL_CONFIG
0
STRATEGY_LARGEST
1
STRATEGY_RANDOM
2

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