Skip to content

Conversation

TheBlueMatt
Copy link
Collaborator

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

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 lightningdevkit#4087
@TheBlueMatt TheBlueMatt added this to the 0.2 milestone Sep 21, 2025
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Sep 21, 2025

👋 I see @tankyleo was un-assigned.
If you'd like another reviewer assignment, please click here.

Copy link

codecov bot commented Sep 21, 2025

Codecov Report

❌ Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.71%. Comparing base (1ed6c4b) to head (21a8b75).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/onion_utils.rs 68.75% 0 Missing and 5 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4099   +/-   ##
=======================================
  Coverage   88.71%   88.71%           
=======================================
  Files         176      176           
  Lines      132778   132794   +16     
  Branches   132778   132794   +16     
=======================================
+ Hits       117790   117806   +16     
+ Misses      12304    12301    -3     
- Partials     2684     2687    +3     
Flag Coverage Δ
fuzzing 21.55% <50.00%> (+<0.01%) ⬆️
tests 88.55% <68.75%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wpaulino wpaulino merged commit 677eec6 into lightningdevkit:main Sep 22, 2025
25 checks passed
@tankyleo tankyleo removed their request for review October 10, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LocalHTLCFailureReason isn't forwards-compatible

3 participants