lightningd: use scriptpubkey watches not txid watches for inflights on closing.
What changed, and why it matters
This change adjusts how Core Lightning monitors 'inflight' channel funding transactions after a cooperative channel close. Previously it watched for a specific transaction ID; now it watches for any transaction output matching a script public key. The commit message frames this as a robustness improvement, not a security fix. There is no disclosed vulnerability or exploit scenario in the provided materials.
Treat as a normal robustness/correctness patch. Review whether the scriptPubKey watch correctly covers all inflight variants and whether total_funds and outpoint matching are validated. No urgent security action is indicated by the provided materials.
Security signals we found
Change from txid watch to scriptPubKey watch for inflight funding detection
Callback signature changed from depth-based to output-found-based
No explicit security relevance, CVE, or vulnerability description in commit
No vendor or researcher attribution for a security issue
Evidence from the diff
The patch in lightningd/peer_control.c replaces a txid-based watch (watch_txid with closed_inflight_depth_cb) with a scriptPubKey-based watch (watch_scriptpubkey with closed_inflight_splice_found) for channel inflights during closing. The new callback no longer returns a watch result; it is invoked when the splice funding script is found on-chain. This is intended to detect a confirmed inflight funding output after mutual close, even if the transaction ID differs (e.g., due to malleability or different transaction packaging). The commit does not describe a security bug, CVE, or attacker model.
Changed components
lightningd/peer_control.cChannel closing / mutual close handlingChannel inflight / splice funding watch logicInspect captured patch +14 / −12
diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c
index fdabbc70..ddcdb27e 100644
--- a/lightningd/peer_control.c
+++ b/lightningd/peer_control.c
@@ -330,22 +330,18 @@ static enum watch_result funding_spent(struct channel *channel,
const struct block *block);
/* We coop-closed channel: if another inflight confirms, force close */
-static enum watch_result closed_inflight_depth_cb(struct lightningd *ld,
- const struct bitcoin_txid *txid,
- const struct bitcoin_tx *tx,
- unsigned int depth,
- struct channel_inflight *inflight)
+static void closed_inflight_splice_found(struct lightningd *ld,
+ const struct bitcoin_tx *tx,
+ u32 outnum,
+ const struct txlocator *loc,
+ struct channel_inflight *inflight)
{
- if (depth == 0)
- return KEEP_WATCHING;
-
/* This is now the main tx. */
update_channel_from_inflight(ld, inflight->channel, inflight, false);
channel_fail_saw_onchain(inflight->channel,
REASON_UNKNOWN,
tx,
"Inflight tx confirmed after mutual close");
- return DELETE_WATCH;
}
void drop_to_chain(struct lightningd *ld, struct channel *channel,
@@ -490,9 +486,15 @@ void drop_to_chain(struct lightningd *ld, struct channel *channel,
&channel->funding)) {
continue;
}
- watch_txid(inflight, ld->topology,
- &inflight->funding->outpoint.txid,
- closed_inflight_depth_cb, inflight);
+ const u8 *funding_wscript = bitcoin_redeem_2of2(tmpctx,
+ &channel->local_funding_pubkey,
+ inflight->funding->splice_remote_funding);
+ watch_scriptpubkey(inflight, ld->topology,
+ take(scriptpubkey_p2wsh(NULL, funding_wscript)),
+ &inflight->funding->outpoint,
+ inflight->funding->total_funds,
+ closed_inflight_splice_found,
+ inflight);
}
}
}
Why this scored 42/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.