← Back to Pull requests

invoices: revalidate accepted htlc expiries at set completion #11551

Closed
unknown closed this pull request without merging on Nov 11, 2026 07:48 UTC
View on GitHub
unknown unknown commented on Nov 11, 2026 01:49 UTC
Author

Change Description

Revalidate the expiry of every accepted HTLC in an MPP or AMP set at the
moment the set becomes complete.

Each shard's expiry is checked against the final CLTV requirements when it is
first accepted. While the set waits for its remaining shards, the chain
advances, so an earlier shard may no longer satisfy those requirements by the
time the final shard arrives. Previously, only the arriving shard was checked
at that point.

When an incoming HTLC would complete a set, updateMpp now also checks every
previously accepted HTLC in that set against both the registry's final CLTV
reject delta and the invoice's final CLTV delta at the current height. If any
of them no longer qualifies, the accepted HTLCs of that set are canceled, the
completing HTLC is failed with the new set-level
ResultHtlcSetExpiryTooSoon, and the invoice remains open so the payer can
retry.

For AMP invoices only the set identified by the incoming set ID is evaluated;
other sets on a reusable AMP invoice are unaffected. The existing
set-cancellation logic used for AMP reconstruction failures is factored into a
shared helper.

SubscribeHtlcEvents maps the new result to the existing
INVOICE_EXPIRY_TOO_SOON failure detail.

Steps to Test

go test ./invoices ./lnrpc/routerrpc ./contractcourt -count=1

All pass locally on this branch.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.

  • Tests covering positive and negative paths are included.

  • Bug-fix regression tests are included.
  • Code Style and Documentation

  • The change is substantial and focused.

  • Code and comments follow the project guidelines.

  • Commits follow the ideal commit structure.

  • No new logging subsystem or lncli command is introduced.

  • A PR-specific release-note fragment is included under # Bug Fixes.
  • Diff: 233 lines (+174 / -59) across 2 files Reviewer: litbot-9000 Review duration: 358m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 233 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.326
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11551"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37.1% (MEDIUM) · Higher = larger blast radius
    37.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16% · Safe to merge
    16%