Skip to content

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

Merged
tnull merged 4 commits into
lightningdevkit:mainfrom
tnull:2023-05-list-all-payments
Jun 1, 2023
Merged

Only avoid duplicate payments if we didn't fail sending (and expose list_payments)#96
tnull merged 4 commits into
lightningdevkit:mainfrom
tnull:2023-05-list-all-payments

Conversation

@tnull

@tnulltnull commented May 12, 2023

Copy link
Copy Markdown
Collaborator

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.

@tnulltnull added this to the 0.1 milestone May 12, 2023
@tnulltnull mentioned this pull request May 12, 2023
47 tasks
@tnull
tnullforce-pushed the 2023-05-list-all-payments branch from b0ff3c8 to c4f49c4CompareMay 23, 2023 17:38
@tnull

Copy link
Copy Markdown
CollaboratorAuthor

Rebased after #85 landed.

@jkczyz
jkczyz self-requested a review May 30, 2023 13:47
Comment threadsrc/error.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs Outdated
Comment threadsrc/lib.rs
@tnull
tnullforce-pushed the 2023-05-list-all-payments branch from c4f49c4 to 94e87e5CompareMay 31, 2023 07:41
Comment threadsrc/lib.rs
status: PaymentStatus::SendingFailed,
};

self.payment_store.insert(payment)?;

Copy link
Copy Markdown
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.

@tnulltnullJun 1, 2023

Copy link
Copy Markdown
CollaboratorAuthor

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
Copy Markdown
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
Copy Markdown
CollaboratorAuthor

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
tnullforce-pushed the 2023-05-list-all-payments branch from 94e87e5 to 4a9cc01CompareJune 1, 2023 07:23
@tnull

tnull commented Jun 1, 2023

Copy link
Copy Markdown
CollaboratorAuthor

Rebased on main.

@tnull
tnullforce-pushed the 2023-05-list-all-payments branch from 4a9cc01 to f3e5658CompareJune 1, 2023 14:03

@jkczyzjkczyz left a comment

Copy link
Copy Markdown
Contributor

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
tnullforce-pushed the 2023-05-list-all-payments branch from f3e5658 to ecd1b64CompareJune 1, 2023 15:50
@tnull

tnull commented Jun 1, 2023

Copy link
Copy Markdown
CollaboratorAuthor

LGTM. Please squash.

Squashed without further changes.

@tnull
tnull merged commit d2d75a9 into lightningdevkit:mainJun 1, 2023
joostjager pushed a commit to joostjager/ldk-node that referenced this pull request Jan 28, 2026
Sign up for freeto 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

@tnull@jkczyz