invoices: settle after complete HTLC collection #11555
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 461 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.367
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #11555"
general
weight: 0.35
Roasbeef
Summary
Keep ordinary MPP, keysend and hold invoices pending until their released
payment HTLCs have final outcomes. Mark an invoice settled only after the
complete payment has been collected off chain or through confirmed on-chain
claims. A full payment can be accepted and its preimage released while
collection is still outstanding. This keeps merchants from treating that
release as final receipt, including through disconnects, restarts and force
closes.
Change Description
PENDING_SETTLEinvoice and HTLC states. Wait for all released paymentHTLCs to finish. If any fails, cancel the invoice while preserving the
collected amount and payment history. Cancellation does not refund collected
shards.
Recorded outcomes override channel inference. Untrusted or unresolved
channel state leaves the HTLC pending. Persist on-chain outcomes without
requiring optional off-chain outcome history.
Defer settlement indexes until final collection, preserve an existing
settlement index when duplicate HTLCs finish, and retain released ordinary
invoice history during startup cleanup and canceled-invoice deletion, even
when every released HTLC failed.
FAILEDoutcomes and an ordinaryinvoice
preimage_releasedflag through RPC. Keep AMP settlement finalityunchanged.
Regression coverage includes accounting and recovery on KV, SQLite and
PostgreSQL, the MPP restart scenario, and existing on-chain resolution controls.
Notes
Invoice finality consumes existing channel and resolver outcomes. Incoming
resolver admission, preimage lookup and expiry behavior follow the existing
implementation on master.
AMP settlement finality and AMP-specific mixed-outcome accounting are deferred.
The small closed-AMP-set admission guard protects ordinary MPP payments on the
same link; it does not extend AMP settlement finality.
Existing
OPENandACCEPTEDinvoices can continue through the upgrade.Legacy
SETTLEDpayments retain their old state; their finality is notretroactively reconciled and missing historical outcomes are not recreated.
Clients must handle
PENDING_SETTLE, HTLCFAILEDand provisional aggregateamounts. An ordinary
CANCELEDinvoice can have released its preimage; checkpreimage_releasedand final HTLC outcomes before deciding on counterpartrefunds or hash reuse. The flag records lnd's release decision, not proof of
peer receipt or global secret privacy when false. It is not supported for AMP.
Late duplicate HTLCs can remain pending beneath a settled parent.
Before downgrading, inspect all invoice pages and their HTLCs across every
parent state, and let pending work finalize.
--pending_onlymisses pendingchildren beneath settled parents. Downgrade is unsupported once a released
failure has been stored as
HtlcStateFailed, exposed asFAILEDthrough RPC.Include failed children in the inspection; a terminal parent alone does not
establish downgrade safety.
Related to #7463.