lightningd: allow openchannel_abort up until we send tx_signatures
What changed, and why it matters
This change loosens when a user can cancel an in-progress Lightning channel opening. Previously, the software blocked cancellation once both sides had exchanged commitment signatures, even though the protocol rules allow cancellation until the opener has actually sent their transaction signatures. The fix lets users abort later in the process and adds a test confirming the correct behavior. It is a protocol-correctness and usability improvement rather than a fix for an active attack.
Review as normal protocol-correctness change. Verify that the cleanup path after aborting with commitments secured properly forgets the channel on the aborting side and does not leave stale signatures or PSBT data that could be reused. Run the new test and existing dual-funding tests.
Security signals we found
Protocol state machine relaxation: abort allowed closer to funding broadcast
BOLT #2 compliance: abort permitted until tx_signatures sent
New regression test for abort-after-accepter-signatures edge case
Potential concern: aborting after commitments are secured changes cleanup path; must ensure no double-spend or state inconsistency
Evidence from the diff
The commit modifies json_openchannel_abort in lightningd/dual_open_control.c. The old code rejected abort if the channel had no open_attempt, which happened after commitments were exchanged. The new code checks channel_funding_sigs_sent() and only rejects abort if this node has already sent tx_signatures. It also creates a new open_attempt when needed so the abort command can be parked and receive the final outcome. A new test verifies the opener can abort after the accepter has sent tx_signatures, and that the accepter remembers the channel per BOLT #2 rules.
Changed components
lightningd/dual_open_control.cJSON-RPC openchannel_abortv2 channel opening (dual funding) state machineInspect captured patch +45 / −5
### lightningd/dual_open_control.c
@@ -2430,14 +2430,16 @@ json_openchannel_abort(struct command *cmd,
if (list_empty(&channel->inflights))
return command_fail(cmd, FUNDING_STATE_INVALID,
"Channel open not in progress");
- return command_fail(cmd, FUNDING_STATE_INVALID,
- "Sigs already exchanged, can't cancel");
- }
-
- if (channel->open_attempt->cmd)
+ /* Commitments may already be stored; we can still abort
+ * until we have sent tx_signatures. */
+ if (channel_funding_sigs_sent(channel))
+ return command_fail(cmd, FUNDING_STATE_INVALID,
+ "Already sent sigs, can't cancel");
+ } else if (channel->open_attempt->cmd) {
return command_fail(cmd, FUNDING_STATE_INVALID,
"Another openchannel command"
" is in progress");
+ }
if (channel->openchannel_signed_cmd)
return command_fail(cmd, FUNDING_STATE_INVALID,
@@ -2446,6 +2448,12 @@ json_openchannel_abort(struct command *cmd,
if (command_check_only(cmd))
return command_check_done(cmd);
+ /* If commitments were already exchanged there's no open_attempt;
+ * make one to park the command on, so we respond with the actual
+ * outcome once the abort completes. */
+ if (!channel->open_attempt)
+ channel->open_attempt = new_channel_open_attempt(channel);
+
/* Mark it as aborted so when we clean-up, we send the
* correct response */
channel->open_attempt->aborted = true;
### tests/test_opening.py
@@ -498,6 +498,38 @@ def test_v2_fail_second(node_factory, bitcoind):
assert len(l1.rpc.listpeerchannels(l2.info['id'])['channels']) == 2
+@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
+@pytest.mark.openchannel('v2')
+def test_v2_abort_after_accepter_tx_sigs(node_factory, bitcoind):
+ """Opener aborts after the accepter has sent tx_signatures.
+
+ Per the BOLT #2 tx_abort receiver rule, the accepter must not forget
+ the channel until an input of the negotiated funding transaction is
+ spent.
+ """
+ l1, l2 = node_factory.get_nodes(2)
+
+ l1.fundwallet(10**6)
+ l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
+
+ amount = 100000
+ psbt = l1.rpc.fundpsbt(amount, '253perkw', 250, reserve=0)['psbt']
+ start = l1.rpc.openchannel_init(l2.info['id'], amount, psbt)
+ update = l1.rpc.openchannel_update(start['channel_id'], start['psbt'])
+ assert update['commitments_secured']
+
+ l2.daemon.wait_for_log(r'peer_out WIRE_TX_SIGNATURES')
+
+ # Legal for the opener: they have not sent tx_signatures yet.
+ l1.rpc.openchannel_abort(start['channel_id'])
+
+ l2.daemon.wait_for_log(r'tx-abort rcvd after we sent tx-sigs'
+ r'|Already sent tx_signatures, remembering channel')
+
+ chans = l2.rpc.listpeerchannels(l1.info['id'])['channels']
+ assert any(c['channel_id'] == start['channel_id'] for c in chans)
+
+
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
@pytest.mark.openchannel('v2')
def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.