Skip to content

chainnotifier: surface re-org depth and Done events#283

Open
ellemouton wants to merge 2 commits into
lightninglabs:masterfrom
ellemouton:ellemouton/chainntfn-reorg-depth-done
Open

chainnotifier: surface re-org depth and Done events#283
ellemouton wants to merge 2 commits into
lightninglabs:masterfrom
ellemouton:ellemouton/chainntfn-reorg-depth-done

Conversation

@ellemouton

@ellemouton ellemouton commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Surfaces the ChainNotifier re-org depth and the terminal Done (past
re-org-safety-depth) signal that lnd's gRPC stream now carries, via
lightningnetwork/lnd#10943.

Previously the adapter received a payload-less re-org ping and had no way to
observe finality (lnd closed the stream instead of sending an explicit event),
so ConfRegistration.Done was allocated but never written over this transport.

Changes

  • New functional options on RegisterConfirmationsNtfn / RegisterSpendNtfn:
    • WithReOrgDepthChan(chan int32) — delivers the re-org depth (0 for spends,
      which lnd does not track a depth for).
    • WithDoneChan(chan struct{}) — delivers the terminal Done signal.
    • Setting either (like WithReOrgChan) keeps the listener alive past the
      first event.
  • Handle the new ConfEvent_Done / SpendEvent_Done proto variants and read
    Reorg.Depth. A small generic deliver() helper fans each signal out to the
    optional caller channel without blocking the read loop beyond the
    registration context.

Notes

@ellemouton ellemouton marked this pull request as ready for review June 30, 2026 21:11
@ellemouton ellemouton force-pushed the ellemouton/chainntfn-reorg-depth-done branch from 299ff09 to a68fd53 Compare June 30, 2026 21:11
Temporary replace onto the lnd branch that adds the reorg depth and Done
events to the ChainNotifier proto (lightningnetwork/lnd#10943). Lands
before the code change so each commit builds. Drop this once that lnd
change is merged and tagged.
The ChainNotifier gRPC stream now carries the re-org depth on the Reorg
message and an explicit Done event at re-org safety depth. Expose both
through new functional options:

  - WithReOrgDepthChan delivers the re-org depth (0 for spends, which
    lnd does not track a depth for).
  - WithDoneChan delivers the terminal Done signal, letting callers
    distinguish reaching re-org safety depth from an unrelated stream
    teardown.

Setting either option (like WithReOrgChan) keeps the listener alive past
the first event. A small generic deliver() helper fans each signal out
to the optional caller channel without blocking the read loop beyond the
registration context.
@ellemouton ellemouton force-pushed the ellemouton/chainntfn-reorg-depth-done branch from a68fd53 to a3baa8d Compare July 1, 2026 21:32
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