Skip to content

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

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

chainnotifier: surface re-org depth and Done events#283
ellemouton wants to merge 3 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 reversible ChainNotifier lifecycle added by
lightningnetwork/lnd#10943:

positive → reorg(depth) → positive → Done

Previously lndclient only exposed a payload-less re-org ping and had no
unambiguous finality event. In particular, stream completion alone could not
distinguish policy finality from transport teardown.

Changes

  • Add WithReOrgDepthChan(chan int32):
    • confirmation notifications deliver lnd's native re-org depth;
    • spend notifications deliver 0, because lnd does not currently track
      spend re-org depth.
  • Add WithDoneChan(chan struct{}) for explicit backend policy finality.
  • Keep the listener alive past the first positive event when any re-org/depth/
    Done channel is configured, while preserving the legacy first-positive-event
    behavior for callers which configure none of them.
  • Handle ConfEvent_Done and SpendEvent_Done, and stop cleanly after
    delivering the terminal event.
  • Document that delivery waits for each configured channel or context
    cancellation, so callers must drain every channel they configure.
  • Add scripted transport tests for confirmation and spend
    positive/reorg/positive/Done lifecycles, re-org depth mapping, spend depth
    0, terminal completion, and legacy behavior.

Dependency

This PR is blocked on lightningnetwork/lnd#10943
for the additive proto variants. Until that lands and is released, go.mod
temporarily replaces lnd with the exact reviewed PR head. The replace should be
removed when lndclient can bump to the released upstream version.

Validation

  • make build
  • go test ./...
  • go test -race ./...
  • golangci-lint run --new ./... — 0 issues

Temporarily replace lnd with the branch that adds reorg depth and Done
events to the ChainNotifier RPC. Include finality signaling for mature
historical registrations so this commit provides the complete server
behavior required by the following client change.

Replace the fork pin with a released upstream lnd version after the
server change lands and is tagged.
The ChainNotifier RPC now reports the reorg depth and emits an explicit
Done event at the reorg-safety depth. Expose both with
WithReOrgDepthChan and WithDoneChan options. Reorg depth is zero for
spend notifications because lnd does not track it.

Keep a listener alive past its first event when either option is set.
Deliver optional notifications without blocking the stream read loop
beyond the registration context.
@lightninglabs-deploy

Copy link
Copy Markdown

@Roasbeef: review reminder

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.

2 participants