Skip to content

tx-sync: Re-register watched outputs after spend has been reorged out of chain #2734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tnull opened this issue Nov 14, 2023 · 3 comments · Fixed by #2946
Closed

tx-sync: Re-register watched outputs after spend has been reorged out of chain #2734

tnull opened this issue Nov 14, 2023 · 3 comments · Fixed by #2946
Assignees
Milestone

Comments

@tnull
Copy link
Contributor

tnull commented Nov 14, 2023

Currently, in lightning-transaction-sync, we'd remove an output from our list of watched_outputs once we see its spend confirmed on-chain. If now a reorg happens we'd gladly unconfirm the spending tx, however, we would currently not re-add the spent output to be watched.

In order to fix this we could consider to

  1. Keep additional tracking state around that would allow us to match any unconfirmed txid to the originally registered WatchedOutput and then simply re-add it to watched_outputs or
  2. Take a reference to ChainMonitor/ChannelMonitors and call load_outputs_to_watch on the start of each sync round. This would allow us to always retrieve the newest items to watch on a per-round basis. However, this would also exclude us from using lightning-transaction-sync with any objects besides the core LDK ones. (we could however also consider making a method similar to load_outputs_to_watch to Filter to accommodate for this) or
  3. Have ChannelMonitors re-register the affected outputs to watch once we inform them about spending transaction unconfirmation.

I'm not the biggest fan of 2), but considering 1)/3).

@tnull tnull added this to the 0.0.119 milestone Nov 14, 2023
@tnull tnull self-assigned this Nov 14, 2023
@wpaulino
Copy link
Contributor

Would keeping the WatchedOutputs around until the spending transaction reaches 6 confirmations (ANTI_REORG_DELAY) help?

@tnull
Copy link
Contributor Author

tnull commented Nov 21, 2023

Would keeping the WatchedOutputs around until the spending transaction reaches 6 confirmations (ANTI_REORG_DELAY) help?

Yeah, I think that would be option 1. above, just that we would prune the state after 6conf?

@TheBlueMatt
Copy link
Collaborator

Slipping since we just ran out of time.

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 a pull request may close this issue.

3 participants