Channel establishment v2 (dual funding) - #239
Draft
erickcestari wants to merge 16 commits into
Draft
erickcestari wants to merge 16 commits into
erickcestari wants to merge 16 commits into
Conversation
erickcestari
force-pushed
the
channel-establishment-v2
branch
from
September 8, 2026 19:50
7ab8dfb to
e18c1d1
Compare
Contributor
Author
|
This PR can be decomposed in multiple other smaller PRs if needed. |
erickcestari
force-pushed
the
channel-establishment-v2
branch
from
September 9, 2026 13:23
e18c1d1 to
ca525b5
Compare
erickcestari
force-pushed
the
channel-establishment-v2
branch
from
September 9, 2026 14:19
ca525b5 to
4fbd628
Compare
erickcestari
force-pushed
the
channel-establishment-v2
branch
3 times, most recently
from
September 9, 2026 19:07
d3e46f6 to
829a24b
Compare
erickcestari
marked this pull request as draft
September 11, 2026 13:42
BOLT 2 derives both the temporary_channel_id and the channel_id of a dual-funded channel from revocation basepoints rather than from the funding outpoint.
Channel establishment v2 needs the previous transaction bytes for tx_add_input and our own witnesses for tx_signatures, which the wallet can only produce as a partial signing of the shared transaction.
A dual-funded funding transaction holds whatever the program negotiated: no inputs, inputs the wallet cannot sign, a lock time in the future or an output that breaks a consensus rule. None of these is a harness failure. Classify sendrawtransaction rejections, and keep a policy-rejected transaction for mining later only if a block would accept it.
SharedTransaction accumulates the inputs and outputs both peers add and remove by serial_id and assembles the BOLT 2 shared transaction, with the initiator's fee computed per BOLT 3 Appendix G.
TxExchange drives a SharedTransaction from the messages sent and received, queuing unanswered sends so a program that sends several messages before reading a reply still settles which tx_complete concluded the exchange.
Negotiations are keyed by temporary_channel_id and addressable by the derived channel_id every later message carries.
BOLT 2 makes the two channel establishment flows mutually exclusive on one connection, so the v2 flow needs its own post-init snapshot that keeps option_dual_fund, and CLN and Eclair need to advertise it.
Each tx_add_input locks the coin it selects, so a program contributing several inputs needs several mature coinbase outputs.
The first half of the channel establishment v2 flow: build and send open_channel2, receive accept_channel2 and extract its fields, and derive the temporary_channel_id and channel_id BOLT 2 computes from the revocation basepoints. New variants are appended to Operation: it is postcard-encoded by declaration index, so inserting mid-enum would make existing corpus entries decode as different operations.
Contribute inputs and outputs to the shared transaction, remove them, send tx_complete and read the peer's replies, then rebuild the funding transaction from the negotiation. A receive reads only while the peer owes a reply, and building from the negotiation settles the owed replies first, so what is built is what the peer agreed to.
Exchange the initial commitment_signed over the negotiated funding transaction, then tx_signatures in the order BOLT 2 prescribes: the peer that contributed less signs first, ties broken by node_id. The peer's witnesses are applied when the funding transaction is broadcast, since our wallet cannot sign its inputs.
One linear script from open_channel2 through channel_ready, with every interactive tx send paired with a receive.
BOLT 2 makes the two channel establishment flows mutually exclusive on one connection, so a campaign only wants the generators its snapshot can act on. SMITE_IR_GENERATORS picks v1, v2 or all, and smitebot sets it from the scenario name.
erickcestari
force-pushed
the
channel-establishment-v2
branch
from
September 15, 2026 18:26
8f4fb9a to
32337dc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds fuzzing support for the BOLT 2 v2 channel establishment flow: open_channel2, interactive transaction construction, v2 commitment signatures and tx_signatures.
Protocol and transaction primitives
IR and generators
Scenarios
Depends on #222 , #221 and #240
For follow ups: