Skip to content

Fix/claim for id amount validation - #1108

Open
yahia008 wants to merge 2 commits into
lightningdevkit:mainfrom
yahia008:fix/claim-for-id-amount-validation
Open

yahia008 wants to merge 2 commits into
lightningdevkit:mainfrom
yahia008:fix/claim-for-id-amount-validation

Conversation

@yahia008

Copy link
Copy Markdown

Summary

Fix claim_for_id amount validation by validating the requested claim amount against the amount observed in the corresponding PaymentClaimable event.

Previously, the claim flow could validate the amount using stored payment information that did not necessarily represent the amount that was actually claimable. This change makes the validation consistent with the observed PaymentClaimable event.

Changes

  • Validate claim_for_id against the amount from the observed PaymentClaimable event.
  • Update BOLT11 payment handling and payment-store logic to retain and use the required claimable amount information.
  • Add the necessary event data to support claim amount validation.
  • Add wallet-related updates required by the new claim flow.
  • Add integration tests covering the claim amount validation behavior.
  • Update CHANGELOG.md.

Testing

Added integration test coverage for the claim_for_id amount validation flow, including validation against the amount reported by the PaymentClaimable event.

Files Changed

  • src/event.rs
  • src/payment/bolt11.rs
  • src/payment/store.rs
  • src/wallet/mod.rs
  • tests/integration_tests_rust.rs
  • CHANGELOG.md

Closes #1091

…le event

Previously, `Bolt11Payment::claim_for_id`'s `claimable_amount_msat` check
compared the caller-supplied argument against `details.amount_msat`, which
for any payment received since the payment-ID refactor in v0.8-development
is itself derived from the same triggering event. This made the check
ineffective for well-behaved callers and silently permissive of mismatched
arguments across concurrent manual claims.

Store the amount reported by the triggering `PaymentClaimable` event on
`PaymentKind::Bolt11` and require `claim_for_id` callers to echo it back
exactly. The historic underpayment guard (net of any JIT-channel-opening
LSP fee) is preserved for payments serialized before the v0.8 refactor,
where `amount_msat` still reflects the originally requested invoice amount.

AI tooling (Claude Code) was used to help implement and test this change.
@ldk-reviews-bot

ldk-reviews-bot commented Sep 19, 2026

Copy link
Copy Markdown

I've assigned @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

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.

Clarify/fix amount validation in Bolt11Payment::claim_for_id

2 participants