wallet: let wallet_inflight_save update i_sent_sigs
What changed, and why it matters
This commit fixes a bug where a flag called i_sent_sigs was not being saved to the database when updating a channel funding inflight. The flag tracks whether a node has already sent signatures for a funding transaction. Because the flag was not persisted, a node could forget it had sent signatures after a restart, which could lead to incorrect behavior in upcoming code that relies on this flag. The fix is a one-line SQL update change to also write the i_sent_sigs column.
Treat as a low-to-moderate correctness fix. Review the upcoming code that relies on i_sent_sigs to confirm whether the unpersisted flag could have led to a security-relevant failure (e.g., signature replay, channel state inconsistency, or fund loss). Backport if the dependent code is already in release branches. No immediate emergency response is indicated by the diff alone.
Security signals we found
State-persistence bug in a Bitcoin/Lightning funding workflow
Flag controls whether signatures for a channel funding transaction were already sent
Incorrect flag after restart could cause double-send, missed send, or protocol desynchronization
Fix is small and targeted, but commit message implies future logic depends on it
Evidence from the diff
wallet_inflight_save() in wallet/wallet.c previously updated only funding_psbt, last_tx, last_sig, and locked_scid in the channel_funding_inflights table. The i_sent_sigs field was passed to the function but never included in the UPDATE statement, so any runtime change to the flag was lost on the next DB write. The patch adds i_sent_sigs=? to the SQL UPDATE and adjusts the parameter binding accordingly. The commit message states the codebase is about to rely on this flag, making persistence necessary.
Changed components
wallet/wallet.cwallet_inflight_save()channel_funding_inflights tablei_sent_sigs fieldInspect captured patch +2 / −3
### wallet/wallet.c
@@ -1590,9 +1590,8 @@ void wallet_inflight_save(struct wallet *w,
struct channel_inflight *inflight)
{
struct db_stmt *stmt;
- /* The *only* thing you can update on an
- * inflight is the funding PSBT (to add sigs)
- * and the last_tx/last_sig or locked_scid if this is for a splice */
+ /* Update inflight PSBT (to add sigs), last_tx/last_sig,
+ * locked_scid, and i_sent_sigs. */
stmt = db_prepare_v2(w->db,
SQL("UPDATE channel_funding_inflights SET"
" funding_psbt=?"Why this scored 30/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.