LIGHTNING-HOOK-OPENCHANNEL2(7)
LIGHTNING-HOOK-OPENCHANNEL2(7) π
okay bestie, pull up a chair β this is the manual page for lightning-hook-openchannel2 (yep, that's the lightning-hook-openchannel2(7) page, section 7, in case you were wondering), and it's genuinely one of the slay-est hooks in the whole Lightning stack. let's get into it π
β¨ NAME β¨
openchannel2 β the hook that fires when a peer proposes opening a channel using v2 protocol. that's it. that's the vibe. π
πΈ DESCRIPTION πΈ
so, openchannel2 gets called whenever a remote peer tries to fund a channel using the v2 (dual-funding) protocol β but only after passing the basic sanity checks, obviously. like, we have standards. π
the payload mirrors the BOLT #2 open_channel message and its dual-funding extensions, no cap. and heads up β there may be additional fields present depending on the negotiated features. iykyk. β¨
okay so this part is important: requested_lease_msat, lease_blockheight_start, and node_blockheight are only present if the peer requested a funding lease (option_will_fund). if there's no lease, those three just aren't there. simple as. π
your plugin has three moves: reject the channel, accept it, or contribute funds via a PSBT when accepting. main character energy, honestly. π₯
if you want to see how this is actually done, check plugins/funder.c β that's the example for using this hook to contribute funds to a channel open. go read it, it eats. π
now. this is a chained hook, which means multiple plugins may be invoked. and the way that works is β returning any result other than "continue" terminates the chain. that's a full stop on the whole thing, so be careful out there. π
also: only the first plugin that sets mutation fields (e.g. close_to) will have them applied. first one wins, everyone after is just vibing in the void. and listen β invalid close_to addresses will cause lightningd to exit. like, dead. gone. so maybe double-check those addresses, bestie. π«Ά
last thing: the PSBT must be consistent with the funding transaction and respect feerate constraints. fr fr, don't skip that part. β
π¦ HOOK PAYLOAD π¦
openchannel2(object):id(pubkey): thenode_idof the peer proposing the channel. who's this diva? π§channel_id(hash): the temporarychannel_idassigned for this channel negotiation.their_funding_msat(msat): amount contributed by the remote peer to the channel funding transaction.dust_limit_msat(msat): minimum output value below which outputs are considered dust.max_htlc_value_in_flight_msat(msat): maximum total value of outstanding HTLCs allowed in the channel at any time.htlc_minimum_msat(msat): minimum HTLC value the peer will accept.funding_feerate_per_kw(u32): feerate (per kw) used for the funding transaction.commitment_feerate_per_kw(u32): feerate (per kw) used for commitment transactions.feerate_our_max(u32): maximum feerate we are willing to accept for commitment transactions.feerate_our_min(u32): minimum feerate we are willing to accept for commitment transactions.to_self_delay(u16): the number of blocks before they can take their funds if they unilateral close.max_accepted_htlcs(u16): maximum number of HTLC's the remote is allowed to offer at once.channel_flags(u8): channel flags as defined in BOLT #7.locktime(u32): locktime to be used in the funding transaction.channel_max_msat(msat): maximum capacity this channel is allowed to reach.require_confirmed_inputs(boolean): indicates whether the peer requires all funding inputs to be confirmed. (added v23.02) βchannel_type(object) (added v25.09): πbits(array of u32s): list of feature bit numbers that define the negotiated channel type. each value represents a feature bit as defined in BOLT #2.:- (u32, optional): feature bit number.
names(array of strings): human-readable names corresponding to each feature bit. names are implementation-defined and may evolve over time.:- (string, optional): name of the feature bit.
shutdown_scriptpubkey(hex, optional): optional shutdownscriptPubKeyprovided by the peer for cooperative close.requested_lease_msat(msat, optional): amount of liquidity the peer is requesting us to lease to them. only present ifoption_will_fundis negotiated.lease_blockheight_start(u32, optional): blockheight at which the lease period begins. only present ifrequested_lease_msatis present.node_blockheight(u32, optional): current blockheight of the node. used in conjunction with lease parameters. only present ifrequested_lease_msatis present.
π HOOK RETURN π
result(string) (one of"continue","reject"): indicates whether to accept or reject the channel proposal. returning"continue"allows the channel negotiation to proceed. returning"reject"aborts the channel opening. yes or no, pick one, no in-between. πerror_message(string, optional): error message sent to the peer when rejecting the channel. only valid ifresultis"reject".close_to(string, optional): Bitcoin address to which funds will be sent on cooperative close. must be valid for the current chain orlightningdwill exit with an error. β οΈ seriously.psbt(string, optional): Partially Signed Bitcoin Transaction contributing inputs and outputs for the funding transaction. used when the plugin contributes funds to the channel.our_funding_msat(msat, optional): amount we contribute to the channel funding. this amount must NOT be included in any outputs in the provided PSBT. change outputs must be included separately. π ββοΈ like, do not do that.
β¨ quick recap corner β¨ ifresultis present, andresultis"reject": -error_message(string, optional)
and that's the whole page, bestie β you're now legally required to go contribute some funds to a channel π«Ά
π this has been lightning-hook-openchannel2(7) from Core Lightning v26.06.9 β go forth and dual-fund, ily, mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: clightning 26.06.9
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms