lightningd: use inflight->locked_scid instead of db lookup when splice locked.
What changed, and why it matters
This change fixes how Core Lightning updates a channel's short identifier (SCID) after a 'splice' transaction is locked. Previously, the code looked up the transaction's location in the wallet database to compute the new SCID. Now it uses the SCID already recorded in the in-flight splice object. The change also refactors the update into smaller helper functions. The patch appears to be a correctness or robustness fix for splice handling, but the commit message does not frame it as a security issue.
Treat as a normal code-quality/correctness patch. Review whether the old db-lookup path could have been exploited to force channel closure or cause inconsistent state, but no immediate security response is indicated by the commit itself. If running a node, include this fix in regular updates.
Security signals we found
Change removes a database lookup from the splice lock-in path, reducing the chance of channel failure due to missing or inconsistent wallet state.
The previous code had an explicit 'Unrepresentable SCIDs cause channel failure' failure mode that is no longer exercised in this path.
The commit does not mention security, vulnerabilities, or a CVE.
No explicit bounds checks or input validation changes are present; the change is a refactor of existing logic.
The patch is small and localized to channel splice lock-in handling.
Evidence from the diff
The patch refactors depthcb_update_scid() in lightningd/channel_control.c by extracting change_scid() and scid_updated(). In handle_peer_splice_locked(), it replaces a wallet_transaction_locate() database lookup followed by depthcb_update_scid() with a direct call to change_scid(channel, *inflight->locked_scid). This means the SCID update path during splice lock-in no longer depends on the wallet having indexed the funding transaction’s block location. The old path could fail if the locator was missing or produced an ‘unrepresentable SCID’, causing the channel to fail. The new path uses the SCID that was already computed and stored when the splice was locked.
Changed components
lightningd/channel_control.cSplice lock-in handlingChannel SCID update pathWallet transaction locator usageInspect captured patch +29 / −21
diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c
index 560d11b6..9e1ab492 100644
--- a/lightningd/channel_control.c
+++ b/lightningd/channel_control.c
@@ -802,6 +802,31 @@ static void handle_splice_sending_sigs(struct lightningd *ld,
watch_splice_inflight(ld, inflight);
}
+static void scid_updated(struct channel *channel)
+{
+ if (channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL)
+ tell_connectd_scid(channel->peer->ld, *channel->scid, &channel->peer->id);
+
+ wallet_channel_save(channel->peer->ld->wallet, channel);
+}
+
+/* You must call scid_updated after this! */
+static void change_scid(struct channel *channel,
+ struct short_channel_id scid)
+{
+ struct short_channel_id old_scid = *channel->scid;
+
+ /* We freaked out if required when original was
+ * removed, so just update now */
+ log_info(channel->log, "Short channel id changed from %s->%s",
+ fmt_short_channel_id(tmpctx, *channel->scid),
+ fmt_short_channel_id(tmpctx, scid));
+ channel_set_scid(channel, &scid);
+ /* In case we broadcast it before (e.g. splice!) */
+ channel_add_old_scid(channel, old_scid);
+ channel_gossip_scid_changed(channel);
+}
+
bool depthcb_update_scid(struct channel *channel,
const struct bitcoin_outpoint *outpoint,
const struct txlocator *loc)
@@ -840,23 +865,10 @@ bool depthcb_update_scid(struct channel *channel,
lockin_has_completed(channel, false);
} else {
- struct short_channel_id old_scid = *channel->scid;
-
- /* We freaked out if required when original was
- * removed, so just update now */
- log_info(channel->log, "Short channel id changed from %s->%s",
- fmt_short_channel_id(tmpctx, *channel->scid),
- fmt_short_channel_id(tmpctx, scid));
- channel_set_scid(channel, &scid);
- /* In case we broadcast it before (e.g. splice!) */
- channel_add_old_scid(channel, old_scid);
- channel_gossip_scid_changed(channel);
+ change_scid(channel, scid);
}
- if (channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL)
- tell_connectd_scid(ld, *channel->scid, &channel->peer->id);
-
- wallet_channel_save(ld->wallet, channel);
+ scid_updated(channel);
return true;
}
@@ -1140,7 +1152,6 @@ static void handle_peer_splice_locked(struct channel *channel, const u8 *msg)
struct channel_inflight *inflight;
struct bitcoin_txid locked_txid;
struct txwatch *txw;
- struct txlocator *loc;
if (!fromwire_channeld_got_splice_locked(msg, &funding_sats,
&splice_amnt,
@@ -1185,11 +1196,8 @@ static void handle_peer_splice_locked(struct channel *channel, const u8 *msg)
wallet_channel_clear_inflights(channel->peer->ld->wallet, channel);
- loc = wallet_transaction_locate(tmpctx, channel->peer->ld->wallet,
- &inflight->funding->outpoint.txid);
- /* Unrepresentable SCIDs cause channel failure */
- if (!depthcb_update_scid(channel, &inflight->funding->outpoint, loc))
- return;
+ /* Update the scid and tell everyone */
+ change_scid(channel, *inflight->locked_scid);
/* That freed watchers in inflights: now watch funding tx */
channel_watch_funding(channel->peer->ld, channel);
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.