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

[BugFix] CLNRest Backend Fix for paid invoices #2295

Merged
merged 3 commits into from
Jul 21, 2024

Conversation

newtonick
Copy link
Contributor

Description

CLNRest backend fix.

Current master branch uses the /v1/listinvoices endpoint for involves and does a limit of 150 records by created index. Unfortunately this limit is for the first 150 invoices and not the last 150 invoices. This means nodes with more than 150 invoices in the current master branch won't show up in the Activity View.

Link to code:

this.postRequest('/v1/listinvoices', { limit: 150, index: 'created' });

The fix is to move to the sql endpoint and order by created_index DESC.

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • Embedded LND
  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (c-lightning-REST)
  • LndHub
  • [DEPRECATED] Core Lightning (Spark)
  • [DEPRECATED] Eclair
  • CLNRest

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

this.postRequest('/v1/sql', {
query: "SELECT label, bolt11, bolt12, payment_hash, amount_msat, status, amount_received_msat, paid_at, payment_preimage, description, expires_at FROM invoices WHERE status = 'paid' ORDER BY created_index DESC LIMIT 150;"
}).then((data: any) => {
const invoicelist: any[] = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaloudis if there is a more "javascripty" way to name invoicelist let me know. The linter gave me grief about naming it invoices.

zeus/backends/CLNRest.ts
  235:17  error  Expected property shorthand  object-shorthand

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine as is.

nit: would camelCase the var name

@kaloudis kaloudis added this to the v0.9.0 milestone Jul 19, 2024
@kaloudis kaloudis added Core Lightning Issues specific to Core Lightning CLNRest labels Jul 19, 2024
@kaloudis kaloudis merged commit 9d9958f into ZeusLN:master Jul 21, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLNRest Core Lightning Issues specific to Core Lightning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants