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

Hold back HTLC monitor events while updates are in-flight

Public commit record

What the developer wrote

Authored by Valentine Wallace

73/100 · Adequate
Hold back HTLC monitor events while updates are in-flight

A ChannelMonitor applies a ChannelMonitorUpdate in-memory before the update
has been durably persisted, and may queue a MonitorEvent::HTLCEvent based on
the update's contents.

Acting on such an event before the update which generated it is persisted will
become unsafe when we begin generating monitor events for off-chain HTLC
failures: if we crash and lose the update that triggered the monitor event, we
lose the counterparty's revocation of the state containing the HTLC, yet we may
have already told the user that the payment failed.

Thus, have the ChainMonitor hold back a monitor's HTLC events while it has any
in-flight updates, and document the same requirement on
Watch::release_pending_monitor_events. Other monitor events, e.g. channel
closures, are still released immediately.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a crash-recovery safety issue in the Lightning Dev Kit's channel monitor. Before the fix, the code could report a failed payment to the user based on a state change that had not yet been saved to disk. If the program crashed right after reporting the failure, it might restart without the counterparty's revocation that justified the failure, potentially leading to inconsistent payment state. The fix delays payment-failure notifications until the underlying state change has been durably saved.

Recommended action

Review the patch for completeness: ensure all callers of release_pending_monitor_events honor the new HTLC-event withholding requirement, and verify that pending HTLC failure events are released once the corresponding ChannelMonitorUpdate is acknowledged as persisted. Consider adding tests that simulate a crash between event surfacing and persistence to confirm the fix.

Security signals we found

01

Crash-recovery consistency bug in payment failure handling

02

In-memory state applied before durable persistence could lead to lost revocation

03

New filtering API to withhold HTLC failure events until persistence completes

04

Trait documentation updated to impose ordering requirement on implementers

05

Test helper force_channel_monitor_updated now cleans pending update list

Risk score

Why this scored 57/100

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