LIGHTNING-OPENCHANNEL_INIT(7)

๐Ÿ“ฆ
version 26.06.9 ยท 2 versions
, in nixpkgs unstable

๐Ÿ’… lightning-openchannel_init(7) โ€” the glam little manual page

okay so bestie, welcome to lightning-openchannel_init(7) โ€” literally the manual page where we learn how to slide into a peer's DMs and start a channel together. lowkey iconic. pull up a chair ๐ŸŽ€


โœจ NAME โœจ

openchannel_init โ€” the command that kicks off a channel open to a peer. it's giving "first message, first impression" ๐Ÿ’Œ


โœจ SYNOPSIS โœจ

openchannel_init id amount initialpsbt [commitment_feerate]
[funding_feerate] [announce] [close_to] [request_amt] [compact_lease]
[channel_type]

โœจ DESCRIPTION โœจ

openchannel_init is a low level RPC command that initiates a channel open with a specified peer. it runs on the openchannel protocol, which is the whole reason we get to do interactive transaction construction like the main characters we are ๐Ÿ‘‘ no cap.

here's the cast of characters, aka every arg:

  • id (pubkey) โ€” the node id of the remote peer. yep, that's your person ๐Ÿซถ
  • amount (sat) โ€” the satoshi value we are contributing to the channel. this value gets added to the provided PSBT in the output that's encumbered by the 2-of-2 script for this channel. write that down.
  • initialpsbt (string) โ€” a funded but incomplete PSBT that specifies the UTXOs and change output for our channel contribution. it can be updated later, see openchannel_update. initialpsbt must have at least one input. also it must have the Non-Witness UTXO (PSBT_IN_NON_WITNESS_UTXO) set for every input โ€” if you don't, you get an error with code 309 returned. no vibes-based PSBTs allowed ๐Ÿ’€
  • commitment_feerate (feerate, optional) โ€” the feerate for commitment transactions, but for non-anchor channels: see fundchannel. for anchor channels, bestie, it's literally ignored.
  • funding_feerate (feerate, optional) โ€” the feerate for the funding transaction. default is the 'opening' feerate โœจ
  • announce (boolean, optional) โ€” whether or not to announce this channel. your call, queen.
  • close_to (string, optional) โ€” a Bitcoin address where the channel funds should be sent on close. only valid if both peers have negotiated option_upfront_shutdown_script โ€” it takes two, periodt ๐Ÿค
  • request_amt (sat, optional) โ€” an amount of liquidity you'd like to lease from the peer. if the peer supports option_will_fund, this tells them to include this much liquidity into the channel. you must also pass in compact_lease alongside it.
  • compact_lease (hex, 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 ๐Ÿ˜ญ
  • channel_type (array of u32s, optional) โ€” each bit set in this channel_type.:
    • (u32, optional) โ€” bit number.

๐ŸŒธ RETURN VALUE ๐ŸŒธ

on success you get an object back, and it contains:

  • channel_id (hash) โ€” the channel id of the channel ๐Ÿ’–
  • psbt (string) โ€” the (incomplete) PSBT of the funding transaction.
  • channel_type (object) โ€” the 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) โ€” the 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.
  • commitments_secured (boolean) (always false) โ€” whether the psbt is complete. it's always false, bestie, that's just the law โš–๏ธ
  • funding_serial (u64) โ€” the serial_id of the funding output in the psbt.
  • requires_confirmed_inputs (boolean, optional) โ€” does peer require confirmed inputs in psbt?

if the peer does not support option_dual_fund, this command returns an error. sorry babe ๐Ÿ™ˆ

and if you sent a request_amt and the peer supports option_will_fund and is interested in leasing you liquidity in this channel, it returns their updated channel fee max (channel_fee_proportional_basis, channel_fee_base_msat), updated rate card for the lease fee (lease_fee_proportional_basis, lease_fee_base_sat), and their on-chain weight weight_charge, which gets added to the lease fee at a rate of funding_feerate * weight_charge / 1000. math slay ๐Ÿงฎโœจ


๐Ÿ”ฅ ERRORS ๐Ÿ”ฅ

on error the returned object contains code and message properties, with code being one of these:

  • -32602 โ€” if the given parameters are wrong.
  • -1 โ€” catchall nonspecific error.
  • 300 โ€” the amount exceeded the maximum configured funding amount.
  • 301 โ€” the provided PSBT cannot afford the funding amount.
  • 304 โ€” still syncing with bitcoin network.
  • 305 โ€” peer is not connected.
  • 306 โ€” unknown peer id.
  • 309 โ€” PSBT missing required fields.
  • 310 โ€” v2 channel open protocol not supported by peer.
  • 312 โ€” channel in an invalid state.

๐Ÿฆ‹ AUTHOR ๐Ÿฆ‹

Lisa Neigut niftynei@gmail.com is mainly responsible. queen behavior, honestly ๐Ÿ‘‘


๐ŸŒˆ SEE ALSO ๐ŸŒˆ


โญ RESOURCES โญ

main web site: https://github.com/ElementsProject/lightning


๐Ÿ“ EXAMPLES ๐Ÿ“

Example 1:

Request:

$ lightning-cli openchannel_init -k "id"="nodeid121212121212121212121212121212121212121212121212121212121212" "amount"=1000000 "initialpsbt"="cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000"
{
  "id": "example:openchannel_init#1",
  "method": "openchannel_init",
  "params": {
    "id": "nodeid121212121212121212121212121212121212121212121212121212121212",
    "amount": 1000000,
    "initialpsbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000"
  }
}

Response:

{
  "channel_id": "a5be438539f73c018a98a4b9dd557d62430881c56552025b5579d180cc3887ed",
  "psbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000610000",
  "channel_type": {
    "bits": [
      12,
      22
    ],
    "names": [
      "static_remotekey/even",
      "anchors/even"
    ]
  },
  "commitments_secured": false,
  "funding_serial": 17725655605188010000,
  "requires_confirmed_inputs": false
}

Example 2:

Request:

$ lightning-cli openchannel_init "nodeid121212121212121212121212121212121212121212121212121212121212" "500000" "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000"
{
  "id": "example:openchannel_init#2",
  "method": "openchannel_init",
  "params": [
    "nodeid121212121212121212121212121212121212121212121212121212121212",
    500000,
    "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000"
  ]
}

Response:

{
  "channel_id": "b3b2e46371876858784cd1b87ecf406e32d8f98b7a44b7f436d1dca317ce0f1b",
  "psbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000710000",
  "channel_type": {
    "bits": [
      12,
      22
    ],
    "names": [
      "static_remotekey/even",
      "anchors/even"
    ]
  },
  "commitments_secured": false,
  "funding_serial": 17725655605188020000,
  "requires_confirmed_inputs": false
}

and that's the whole page, bestie!! ๐Ÿ’œ this lil gem ships with Core Lightning v26.06.9, and yeah โ€” it's LIGHTNING-OPENCHANNEL_INIT(7) all the way through, from the header at the top to this very sparkly sign-off at the bottom ๐ŸŽ€โœจ go open some channels, you absolute icon ๐Ÿฆ‹๐Ÿ’…

๐Ÿ“ฆ where this page comes from