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
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion backends/CLNRest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,30 @@ export default class CLNRest {
};
getMyNodeInfo = () => this.postRequest('/v1/getinfo');
getInvoices = () =>
this.postRequest('/v1/listinvoices', { limit: 150, index: 'created' });
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

data.rows.forEach((invoice: any) => {
invoicelist.push({
label: invoice[0],
bolt11: invoice[1],
bolt12: invoice[2],
payment_hash: invoice[3],
amount_msat: invoice[4],
status: invoice[5],
amount_received_msat: invoice[6],
paid_at: invoice[7],
payment_preimage: invoice[8],
description: invoice[9],
expires_at: invoice[10]
});
});

return {
invoices: invoicelist
};
});
createInvoice = (data: any) =>
this.postRequest('/v1/invoice', {
description: data.memo,
Expand Down
Loading