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

htlcswitch: track held HTLC source

Public commit record

What the developer wrote

Authored by ziggie

90/100 · Strong
htlcswitch: track held HTLC source

Store held forwards as off-chain or on-chain entries instead of a raw
InterceptedForward map. Off-chain entries keep the existing resume, fail,
settle and auto-fail behavior. On-chain entries are settle-only and
expire by pruning local interceptor state.

When contractcourt re-offers a circuit that is already held off-chain,
replace the stored entry with the on-chain forward so a later SETTLE
reaches the witness beacon instead of the old link mailbox path.

Also set the on-chain interceptor deadline to the HTLC refund timeout.
This keeps the public interceptor deadline populated while ensuring only
off-chain held entries use that value to fail back.

Only off-chain held HTLCs can be released when an optional interceptor
disconnects, because they can resume into the link forwarding flow.

On-chain held HTLCs have no link flow to resume. Keep them in the held
set so a reconnecting interceptor can replay and settle them while
contractcourt waits for the preimage or on-chain expiry.

Use distinct internal deadline types for off-chain auto-fail heights and
on-chain settlement deadlines instead of overloading the intercepted packet
field.

Project both variants back into the existing router RPC auto_fail_height
field to preserve wire compatibility. Reject mismatched held HTLC deadline
types in tests.

On-chain intercepted HTLCs can only be settled. Resume and fail actions
already return concrete errors through the on-chain intercepted forward, so
let those errors propagate to the interceptor client instead of converting
them to success.

Keep the held entry tracked on these errors so the client can reconnect and
settle the HTLC later.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit rewrites how LND tracks HTLCs that are paused by an external interceptor, distinguishing between normal off-chain forwards and ones that have moved to on-chain contract resolution. It fixes a likely bug where a previously off-chain held HTLC, once forced on-chain, could still be settled through the old link path instead of the on-chain witness beacon, and it prevents on-chain HTLCs from being incorrectly auto-failed or released on interceptor disconnect. The change is defensive and correctness-oriented rather than a clear remote-exploitable vulnerability.

Recommended action

Treat as a security-relevant correctness fix. Review the new held entry lifecycle, especially the promotion from off-chain to on-chain and the settle-only enforcement, to ensure no edge cases allow an on-chain HTLC to be failed back or resumed. Consider whether the projected AutoFailHeight for on-chain packets could mislead interceptor clients about semantics, and update documentation/RPC comments if needed.

Security signals we found

01

Prevents settlement of on-chain HTLCs through stale off-chain link mailbox path

02

Prevents premature auto-fail of on-chain HTLCs at off-chain auto-fail height

03

Prevents loss of on-chain settlement opportunity when external interceptor disconnects

04

Adds explicit error propagation for disallowed resume/fail actions on on-chain held HTLCs

05

Adds deadline-type validation and distinct internal expiry semantics

06

Adds replay/retention semantics for on-chain held HTLCs across interceptor reconnects

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 8/15
Affected reach 10/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.