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

Add forwards-compatibility logic in `LocalHTLCFailureReason` ser

Public commit record

What the developer wrote

Authored by Matt Corallo

93/100 · Strong
Add forwards-compatibility logic in `LocalHTLCFailureReason` ser

We recently created a `LocalHTLCFailureReason` enum to cover
detailed reasons why an HTLC may have failed, in excess of the
on-the-wire failure encoding.

Sadly, when we did so we introduced a serialization format which
isn't particularly conducive to introducing new failure reasons in
the future. Luckily, `LocalHTLCFailureReason` already has logic
that works for forwards-compatibility - it can be converted to, and
from, the on-the-wire error codes.

Thus, here, we take advantage of that, writing both the on-the-wire
error code as well as a code for the specific case. If we don't
recognize the specific case on deserialization, we'll fall back to
the default case for the on-the-wire code we've written.

We also, of course, include a length-prefixed TLV stream to allow
for additional fields in the future.

Fixes #4087
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit changes how a Lightning node stores and reloads its own internal reasons for payment failures. The old format used a single fixed list of numeric codes, which would have made future upgrades fragile. The new format writes both the standard on-the-wire failure code and a separate internal reason code, plus a placeholder for future extra fields. If an older or newer version reads a reason it does not know, it now falls back to the standard failure code instead of potentially failing to load the data. This is a forward-compatibility improvement, not a fix for an active exploit.

Recommended action

Treat as a maintainability and compatibility improvement. Include in normal review and testing; verify that round-trip serialization of all enum variants and fallback behavior for unknown reason codes work as intended. No urgent security response is indicated by the commit content.

Security signals we found

01

Forward-compatibility hardening for persisted enum data

02

Graceful fallback to known on-the-wire failure code on unknown internal reason

03

Addition of length-prefixed TLV stream for future field extensions

04

No memory safety, cryptographic, or authorization changes visible

05

No explicit vulnerability or CVE referenced in commit message

Risk score

Why this scored 31/100

Our methodology →
Potential impact 8/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 6/15
Confidence 7/10
Evidence quality 3/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.