← Back to Pull requests

contractcourt: recover settled AMP HTLCs on-chain #11492

Closed
unknown closed this pull request without merging on Nov 05, 2026 09:22 UTC
View on GitHub
unknown unknown commented on Nov 04, 2026 21:18 UTC
Author

Change Description

This change makes settled AMP child preimages available to the on-chain resolution path through a side-effect-free invoice-registry lookup.

The lookup is scoped by AMP set ID and child hash and returns a preimage only for a settled invoice HTLC. The channel arbitrator and incoming contest resolver use it when processing final-hop AMP HTLCs. Recorded spontaneous AMP and keysend replays are also routed through persisted invoice state before preprocessing intended for new HTLCs.

To keep the normal block-processing path lightweight, invoice lookups are deferred until an incoming HTLC is within its broadcast window. Lookup failures do not block unrelated HTLC actions and are retried on the next block.

Steps to Test

go test ./contractcourt
go test ./invoices

Both focused suites pass locally, including the PostgreSQL-backed invoice tests.

Pull Request Checklist

Testing

  • Your PR passes all CI checks.

  • Tests covering the positive and negative (error paths) are included.

  • Bug fixes contain tests triggering the bug to prevent regressions.
  • Code Style and Documentation

  • The change is not insubstantial.

  • The change obeys the code documentation and commenting guidelines, and lines wrap at 80.

  • Commits follow the Ideal Git Commit Structure.

  • Any new logging statements use an appropriate subsystem and logging level.

  • No new lncli commands are introduced.

  • A PR-specific release note fragment is included under # Bug Fixes.
  • Diff: 192 lines (+144 / -48) across 2 files Reviewer: Roasbeef Review duration: 723m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 192 lines diff across 2 files
    0.36
    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%
    60%
    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.315
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #11492"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 35.9% (MEDIUM) · Higher = larger blast radius
    35.9%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 14.2% · Safe to merge
    14.2%