Skip to content

Implement GetPaymentDetails and ListPayments Api. #15

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

Merged
merged 4 commits into from
Oct 21, 2024
Merged

Implement GetPaymentDetails and ListPayments Api. #15

merged 4 commits into from
Oct 21, 2024

Conversation

G8XSU
Copy link
Contributor

@G8XSU G8XSU commented Oct 14, 2024

Adds implementation for:

  • GetPaymentDetails
  • ListPayments

Based on #13

let payment_details = node.payment(&PaymentId(payment_id_bytes));

let response = GetPaymentDetailsResponse {
payment: payment_details.map(|payment| payment_to_proto(payment)),
Copy link

Choose a reason for hiding this comment

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

Should we respond with an error if the payment is not found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Payment being queried and not being present is a valid use-case, it shouldn't be an exception.
Moreover, it doesn't fit into invalidRequest, InternalError or Lightning Error.
I think returning empty response is correct here, ldk-node does the same.

Copy link

Choose a reason for hiding this comment

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

Hmmm... I thought "not found" was a standard error sort of REST error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, If we are trying to edit channel which doesn't exist, we should throw error.
or close channel that doesn't exist. "not found" in this case represents resource which we were trying to change but wasn't found.

But trying to fetch a non-existent payment or payment that hasn't been made isn't an error, at application layer.
It mostly is a valid scenario, which can be represented by returning empty response or None in optional.
I think it should be documented in proto though.

@G8XSU
Copy link
Contributor Author

G8XSU commented Oct 18, 2024

Now rebased on top of #18 and addressed feedback.

@G8XSU
Copy link
Contributor Author

G8XSU commented Oct 21, 2024

Need to rebase after #18 landed.

@G8XSU
Copy link
Contributor Author

G8XSU commented Oct 21, 2024

Addressed comments, rebased on main, squashed fixups as part of rebase.

@G8XSU G8XSU requested a review from jkczyz October 21, 2024 20:28
@G8XSU G8XSU requested a review from jkczyz October 21, 2024 22:02
Copy link

@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.

@G8XSU
Copy link
Contributor Author

G8XSU commented Oct 21, 2024

Squashed fixups

@G8XSU G8XSU requested a review from jkczyz October 21, 2024 22:06
@G8XSU G8XSU merged commit 7242146 into lightningdevkit:main Oct 21, 2024
1 check passed
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