Description
Had some questions about the validation of claimable_amount_msat in Bolt11Payment while reviewing lightningdevkit/ldk-server#258, below is a codex-generated issue:
The amount check in claim_for_id was originally intentional:
if claimable_amount_msat < invoice_amount_msat.saturating_sub(skimmed_fee_msat)
In PR #308 (#308 (comment)), claimable_amount_msat represented the actual event amount, while the stored amount represented the invoice expectation. This correctly rejected underpayments and allowed overpayments.
However, PR #948 (#948) changed new manual-payment records to derive details.amount_msat from the PaymentClaimable event itself. After subtracting the skimmed fee, the stored value therefore equals the event_s claimable amount, making the check ineffective for normal calls and confusing when the supplied argument differs.
Simply flipping the inequality is insufficient because migrated v0.7 records retain the original semantics.
We should:
- Define whether the argument is the event amount or the caller_s minimum expected amount.
- Preserve requested and actual claimable amounts separately if necessary.
- Add underpayment, overpayment, JIT-fee, mismatched-argument, and migrated-record tests.
Activity
yahia008 commentedon Sep 19, 2026
I'd like to take this one on if it's still open.
Root cause, restated
details.amount_msat is overloaded with two different meanings depending on how the PaymentDetails record came to exist:
PaymentId#948): there's no locally-created invoice, so there's nothing independent to promise an amount. amount_msat is populated from the same event the caller then echoes back into claim_for_id, so the check degenerates to comparing a number against itself.Flipping the inequality doesn't work because pre-#948 and migrated v0.7 records only ever have the first meaning — there's no per-record marker distinguishing the two cases today.
Proposed fix
Test plan: underpayment/overpayment against a known invoice, JIT-fee-skimmed payment, mismatched-argument on an unknown-payment record, correctly-echoed amount on an unknown-payment record, and a decoded pre-#948/v0.7 record — one test per case.
Could someone assign this to me? Happy to open a draft PR early for feedback on the approach before going further.
Simplify manual BOLT11 payment claims
Simplify manual BOLT11 payment claims
Simplify manual BOLT11 payment claims
Simplify manual BOLT11 payment claims