lightningd: make dualopend's opening_depth_cb use depthcb_update_scid.
What changed, and why it matters
This is a small code cleanup in Core Lightning's dual-funding channel opener. It replaces a locally repeated block of code with a shared helper function that does the same job. There is no obvious security bug being fixed; the change is described by the author as not 'reinventing the wheel.'
No immediate security action required. Treat as routine maintenance. If reviewing for security, verify that `depthcb_update_scid()` handles the dual-open edge cases (e.g., scid changes, permanent failure on invalid scid, connectd notification for announced channels) identically to the removed code.
Security signals we found
Refactor only: code deduplication, no functional change claimed
No mention of vulnerability, CVE, bug, or security issue in commit message
Helper `depthcb_update_scid` already existed and was used by another opener path
Evidence from the diff
The commit refactors opening_depth_cb() in lightningd/dual_open_control.c to call the existing helper depthcb_update_scid() instead of inline logic that constructed a short_channel_id, annotated the txout, set/saved the channel’s scid, and notified connectd. The removed inline code and the helper appear functionally equivalent for the dual-open path. No new behavior is introduced and no vulnerability is mentioned.
Changed components
lightningd/dual_open_control.cdual-funding channel opening flowshort_channel_id update logicInspect captured patch +3 / −30
diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c
index bdf0fcf8..ed7f732a 100644
--- a/lightningd/dual_open_control.c
+++ b/lightningd/dual_open_control.c
@@ -1009,7 +1009,6 @@ static enum watch_result opening_depth_cb(struct lightningd *ld,
struct channel_inflight *inflight)
{
struct txlocator *loc;
- struct short_channel_id scid;
/* Usually, we're here because we're awaiting a lockin, but
* we could also mutual shutdown */
@@ -1022,36 +1021,10 @@ static enum watch_result opening_depth_cb(struct lightningd *ld,
/* FIXME: Don't do this until we're actually locked in! */
loc = wallet_transaction_locate(tmpctx, ld->wallet, txid);
- if (!mk_short_channel_id(&scid,
- loc->blkheight, loc->index,
- inflight->funding->outpoint.n)) {
- channel_fail_permanent(inflight->channel,
- REASON_LOCAL,
- "Invalid funding scid %u:%u:%u",
- loc->blkheight, loc->index,
- inflight->funding->outpoint.n);
+ if (!depthcb_update_scid(inflight->channel,
+ &inflight->funding->outpoint,
+ loc))
return DELETE_WATCH;
- }
-
- if (!inflight->channel->scid) {
- wallet_annotate_txout(ld->wallet, &inflight->funding->outpoint,
- TX_CHANNEL_FUNDING, inflight->channel->dbid);
- channel_set_scid(inflight->channel, &scid);
- wallet_channel_save(ld->wallet, inflight->channel);
- } else if (!short_channel_id_eq(*inflight->channel->scid, scid)) {
- /* We freaked out if required when original was
- * removed, so just update now */
- log_info(inflight->channel->log, "Short channel id changed from %s->%s",
- fmt_short_channel_id(tmpctx, *inflight->channel->scid),
- fmt_short_channel_id(tmpctx, scid));
- channel_set_scid(inflight->channel, &scid);
- wallet_channel_save(ld->wallet, inflight->channel);
- }
-
- /* Tell connectd it can forward onion messages via this scid (ok if redundant!) */
- if (inflight->channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL)
- tell_connectd_scid(ld, *inflight->channel->scid,
- &inflight->channel->peer->id);
if (depth >= inflight->channel->minimum_depth)
update_channel_from_inflight(ld, inflight->channel, inflight,
Why this scored 20/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.