-
Notifications
You must be signed in to change notification settings - Fork 24
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
More detailed error when HTLC could not be sent #634
Conversation
We use more detailed errors when we fail to send an HTLC, since this may happen because the channel is offline, syncing, opening or closing. It may also happen that we have a channel in the `Normal` state that has enough funds, but we cannot send the HTLC because it hits a channel limit (too many HTLCs pending, a splice is ongoing, etc). When that happens we will retry ignoring the channel, which leads to the default `NoAvailableChannels` error: in that case, the "real" error can be found in the `failures` list of the `OutgoingPaymentFailure` instance. Fixes #616
Some payment errors can be converted into friendly user errors, telling them whether they should retry or not and what should change in their payment attempt. This isn't the case for all errors: some of them cannot be interpreted easily when they come from remote nodes, but that's ok, we're doing the best we can when the error can be interpreted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just nits
src/commonMain/kotlin/fr/acinq/lightning/payment/OutgoingPaymentFailure.kt
Outdated
Show resolved
Hide resolved
src/commonMain/kotlin/fr/acinq/lightning/payment/OutgoingPaymentFailure.kt
Outdated
Show resolved
Hide resolved
And use sealed class hierarchy instead.
src/commonMain/kotlin/fr/acinq/lightning/payment/OutgoingPaymentFailure.kt
Outdated
Show resolved
Hide resolved
For backward compat, it would work, yes. However, these changes do not fix #616. When a payment fails, Phoenix does not display the failures for each parts. Payment parts are confusing for users, so we don't show them (except on iOS but we'll have to remove that). Instead we show the What would be great is a method that takes the |
And update the `PaymentsDb` trait to use this type instead of an `Either<ChannelException, FailureMessage>`.
I did something in 2932347, I'm not sure we can do better. There are always cases that won't be easy to programmatically analyze and will require the exact details of each payment attempt to figure out what went wrong, but it should work in most cases. |
At some point we could simplify all of this greatly by assuming that |
src/commonMain/kotlin/fr/acinq/lightning/payment/OutgoingPaymentFailure.kt
Outdated
Show resolved
Hide resolved
The actual balance isn't useful and makes localization harder.
Testing this PR on Phoenix, and trying to pay an already paid invoice a second time, I hoped to get a Instead, the parent payment status is FYI, the So we are still not able to provide a meaningful error message to the user, even with the improvements added in the PR. |
Outgoing LN parts have a new failure type, which will help provide more meaningful error messages. The payments database interface has also changed to accomodate these new types. See ACINQ/lightning-kmp#634
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, it's a nice improvement over what we have already.
Outgoing LN parts have a new failure type, which will help provide more meaningful error messages. The payments database interface has also changed to accomodate these new types. See ACINQ/lightning-kmp#634
Outgoing LN parts have a new failure type, which will help provide more meaningful error messages. The payments database interface has also changed to accomodate these new types. See ACINQ/lightning-kmp#634
Outgoing LN parts have a new failure type, which will help provide more meaningful error messages. The payments database interface has also changed to accomodate these new types. See ACINQ/lightning-kmp#634
Outgoing LN parts have a new failure type, which will help provide more meaningful error messages. The payments database interface has also changed to accomodate these new types. See ACINQ/lightning-kmp#634 --------- Co-authored-by: Robbie Hanson <[email protected]>
We use more detailed errors when we fail to send an HTLC, since this may happen because the channel is offline, syncing, opening or closing.
It may also happen that we have a channel in the
Normal
state that has enough funds, but we cannot send the HTLC because it hits a channel limit (too many HTLCs pending, a splice is ongoing, etc). When that happens we will retry ignoring the channel, which leads to the defaultNoAvailableChannels
error: in that case, the "real" error can be found in thefailures
list of theOutgoingPaymentFailure
instance.We now explicitly map every failure to a potentially user-friendly error (
PartFailure
), whenever possible. When the error cannot be easily interpreted, we use aPartFailure.Uninterpretable
error to wrap the actual error. Applications like Phoenix should define localized error messages for each of these errors and print them on failures.LightningOutgoingPayment.Part.Status.Failed
, which is stored in the DB. The migration should be handled by:error_code
and a mapping fromPartFailure
to an error codePartFailure.Uninterpretable
, the existingdetails
column should be used for the error messageerror_code
ofPartFailure.Uninterpretable
and just display the storeddetails
messageWhat do you think @dpad85, is that an acceptable way of handling backwards-compat for previously failed payments?
Fixes #616