Skip to content

Implement GetPaymentDetails and ListPayments Api.#15

Merged
G8XSU merged 4 commits intolightningdevkit:mainfrom
G8XSU:payment-apis
Oct 21, 2024
Merged

Implement GetPaymentDetails and ListPayments Api.#15
G8XSU merged 4 commits intolightningdevkit:mainfrom
G8XSU:payment-apis

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
Contributor

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
Contributor

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

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

Comments