Skip to main content

OpenChannel

OpenChannel attempts to open a singly funded channel specified in the request to a remote peer. Users are able to specify a target number of blocks that the funding transaction should be confirmed in, or a manual fee rate to us for the funding transaction. If neither are specified, then a lax block confirmation target is used. Each OpenStatusUpdate will return the pending channel ID of the in-progress channel. Depending on the arguments specified in the OpenChannelRequest, this pending channel ID can then be used to manually progress the channel funding flow.

Source: lightning.proto

gRPC

info

This is a server-streaming RPC

rpc OpenChannel (OpenChannelRequest) returns (stream OpenStatusUpdate);

REST

HTTP MethodPath
POST /v1/channels/stream

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 = {
sat_per_vbyte: <uint64>,
node_pubkey: <bytes>,
node_pubkey_string: <string>,
local_funding_amount: <int64>,
push_sat: <int64>,
target_conf: <int32>,
sat_per_byte: <int64>,
private: <bool>,
min_htlc_msat: <int64>,
remote_csv_delay: <uint32>,
min_confs: <int32>,
spend_unconfirmed: <bool>,
close_address: <string>,
funding_shim: <FundingShim>,
remote_max_value_in_flight_msat: <uint64>,
remote_max_htlcs: <uint32>,
max_local_csv: <uint32>,
commitment_type: <CommitmentType>,
zero_conf: <bool>,
scid_alias: <bool>,
base_fee: <uint64>,
fee_rate: <uint64>,
use_base_fee: <bool>,
use_fee_rate: <bool>,
remote_chan_reserve_sat: <uint64>,
fund_max: <bool>,
memo: <string>,
outpoints: <OutPoint>,
};
let call = client.openChannel(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:
// {
// "chan_pending": <PendingUpdate>,
// "chan_open": <ChannelOpenUpdate>,
// "psbt_fund": <ReadyForPsbtFunding>,
// "pending_chan_id": <bytes>,
// }

Messages

lnrpc.OpenChannelRequest

Source: lightning.proto

FieldgRPC TypeREST TypeREST Placement
sat_per_vbyte
uint64stringbody
node_pubkey
bytesstringbody
node_pubkey_stringdeprecated
stringstringbody
local_funding_amount
int64stringbody
push_sat
int64stringbody
target_conf
int32integerbody
sat_per_bytedeprecated
int64stringbody
private
boolbooleanbody
min_htlc_msat
int64stringbody
remote_csv_delay
uint32integerbody
min_confs
int32integerbody
spend_unconfirmed
boolbooleanbody
close_address
stringstringbody
funding_shim
FundingShimobjectbody
remote_max_value_in_flight_msat
uint64stringbody
remote_max_htlcs
uint32integerbody
max_local_csv
uint32integerbody
commitment_type
CommitmentTypestringbody
zero_conf
boolbooleanbody
scid_alias
boolbooleanbody
base_fee
uint64stringbody
fee_rate
uint64stringbody
use_base_fee
boolbooleanbody
use_fee_rate
boolbooleanbody
remote_chan_reserve_sat
uint64stringbody
fund_max
boolbooleanbody
memo
stringstringbody
outpoints
OutPoint[]arraybody

lnrpc.OpenStatusUpdate

Source: lightning.proto

FieldgRPC TypeREST Type
chan_pending
PendingUpdateobject
chan_open
ChannelOpenUpdateobject
psbt_fund
ReadyForPsbtFundingobject
pending_chan_id
bytesstring

Nested Messages

lnrpc.ChannelOpenUpdate

FieldgRPC TypeREST Type
channel_point
ChannelPointobject

lnrpc.ChannelPoint

FieldgRPC TypeREST Type
funding_txid_bytes
bytesstring
funding_txid_str
stringstring
output_index
uint32integer

lnrpc.ChanPointShim

FieldgRPC TypeREST Type
amt
int64string
chan_point
ChannelPointobject
local_key
KeyDescriptorobject
remote_key
bytesstring
pending_chan_id
bytesstring
thaw_height
uint32integer
musig2
boolboolean

lnrpc.FundingShim

FieldgRPC TypeREST Type
chan_point_shim
ChanPointShimobject
psbt_shim
PsbtShimobject

lnrpc.KeyDescriptor

FieldgRPC TypeREST Type
raw_key_bytes
bytesstring
key_loc
KeyLocatorobject

lnrpc.KeyLocator

FieldgRPC TypeREST Type
key_family
int32integer
key_index
int32integer

lnrpc.OutPoint

FieldgRPC TypeREST Type
txid_bytes
bytesstring
txid_str
stringstring
output_index
uint32integer

lnrpc.PendingUpdate

FieldgRPC TypeREST Type
txid
bytesstring
output_index
uint32integer

lnrpc.PsbtShim

FieldgRPC TypeREST Type
pending_chan_id
bytesstring
base_psbt
bytesstring
no_publish
boolboolean

lnrpc.ReadyForPsbtFunding

FieldgRPC TypeREST Type
funding_address
stringstring
funding_amount
int64string
psbt
bytesstring

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