Skip to content
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

tapdb: add anchor point to SetSpent, remove LIMIT 1 #984

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Jun 28, 2024

Discovered while adding more assertions in the litd custom channel itests.

This commit fixes two things:

  • Because we could have multiple assets with the same script key, but in different anchor transactions, we also need to include the anchor outpoint of the input we want to mark as spent. Otherwise a duplicate script key (e.g. a second TAP channel funding script key, which is identical for every channel as it's just OP_TRUE) couldn't be set as spent anymore.
  • Remove the TODO and LIMIT 1 workaround, since we now have a proper unique index preventing duplicate script keys WITHIN THE SAME ANCHOR OUTPUT.

This commit fixes two things:
 - Because we could have multiple assets with the same script key, but
   in different anchor transactions, we also need to include the anchor
   outpoint of the input we want to mark as spent. Otherwise a duplicate
   script key (e.g. second TAP channel funding script key) couldn't be
   set as spent anymore.
 - Remove the TODO and LIMIT 1 workaround, since we now have a proper
   unique index preventing duplicate script keys _WITHIN THE SAME
   ANCHOR OUTPUT_.
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 💃🏾

@jharveyb jharveyb self-requested a review July 1, 2024 21:27
Copy link
Contributor

@jharveyb jharveyb left a comment

Choose a reason for hiding this comment

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

Also LGTM 👍🏽

Scoping by outpoint is probably going to useful in other spots where script keys can be duplicated / reused.

@Roasbeef Roasbeef merged commit 88012a5 into main Jul 1, 2024
16 checks passed
@guggero guggero deleted the set-spent-duplicate-key branch July 8, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants