Skip to content

Use LocalHTLCFailureReason in Onion Processing #3744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

carlaKC
Copy link
Contributor

@carlaKC carlaKC commented Apr 17, 2025

This PR contains some of the follow ups that didn't make it into #3601:

  • Implement Display for LocalHTLCFailureReason
  • Use LocalHTLCFailureReason in onion error processing, removing the last few places where we were using raw u16 values
  • Adds a very simple macro to de-dup use of u16 failure codes in failure_code and from<u16> to dedup codes

@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@carlaKC
Copy link
Contributor Author

carlaKC commented Apr 21, 2025

@joostjager anything else that you'd like to add here?

carlaKC added 4 commits April 21, 2025 11:26
In some places where we have LocalHTLCFailureReason, the string we're
passing around is redundant.

This isn't the case in all uses of LocalHTLCFailureReason, for example
InboundHTLCError provides additional information about payload and
blinding related errors that isn't captured in LocalHTLCFailureReason.
In these cases we keep the error string, tolerating some duplication.
These error codes were removed from the specification seven years ago
to prevent probing, so we don't need to handle these cases anymore.
De-duplicate use of u16 failure codes by using a macro that will
match against each variant's failure_code instead.
Copy link
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only comment that I think may not be in this PR is #3601 (comment)

If that one still applies now of course.

@@ -601,19 +601,18 @@ where

pub(super) fn check_incoming_htlc_cltv(
cur_height: u32, outgoing_cltv_value: u32, cltv_expiry: u32
) -> Result<(), (&'static str, LocalHTLCFailureReason)> {
) -> Result<(), LocalHTLCFailureReason> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In decode_incoming_update_add_htlc_onion, encode_malformed_error could have its message param dropped perhaps.

@@ -7838,17 +7838,15 @@ impl<SP: Deref> FundedChannel<SP> where

fn internal_htlc_satisfies_config(
&self, htlc: &msgs::UpdateAddHTLC, amt_to_forward: u64, outgoing_cltv_value: u32, config: &ChannelConfig,
) -> Result<(), (&'static str, LocalHTLCFailureReason)> {
) -> Result<(), LocalHTLCFailureReason> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there more in FundedChannel.send_htlc?

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.

3 participants