Skip to content
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

Add a reason to HTLCHandlingFailed event #3601

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

carlaKC
Copy link
Contributor

@carlaKC carlaKC commented Feb 13, 2025

This PR adds a HTLCHandlingFailure reason to HTLCHandlingFailed to fix #3541.

A simpler version of this would be to make HTLCFailReason public and just surface that on the API. Decided against this approach because it exposes not-so-user-friendly types on the API with types like OnionErrorPacket, but happy to go with that way if it's preferred!

/// The HTLC was failed by the local node.
Local {
/// The BOLT 04 failure code providing a specific failure reason.
failure_code: u16
Copy link
Collaborator

Choose a reason for hiding this comment

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

I admit I'm not super excited about exposing the failure code as-is for two reasons - (a) we have very different constraints on the code - we may not always want to give the sender all the details about a failure (eg if the sender used a private channel but we didn't mean to expose it we might pretend the channel doesnt exist) vs what we want to tell the user about a failure (basically everything), (b) its not particularly easy to parse - users have to go read the BOLT then map that to what is actually happening in LDK code, if we had a big enum here we'd be able to provide good docs linking to config knobs and reasons why failures happened.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, will take a look at adding a more detailed enum or adding to HTLCDestination 👍

@@ -1441,6 +1461,10 @@ pub enum Event {
prev_channel_id: ChannelId,
/// Destination of the HTLC that failed to be processed.
failed_next_destination: HTLCDestination,
/// The cause of the processing failure.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Its worth noting that HTLCDestination has some "reason"-like attributes (I meant to mention this in the issue, but apparently forgot), they're just incomplete and too broad. Up to you if you want to try to add more details there vs adding a new enum.

@carlaKC
Copy link
Contributor Author

carlaKC commented Feb 21, 2025

I'm going to be out on vacation until 3 March, but will pick this up when I get back!

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.

Give HTLCHandlingFailed a reason of some kind
2 participants