lightning-fundchannel

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. Returns close_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 and option_static_remotekey (bits 22 and 12).

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.
  • 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"="022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59" "amount"=1000000 "announce"=True
{
  "id": "example:fundchannel#1",
  "method": "fundchannel",
  "params": {
    "id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
    "amount": 1000000,
    "announce": true
  }
}

Response:

{
  "tx": "020000000001014ca47b75e6982fce6b5ebb6e7ec163dc5b6bed1562934e6febe816103b2b207e0000000000fdffffff0240420f00000000002200205b8cd3b914cf67cdd8fa6273c930353dd36476734fbd962102c2df53b90880cd012f0f000000000022512063ffee4ea7d51e6cadf9086e286a2527922aaa25b8c53aebf32fa32a0a627f5a02473044022058fc4d51c8254d37b266d3db3f8fda7420882b6ec9226d66b8c0139f2707c09602205798d8ce23d4c692a7384362a2e0afd9703f062239a786d7a1840a28d3a1152e012103d745445c9362665f22e0d96e9e766f273f3260dea39c8a76bfa05dd2684ddccf66000000",
  "txid": "6c0a3d8f32f556f3bd8b8c85413c4636a9513c6195abb925ea73c47183d40b7b",
  "channel_id": "7b0bd48371c473ea25b9ab95613c51a936463c41858c8bbdf356f5328f3d0a6c",
  "outnum": 0
}

Example 2:

Request:

lightning-cli fundchannel -k "id"="022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59" "amount"=10000000 "announce"=True "push_msat"=1000000000
{
  "id": "example:fundchannel#2",
  "method": "fundchannel",
  "params": {
    "id": "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59",
    "amount": 10000000,
    "announce": true,
    "push_msat": 1000000000
  }
}

Response:

{
  "tx": "0200000000010141cfa0e9957c7c6d0bb5069d92937f9545e6e6ee9b4650f47f509d5ea65df4690100000000fdffffff0280969800000000002200205b8cd3b914cf67cdd8fa6273c930353dd36476734fbd962102c2df53b90880cd4118530b0000000022512063ffee4ea7d51e6cadf9086e286a2527922aaa25b8c53aebf32fa32a0a627f5a0247304402206488c7dfbc4180781ed0d5ca7ff2c8ce134480c349d03978765053a393229d9a022066c75dee1f19b410ea1c7756d0cb2c097e52b13f4d9bbd033efa4ed95d817e14012103d745445c9362665f22e0d96e9e766f273f3260dea39c8a76bfa05dd2684ddccf66000000",
  "txid": "6aa1231b6356777468a55aea1f49dad6415592aef6c1e652f8a64357c7235301",
  "channel_id": "015323c75743a6f852e6c1f6ae925541d6da491fea5aa568747756631b23a16a",
  "channel_type": {
    "bits": [
      12,
      22
    ],
    "names": [
      "static_remotekey/even",
      "anchors/even"
    ]
  },
  "outnum": 0
}

Example 3: This example shows how to to open new channel with peer 034...4d5 from one whole utxo 961...aeb:1 (you can use listfunds command to get txid and vout):

Request:

lightning-cli fundchannel -k "id"="0348e58210bbc128b1cc3cc1a520a654aaa01e5fe65c65341e21b61a1f09da94d5" "amount"="all" "feerate"="normal" "push_msat"=1000000000 "utxos"='["9619a4ccc08512f9520363c7163c95c54723ee8d40802e763a1598fec7bdaaeb:1"]'
{
  "id": "example:fundchannel#3",
  "method": "fundchannel",
  "params": {
    "id": "0348e58210bbc128b1cc3cc1a520a654aaa01e5fe65c65341e21b61a1f09da94d5",
    "amount": "all",
    "feerate": "normal",
    "push_msat": 1000000000,
    "utxos": [
      "9619a4ccc08512f9520363c7163c95c54723ee8d40802e763a1598fec7bdaaeb:1"
    ]
  }
}

Response:

{
  "tx": "02000000000101ebaabdc7fe98153a762e80408dee2347c5953c16c7630352f91285c0cca419960100000000fdffffff02a861000000000000225120b348ab8875cbcfad71e5f3f96e8b3cb25b3495701fb1e06e7f01c70c6e3d7776ec00510200000000220020b71d4d6b2224c9a6b234fde9ca8922ca83be1bc440c08da2156fc3b154c476ff014035ccc897ca0097be7088e397bab0215c967257a25d3efb2d96259d5a7051078b1caaddacc702fced9289d556be70c55bf10fae0bb761526f3d165ff106da140c2f030000",
  "txid": "dbeeb2320ddf3ae0bb7887df8226ecdbcec3583ea027a2c1d86bfb167b0f93ea",
  "channel_id": "c4e607b4743fa4ee516fd247dbdaf4cb17b8462b2468bd84f15d6f78ac82bf1a",
  "channel_type": {
    "bits": [
      12,
      22
    ],
    "names": [
      "static_remotekey/even",
      "anchors/even"
    ]
  },
  "outnum": 1
}