Skip to content

Conversation

starius
Copy link
Contributor

@starius starius commented Jul 8, 2025

The corresponding API of LND already supports notifying the caller about a reorg. I reused NotifierOption's used for RegisterConfirmationsNtfn already to pass a channel notified upon a reorg affecting a reported confirmation.

Pull Request Checklist

  • PR is opened against correct version branch.
  • Version compatibility matrix in the README and minimal required version
    in lnd_services.go are updated.
  • Update macaroon_recipes.go if your PR adds a new method that is called
    differently than the RPC method it invokes.

starius added a commit to starius/loop that referenced this pull request Jul 9, 2025
Include lightninglabs/lndclient#233
RegisterSpendNtfn: support reorg channel

TODO: remove replace in go.mod
starius added a commit to starius/loop that referenced this pull request Jul 9, 2025
Include lightninglabs/lndclient#233
RegisterSpendNtfn: support reorg channel

TODO: remove replace in go.mod
Copy link
Contributor

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feature!

return
}

opts.ReOrgChan <- struct{}{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also listen on ctx.Done() here, see RegisterConfirmationsNtfn.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the same note, I think we should also do this before writing to the errChan (and fix conf notifier too).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated sending to ReOrgChan (listening for ctx.Done()).

errChan is used at most one time and it is buffered, has capacity 1.

But I think that we should listen for ctx.Done() when sending to spendChan and confChan. These channels have capacity 1, but can be used multiple times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point! Agree!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this in another commit.

The corresponding API of LND already supports notifying the caller about
a reorg. I reused NotifierOption's used for RegisterConfirmationsNtfn already
to pass a channel notified upon a reorg affecting a reported confirmation.
Avoid a deadlock in case the caller doesn't consume notifications about spending
or confirmations after cancelling a call.
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

@guggero guggero merged commit b14415f into lightninglabs:master Jul 9, 2025
1 check passed
@guggero
Copy link
Contributor

guggero commented Jul 9, 2025

Pushed a new tag: v0.19.0-12

starius added a commit to starius/loop that referenced this pull request Jul 9, 2025
Include lightninglabs/lndclient#233
RegisterSpendNtfn: support reorg channel
starius added a commit to starius/loop that referenced this pull request Jul 10, 2025
Include lightninglabs/lndclient#233
RegisterSpendNtfn: support reorg channel
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.

3 participants