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

multi: defer ordinary invoice settlement

Public commit record

What the developer wrote

Authored by yyforyongyu

68/100 · Adequate
multi: defer ordinary invoice settlement

Release ordinary, MPP and hold preimages into PENDING_SETTLE, then
assign final credit and the settlement index through recorded HTLC
outcomes. Recover pending children beneath terminal parents without
allocating another index; let recorded failures override channel
inference and retry channel-only completion while running.

Switch ordinary replay, preimage lookup, expiry, notifications and RPC
projection together. Preserve the parent’s AMP settlement mechanisms and
controls; AMP finality remains deferred. Reuse existing integration
invoice waits rather than adding another harness API.

Cover partial credit, all-failed cancellation, recovery races, transient
writes and pending RPC timestamps using the existing backend fixtures.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit changes how LND marks invoices as 'paid.' Previously, when a payment arrived, LND immediately marked the invoice as fully settled. Now, for ordinary, multi-part, and hold invoices, LND first releases the payment preimage to the peer but keeps the invoice in a new 'pending settle' state. It only flips the invoice to 'settled' once the underlying HTLC outcomes are recorded as final. AMP invoices keep their old behavior for now. The change is designed to prevent double-counting, incorrect settlement indexes, and premature credit allocation if a payment later fails or is replayed.

Recommended action

Treat this as a behavior-hardening change rather than an active vulnerability fix. Reviewers should verify that all code paths that previously assumed immediate settlement now handle ContractPendingSettle correctly, especially around RPC subscriptions, accounting, and any external integrations that poll invoice state. Run the updated integration tests and confirm that the new FinalizeHTLCsUpdate path is exercised on restart/replay paths.

Security signals we found

01

New intermediate state prevents premature settlement-index allocation and credit finalization before HTLC finality

02

Replayed HTLCs in HtlcStatePendingSettle are now re-settled so a peer that already learned the preimage is not left without resolution

03

Canceling an invoice is blocked once the preimage has been released (ContractPendingSettle), reducing risk of inconsistent state

04

RPC projection hides ResolveTime for pending-settle HTLCs, avoiding misleading final timestamps

05

Hold invoice settlement now also uses pending-settle semantics, matching ordinary/MPP behavior

Risk score

Why this scored 61/100

Our methodology →
Potential impact 18/30
Exploitability 12/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.