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

Check if send_payment invoice is already paid #452

Merged
merged 5 commits into from
Sep 13, 2023

Conversation

dangeross
Copy link
Collaborator

Lookup the invoice payment by hash and if the payment is already completed, throw an error.

Fixes #414

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

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

Other than a small enhancement looks good.

.persister
.get_completed_payment_by_hash(&parsed_invoice.payment_hash)?
{
Some(_) => Err(anyhow!("Invoice already paid")),
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we can introduce a new SdkError here?

Copy link
Member

Choose a reason for hiding this comment

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

I also noticed one test is failing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Added SdkError and updated test

Copy link
Member

@roeierez roeierez left a comment

Choose a reason for hiding this comment

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

LGTM!

@dangeross dangeross merged commit 70c6bdb into main Sep 13, 2023
5 checks passed
@dangeross dangeross deleted the savage-check-invoice-paid branch September 13, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent Invoice Payment Confirmation in sendPayment Method
2 participants