Skip to content

Onchain claim replay fixes#4583

Draft
joostjager wants to merge 5 commits intolightningdevkit:mainfrom
joostjager:onchain-claim-replay-fixes
Draft

Onchain claim replay fixes#4583
joostjager wants to merge 5 commits intolightningdevkit:mainfrom
joostjager:onchain-claim-replay-fixes

Conversation

@joostjager
Copy link
Copy Markdown
Contributor

No description provided.

Have ChannelMonitor hand singular ClaimRequests to OnchainTxHandler.

Convert them to PackageTemplates only after duplicate filtering.

This makes the single-outpoint invariant explicit at that boundary.

AI tools were used in preparing this commit.
A replayed holder HTLC claim may arrive as a single-outpoint
request after earlier requests were merged into a delayed package.
Check whether an existing delayed package already covers the new
request instead of requiring exact outpoint-set equality.

Add focused OnchainTxHandler coverage and a ChannelMonitor regression
through claim_funds for both current anchor variants.

AI tools were used in preparing this commit.
When a transaction spends one outpoint from a delayed package, the
split outpoint is tracked as a ContentiousOutpoint while it awaits
anti-reorg confirmation. Reject replayed claim requests for those
pending-spent outpoints so they are not added back before the spend
either matures or reorgs out.

Add an OnchainTxHandler regression that replays a holder claim during
that pending-spent window and verifies reorg resurrection still works.

AI tools were used in preparing this commit.
Remember claim outpoints after their spending transactions reach the
anti-reorg delay. Later claim requests for these outputs must be
ignored even after normal claim tracking has been cleaned up.

Prune stale delayed packages for finalized spent outpoints, and add an
OnchainTxHandler regression covering replay after cleanup plus set
serialization.

AI tools were used in preparing this commit.
Hash HTLC claim outpoints in canonical order so the same logical HTLC
set produces the same ClaimId regardless of descriptor order.

Add a unit test covering reversed descriptor order.

AI tools were used in preparing this commit.
@ldk-reviews-bot
Copy link
Copy Markdown

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 99.54023% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.20%. Comparing base (42e198c) to head (dca8cfb).

Files with missing lines Patch % Lines
lightning/src/chain/onchaintx.rs 99.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4583      +/-   ##
==========================================
+ Coverage   87.15%   87.20%   +0.05%     
==========================================
  Files         161      161              
  Lines      109251   109614     +363     
  Branches   109251   109614     +363     
==========================================
+ Hits        95215    95589     +374     
+ Misses      11560    11551       -9     
+ Partials     2476     2474       -2     
Flag Coverage Δ
fuzzing-fake-hashes 31.17% <54.90%> (+0.02%) ⬆️
fuzzing-real-hashes 22.91% <4.90%> (-0.01%) ⬇️
tests 86.27% <99.54%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joostjager joostjager self-assigned this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants