← Back to Pull requests

htlcswitch+invoices: tighten final-hop CLTV validation #10927

Closed
unknown closed this pull request without merging on Jun 26, 2026 08:59 UTC
View on GitHub
unknown unknown commented on Jun 25, 2026 19:38 UTC
Author

Change Description

This PR tightens validation of the CLTV expiry on HTLCs at the final hop and
makes the related policy bounds explicit and validated at config time.

Final-hop CLTV handling is currently permissive: an HTLC can specify a final
CLTV expiry far beyond any reasonable receive policy, and the values that bound
this behaviour aren't checked when set. Accepting an excessively large final
CLTV delta is undesirable — a single HTLC can tie up channel liquidity for a
very long time (a slow-jamming / liquidity-lockup concern), and there is no
legitimate reason for a final hop to require an expiry that far out. We already
cap CLTV deltas on the forwarding path; this brings the final hop in line and
catches misconfiguration early.

Changes

  • htlcswitch + invoices: validate the final-hop CLTV expiry. A final HTLC

  • whose expiry falls outside the node's receive policy is failed back with
    incorrect_or_unknown_payment_details, consistent with how other final-hop
    policy mismatches are handled and without leaking receive-side policy to the
    sender. The maximum final CLTV delta is bounded and tied to the maximum
    already permitted at invoice creation, so the accept and create paths agree.

  • config: validate the CLTV expiry policy bounds, rejecting out-of-range

  • values instead of silently accepting them.

  • contractcourt: apply the same final-HTLC validation before the invoice

  • lookup, so an out-of-policy final HTLC is handled consistently.

    Compatibility

    The CLTV policy bounds are now validated. A config value or UpdateChannelPolicy
    request that sets an out-of-range value previously accepted silently will now be
    rejected with a clear error. Nodes using sane values are unaffected.

    Diff: 221 lines (+165 / -56) across 2 files Reviewer: gijswijs Review duration: 801m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 221 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%
    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.323
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #10927"
    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: 36.8% (MEDIUM) · Higher = larger blast radius
    36.8%
    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.5% · Safe to merge
    14.5%