AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 59 Bitcoin

invoices: require complete payment collection

Public commit record

What the developer wrote

Authored by Olaoluwa Osuntokun

80/100 · Strong
invoices: require complete payment collection

In this commit, we distinguish failed released HTLCs from attempts
canceled before preimage release. Once every released HTLC has a final
outcome, an ordinary invoice is settled only if all were collected.
Otherwise we cancel it while retaining the amount actually received.
Persisting the failed state keeps this decision independent of outcome
order and restart.

Expose failed collection and the release decision through RPC. Preserve
the first settlement index when later duplicates finish. Backend,
recovery, replay and RPC regressions cover the persisted outcome
contract. AMP settlement is unchanged.

Signed-off-by: Olaoluwa Osuntokun <laolu32@gmail.com>
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit changes how LND handles multi-part Lightning payments when one part fails after the preimage was already released. Previously, the invoice could be marked as fully paid even if one shard was later reclaimed by the payer on-chain. Now the invoice is canceled when any released shard fails, while still keeping the funds that were successfully collected. This prevents a merchant from incorrectly believing they were paid in full and possibly shipping goods or services based on an invoice that ultimately did not fully settle.

Recommended action

Review the change for correctness in edge cases such as AMP invoices (explicitly excluded), overpayment scenarios, and interactions with hold invoices. Ensure RPC consumers handle the new `FAILED` HTLC state and `PreimageReleased` field appropriately. Consider whether any monitoring or alerting needs to flag partially-collected canceled invoices.

Security signals we found

01

Changes invoice settlement semantics for released-but-failed HTLCs

02

Adds new persisted HTLC state `HtlcStateFailed`

03

Prevents invoice from reaching `ContractSettled` when any released shard fails

04

Adds RPC exposure of `PreimageReleased` and `FAILED` HTLC state

05

Includes recovery/restart regression tests to prevent premature settlement

06

Updates replay logic to treat `HtlcStateFailed` like `HtlcStateCanceled`

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 10/25
Stealth signal 8/15
Affected reach 12/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.