Skip to content

lightningd: track funding-tx broadcast visibility, gate zero-conf forwarding on it - #9437

Draft
Andezion wants to merge 2 commits into
ElementsProject:masterfrom
Andezion:funding-visibility-status
Draft

lightningd: track funding-tx broadcast visibility, gate zero-conf forwarding on it#9437
Andezion wants to merge 2 commits into
ElementsProject:masterfrom
Andezion:funding-visibility-status

Conversation

@Andezion

Copy link
Copy Markdown
Collaborator

Inside

Zero-conf channels (option_zeroconf) become usable for HTLC forwarding immediately, with zero verification that the funding transaction was ever broadcast to the network - peer_start_channeld() sends channeld an artificial 0-depth confirmation event, unconditionally, using a zeroed-out fake txid, regardless of whether the real funding tx has ever been observed. There was no persisted state anywhere distinguishing "never broadcast" from "broadcast, unconfirmed" from "confirmed."

This PR adds:

  1. common/funding_tx_status.h: a new persisted DB enum (UNKNOWN / MEMPOOL / CONFIRMED), stored on both channels and channel_funding_inflights (replacing the in-memory-only channel_inflight.tx_broadcast)
  2. Gating in peer_start_channeld(): the artificial zero-conf depth event is only sent once funding_tx_status >= MEMPOOL, using the real funding txid instead of a zeroed-out one
  3. A lightweight poll in chaintopology.c (every 5s) so the non-broadcasting side of a zero-conf channel also detects funding-tx visibility via gettxout (mempool or confirmed), not just the side that called sendrawtransaction
  4. A new FORWARD_FAIL_FUNDING_NOT_BROADCAST forward-failure reason, raised instead of unknown_next_peer when a forward fails specifically because the outgoing zero-conf channel's funding was never observed broadcast
  5. A migration backfilling already-running channels (state past the pre-lockin dance) to CONFIRMED, so this doesn't retroactively block channels already in production use

Important

26.09 FREEZE August 5th: Non-bugfix PRs not ready by this date will wait for 26.12.

RC1 is scheduled on August 17th

The final release is scheduled for September 7th.

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.
  • Important All PRs must consider how to reverse any persistent changes for tools/lightning-downgrade

Changelog-Fixed: lightningd: zero-conf channels no longer accept HTLC forwards before their funding transaction has actually been observed broadcast, failed forwards over such a channel now report funding_not_broadcast instead of a generic reason

@Andezion Andezion self-assigned this Aug 18, 2026
@Andezion
Andezion force-pushed the funding-visibility-status branch from 0678f80 to bd22f4a Compare August 18, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant