lightning-fundchannel -- Command for establishing a lightning channel
SYNOPSIS
fundchannel id amount [feerate] [announce] [minconf] [push_msat] [close_to] [request_amt] [compact_lease] [utxos] [mindepth] [reserve] [channel_type]
DESCRIPTION
The fundchannel RPC command opens a payment channel with a peer by committing a funding transaction to the blockchain as defined in BOLT #2.
If not already connected, fundchannel will automatically attempt to connect if Core Lightning knows a way to contact the node (either from normal gossip, or from a previous connect call).
This auto-connection can fail if Core Lightning does not know how to contact the target node; see lightning-connect(7).
Once the transaction is confirmed, normal channel operations may begin. Readiness is indicated by listpeers reporting a state of CHANNELD_NORMAL
for the channel.
- id (pubkey): Id is the peer id obtained from connect.
- amount (sat_or_all): The amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least
min-emergency- msat
as change). The string all can be used to specify all available funds (or 16777215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in sat, a whole number ending in 000msat, or a number with 1 to 8 decimal places ending in btc. The value cannot be less than the dust limit, currently set to 546, nor more than 16777215 satoshi (unless large channels were negotiated with the peer). - feerate (feerate, optional): Used for the opening transaction and (unless option_anchors is negotiated), as initial feerate for commitment and HTLC transactions (see NOTES in lightning-feerates(7)). The default is normal.
- announce (boolean, optional): Whether to announce this channel or not. An unannounced channel is considered private. The default is True.
- minconf (u32, optional): The minimum number of confirmations that used outputs should have. The default is 1.
- push_msat (msat, optional): The amount of millisatoshis to push to the channel peer at open. Note that this is a gift to the peer -- these satoshis are added to the initial balance of the peer at channel start and are largely unrecoverable once pushed.
- close_to (string, optional): A Bitcoin address to which the channel funds should be sent to on close. Only valid if both peers have negotiated
option_upfront_shutdown_script
. Returnsclose_to
set to closing script iff is negotiated. - request_amt (sat, optional): An amount of liquidity you'd like to lease from the peer. If peer supports
option_will_fund
, indicates to them to include this much liquidity into the channel. Must also pass in compact_lease. - compact_lease (string, optional): A compact representation of the peer's expected channel lease terms. If the peer's terms don't match this set, we will fail to open the channel.
- utxos (array of outpoints, optional): The utxos to be used to fund the channel, as an array of
txid:vout
.:- (outpoint, optional)
- mindepth (u32, optional): Number of confirmations required before we consider the channel active.
- reserve (sat, optional): The amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in sat, a whole number ending in 000msat, or a number with 1 to 8 decimal places ending in btc. The default is 1% of the funding amount.
- channel_type (array of u32s, optional) (added v24.02):
- (u32, optional): Represents the explicit channel type to request. There is currently no sanity checking on this value so if you use strange values and your channel breaks, you get to keep both pieces. BOLT 2 defines the following value types:
``
The currently defined basic types are: option_static_remotekey
(bit 12).option_anchors
andoption_static_remotekey
(bits 22 and 12).
- (u32, optional): Represents the explicit channel type to request. There is currently no sanity checking on this value so if you use strange values and your channel breaks, you get to keep both pieces. BOLT 2 defines the following value types:
Each basic type has the following variations allowed:
option_scid_alias
(bit 46).option_zeroconf
(bit 50).
``
RETURN VALUE
On success, an object is returned, containing:
- tx (hex): The raw transaction which funded the channel.
- txid (txid): The txid of the transaction which funded the channel.
- outnum (u32): The 0-based output index showing which output funded the channel.
- channel_id (hash): The channel_id of the resulting channel.
- channel_type (object): Channel_type as negotiated with peer. (added v24.02):
- bits (array of u32s): Each bit set in this channel_type. (added v24.02):
- (u32, optional): Bit number.
- names (array of strings): Feature name for each bit set in this channel_type. Note that anchors_zero_fee_htlc_tx is a deprecated synonym for anchors. (added v24.02):
- (string, optional) (one of "static_remotekey/even", "anchor_outputs/even", "anchors_zero_fee_htlc_tx/even", "anchors/even", "scid_alias/even", "zeroconf/even"): Name of feature bit.
- bits (array of u32s): Each bit set in this channel_type. (added v24.02):
- close_to (hex, optional): The raw scriptPubkey which mutual close will go to; only present if close_to parameter was specified and peer supports
option_upfront_shutdown_script
. - mindepth (u32, optional): Number of confirmations before we consider the channel active.
ERRORS
The following error codes may occur:
- -1: Catchall nonspecific error.
- 300: The maximum allowed funding amount is exceeded.
- 301: There are not enough funds in the internal wallet (including fees) to create the transaction.
- 302: The output amount is too small, and would be considered dust.
- 303: Broadcasting of the funding transaction failed, the internal call to bitcoin-cli returned with an error.
- 313: The
min-emergency-msat
reserve not be preserved (and we have or are opening anchor channels).
Failure may also occur if lightningd and the peer cannot agree on channel parameters (funding limits, channel reserves, fees, etc.).
SEE ALSO
lightning-connect(7), lightning-listfunds(), lightning-listpeers(7), lightning-feerates(7), lightning-multifundchannel(7)
RESOURCES
Main web site: https://github.com/ElementsProject/lightning
EXAMPLES
Example 1:
Request:
lightning-cli fundchannel -k "id"="032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e" "amount"=1000000 "announce"=True
{
"id": "example:fundchannel#1",
"method": "fundchannel",
"params": {
"id": "032cf15d1ad9c4a08d26eab1918f732d8ef8fdc6abb9640bf3db174372c491304e",
"amount": 1000000,
"announce": true
}
}
Response:
{
"tx": "02000000000101a4f6a433b1c2625323c18bc25f880c3e7960722d9ca353d7ff5c2a2132d56a380000000000fdffffff0240420f0000000000220020b41521751a8eb257315f73a531763071cc39b7cece470f630fd5149fe7b7057a816cdc0b00000000225120a5410daebf4fc3cba618a840af497fbec4c3a084534f2b7b6a7d30bf35f8f566024730440220700ee63053ba1fea998685e721016c15cf7809fd77698560230457e122566f220220181aaa01f472ec575edc532bc612c749e7a3829f5616fc3289fd4dc7d96e98d8012102c8a8f25ed135cd671c88bd4e407bb3746678cfacbcf65ce89f8efc2aa0abe53596000000",
"txid": "8326851788c6da23bc883c960affc6126f766348c131eda53d73bc06f0bd90ff",
"channel_id": "1267da6521b372d7c6407a74066f7a3a5bc3489bbda5eb9f0e990e1e913e2eb9",
"channel_type": {
"bits": [
12,
22
],
"names": [
"static_remotekey/even",
"anchors/even"
]
},
"outnum": 0
}
Example 2: This example shows how to to open new channel with peer 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518 from one whole utxo c8afe317789f3ecbd52893d2ac08be7499486df5a03c95ad063e395e931eb50a:1 (you can use listfunds command to get txid and vout):
Request:
lightning-cli fundchannel -k "id"="0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518" "amount"="all" "feerate"="normal" "push_msat"=100000 "utxos"='["c8afe317789f3ecbd52893d2ac08be7499486df5a03c95ad063e395e931eb50a:1"]'
{
"id": "example:fundchannel#2",
"method": "fundchannel",
"params": {
"id": "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518",
"amount": "all",
"feerate": "normal",
"push_msat": 100000,
"utxos": [
"c8afe317789f3ecbd52893d2ac08be7499486df5a03c95ad063e395e931eb50a:1"
]
}
}
Response:
{
"tx": "020000000001010ab51e935e393e06ad953ca0f56d489974be08acd29328d5cb3e9f7817e3afc80100000000fdffffff01cbb3eb0b00000000220020752dd5af63b98ff64fedf94683b0306c43f6eec74fbfe917639735b305e1b6d9024730440220431a00efd961f417160bd7180970a61b57c01b7c1e082d41429bb0c4e220d4180220542d0c9a1a59048751364b0ede571117fd8abdbf63d83d67a181c17ea3d3ef9e0121024740cce0e548f4ffe80c9914e43444d8e66ee8991dc9d93ec56dff4c56b933159a000000",
"txid": "20bbe695f309285479e6b63b8ab4346ce66b2db7018485e09d59175cec6156b1",
"channel_id": "222d999f537e32e9458c5db17a63e012dcced61340de06fda5bc30566270b0aa",
"channel_type": {
"bits": [
12,
22
],
"names": [
"static_remotekey/even",
"anchors/even"
]
},
"outnum": 0
}