Skip to content

Prune lockedtime packages when inputs are spent #3860

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

whfuyn
Copy link
Contributor

@whfuyn whfuyn commented Jun 13, 2025

We have to prune lockedtime packages when their inputs are spent, otherwise the notification of the watched outputs might be missed. This can lead to lockedtime packages with spent inputs being added back to the pending claim requests in the future, and never being cleaned up.

Resolves: #3859

We have to prune lockedtime packages when their inputs are spent,
otherwise the notification of the watched outputs might be missed. This
can lead to lockedtime packages with spent inputs being added back to
the pending claim requests in the future, and never being cleaned up.

Resolves: lightningdevkit#3859
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jun 13, 2025

👋 I see @jkczyz was un-assigned.
If you'd like another reviewer assignemnt, please click here.

@ldk-reviews-bot ldk-reviews-bot requested a review from jkczyz June 13, 2025 17:29
Copy link
Contributor

@wpaulino wpaulino left a comment

Choose a reason for hiding this comment

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

Thanks! This could really use some test coverage exercising the bug you ran into, and also handling the reorg case where the locktimed package gets restored.

// Also remove/split any locktimed packages whose inputs have been spent by this transaction.
self.locktimed_packages.retain(|_, packages|{
packages.retain_mut(|package| {
if let Some(p) = package.split_package(&inp.previous_output) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we only aggregate locktimed_packages with the same locktime, I think the original package would still have the same one, otherwise we'd have to reinsert it. Let's add a debug_assert that it's true.

@wpaulino wpaulino removed the request for review from jkczyz June 13, 2025 17:52
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.

HTLCs claimed by remote remain in pending claim requests
3 participants