Skip to main content

OpenChannelSync

OpenChannelSync is a synchronous version of the OpenChannel RPC call. This call is meant to be consumed by clients to the REST proxy. As with all other sync calls, all byte slices are intended to be populated as hex encoded strings.

Source: lightning.proto

gRPC

rpc OpenChannelSync (OpenChannelRequest) returns (ChannelPoint);

REST

HTTP MethodPath
POST /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 = {
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>,
};
client.openChannelSync(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "funding_txid_bytes": <bytes>,
// "funding_txid_str": <string>,
// "output_index": <uint32>,
// }

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.ChannelPoint

Source: lightning.proto

FieldgRPC TypeREST Type
funding_txid_bytes
bytesstring
funding_txid_str
stringstring
output_index
uint32integer

Nested Messages

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.PsbtShim

FieldgRPC TypeREST Type
pending_chan_id
bytesstring
base_psbt
bytesstring
no_publish
boolboolean

Enums

lnrpc.CommitmentType

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