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

Only avoid duplicate payments if we didn't fail sending (and expose list_payments) #96

Merged
merged 4 commits into from
Jun 1, 2023

Conversation

tnull
Copy link
Collaborator

@tnull tnull commented May 12, 2023

Previously, we went from not tracking payments when they immediately failed to send to always tracking them but denying any retries for payments whose payment hash was known to us. However, this is of course much too restrictive as payments might fail due to local connections issues or unavailability of usable channels, in which case the invoices/payment hashes would be 'burnt' and couldn't get retried.

Here, we introduce a new PaymentStatus::SendingFailed to differentiate send failures and allow retrying tracked payments if they failed to send immediately. We also rename some error types accordingly for further clarification.

Additionally, we expose a simple Node::list_payments variant, mainly to be used in bindings where we can't make use of the _with_filter variant.

@tnull tnull added this to the 0.1 milestone May 12, 2023
@tnull tnull mentioned this pull request May 12, 2023
47 tasks
@tnull tnull force-pushed the 2023-05-list-all-payments branch from b0ff3c8 to c4f49c4 Compare May 23, 2023 17:38
@tnull
Copy link
Collaborator Author

tnull commented May 23, 2023

Rebased after #85 landed.

@jkczyz jkczyz self-requested a review May 30, 2023 13:47
src/error.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@tnull tnull force-pushed the 2023-05-list-all-payments branch from c4f49c4 to 94e87e5 Compare May 31, 2023 07:41
status: PaymentStatus::SendingFailed,
};

self.payment_store.insert(payment)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

So we have any tests that check the payment store? Might be worth adding a test case for duplicate payments.

Copy link
Collaborator Author

@tnull tnull Jun 1, 2023

Choose a reason for hiding this comment

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

Ah, but checking that we fail to send duplicate payments is already covered in channel_full_cycle? Not entirely sure how we'd check the behavior on the payment store alone as the logic for handling duplicates lives (and has to live I think) in send_payment.

Copy link
Contributor

Choose a reason for hiding this comment

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

But we don't check that the status remains the same as before in case of a duplicate error, IIUC.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, fair enough, now asserting that the payment details are unchanged after we receive Error::DuplicatePayment.

@tnull tnull force-pushed the 2023-05-list-all-payments branch from 94e87e5 to 4a9cc01 Compare June 1, 2023 07:23
@tnull
Copy link
Collaborator Author

tnull commented Jun 1, 2023

Rebased on main.

@tnull tnull force-pushed the 2023-05-list-all-payments branch from 4a9cc01 to f3e5658 Compare June 1, 2023 14:03
Copy link
Contributor

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

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

LGTM. Please squash.

tnull added 3 commits June 1, 2023 17:50
Previously, we denied retrying any payment for which we already had seen
the payment hash. However, this is rather invasive as payments might
fail due to local connections issues or unavailability of usable
channels, in which case the invoices/payment hashes would be 'burnt' and
couldn't get retried.

Here, we introduce a new `PaymentStatus::SendingFailed` to differentiate
send failures and allow retrying tracked payments if they failed to send
immediately. We also rename some error types accordingly for further
clarification.
@tnull tnull force-pushed the 2023-05-list-all-payments branch from f3e5658 to ecd1b64 Compare June 1, 2023 15:50
@tnull
Copy link
Collaborator Author

tnull commented Jun 1, 2023

LGTM. Please squash.

Squashed without further changes.

@tnull tnull merged commit d2d75a9 into lightningdevkit:main Jun 1, 2023
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.

2 participants