2019-08-31 14:30:56 +02:00
lightning-fundchannel -- Command for establishing a lightning channel
=====================================================================
2019-08-10 01:54:18 +02:00
SYNOPSIS
--------
2021-02-18 00:38:30 +01:00
**fundchannel** *id* *amount* \[*feerate*\] \[*announce*\] \[*minconf*\]
2021-07-02 23:19:47 +02:00
\[*utxos*\] \[*push_msat*\] \[*close_to*\] \[*request_amt*\] \[*compact_lease*\]
2019-08-10 01:54:18 +02:00
DESCRIPTION
-----------
The **fundchannel** RPC command opens a payment channel with a peer by
committing a funding transaction to the blockchain as defined in BOLT
2020-01-29 04:25:43 +01:00
\#2.
If not already connected, **fundchannel** will automatically attempt
to connect if C-lightning knows a way to contact the node (either from
normal gossip, or from a previous **connect** call).
This auto-connection can fail if C-lightning does not know how to contact
the target node; see lightning-connect(7).
Once the
2019-08-10 01:54:18 +02:00
transaction is confirmed, normal channel operations may begin. Readiness
2020-09-09 05:11:37 +02:00
is indicated by **listpeers** reporting a *state* of `CHANNELD_NORMAL`
2019-08-10 01:54:18 +02:00
for the channel.
*id* is the peer id obtained from **connect** .
2019-09-19 09:43:26 +02:00
*amount* is the amount in satoshis taken from the internal wallet to
2019-08-10 01:54:18 +02:00
fund the channel. The string *all* can be used to specify all available
2020-04-03 02:03:58 +02:00
funds (or 16777215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise, it is in
2019-08-10 01:54:18 +02:00
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
2020-04-03 02:03:58 +02:00
limit, currently set to 546, nor more than 16777215 satoshi (unless large
channels were negotiated with the peer).
2019-08-10 01:54:18 +02:00
*feerate* is an optional feerate used for the opening transaction and as
initial feerate for commitment and HTLC transactions. It can be one of
the strings *urgent* (aim for next block), *normal* (next 4 blocks or
2021-10-24 11:44:56 +02:00
so) or *slow* (next 100 blocks or so) to use lightningd's internal
2019-08-10 01:54:18 +02:00
estimates: *normal* is the default.
Otherwise, *feerate* is a number, with an optional suffix: *perkw* means
the number is interpreted as satoshi-per-kilosipa (weight), and *perkb*
means it is interpreted bitcoind-style as satoshi-per-kilobyte. Omitting
the suffix is equivalent to *perkb* .
2019-10-19 00:36:52 +02:00
*announce* is an optional flag that triggers whether to announce this
channel or not. Defaults to `true` . An unannounced channel is considered
private.
2019-08-10 01:54:18 +02:00
*minconf* specifies the minimum number of confirmations that used
outputs should have. Default is 1.
*utxos* specifies the utxos to be used to fund the channel, as an array
of "txid:vout".
2019-12-21 06:53:12 +01:00
*push_msat* is 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.
2020-10-15 04:37:27 +02:00
*close_to* is 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` .
Returns `close_to` set to closing script iff is negotiated.
2021-06-08 23:55:06 +02:00
*request_amt* is an amount of liquidity you'd like to lease from the peer.
If peer supports `option_will_fund` , indicates to them to include this
2021-07-02 23:19:47 +02:00
much liquidity into the channel. Must also pass in *compact_lease* .
*compact_lease* is a compact represenation 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.
2021-06-08 23:55:06 +02:00
2021-05-18 21:48:09 +02:00
This example shows how to use lightning-cli to open new channel with peer 03f...fc1 from one whole utxo bcc1...39c:0
(you can use **listfunds** command to get txid and vout):
lightning-cli -k fundchannel id=03f...fc1 amount=all feerate=normal utxos='["bcc1...39c:0"]'
2019-08-10 01:54:18 +02:00
RETURN VALUE
------------
doc/schemas: disableoffer, disconnect, feerates, fetchinvoice, fundchannel, fundchannel_cancel, fundchannel_complete, fundchannel_start, fundpsbt, getinfo, getlog, getroute.
We also add a test for getlog, since it was never called by the
testsuite.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-26 09:35:01 +02:00
[comment]: # (GENERATE-FROM-SCHEMA-START)
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** (hex): The channel_id of the resulting channel (always 64 characters)
- **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`
2021-09-03 12:07:59 +02:00
doc/schemas: disableoffer, disconnect, feerates, fetchinvoice, fundchannel, fundchannel_cancel, fundchannel_complete, fundchannel_start, fundpsbt, getinfo, getlog, getroute.
We also add a test for getlog, since it was never called by the
testsuite.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-05-26 09:35:01 +02:00
[comment]: # (GENERATE-FROM-SCHEMA-END)
2020-10-15 04:37:27 +02:00
2019-08-10 01:54:18 +02:00
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.
Failure may also occur if **lightningd** and the peer cannot agree on
channel parameters (funding limits, channel reserves, fees, etc.).
SEE ALSO
--------
2020-07-12 05:30:35 +02:00
lightning-connect(7), lightning-listfunds(), lightning-listpeers(7),
2020-09-09 05:11:37 +02:00
lightning-feerates(7), lightning-multifundchannel(7)
2019-08-10 01:54:18 +02:00
RESOURCES
---------
Main web site: < https: / / github . com / ElementsProject / lightning >
2020-08-25 03:33:16 +02:00
2021-11-04 15:15:51 +01:00
[comment]: # ( SHA256STAMP:4a8d7c524cfe257f961531929d14d3589efb6ecd182a33e92aade30af90406f8)