Skip to content

Commit

Permalink
[Bug fix] CLNRest Backend Fix for paid invoices (#2295)
Browse files Browse the repository at this point in the history
* move from listinvoices endpoint to sql endpoint for invoices

* renamed invoices array object to invoicelist because yarn run lint didn't like the name

* camelCase invoiceList
  • Loading branch information
newtonick authored Jul 21, 2024
1 parent 0f155bd commit 9d9958f
Showing 1 changed file with 24 additions and 1 deletion.
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[] = [];
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

0 comments on commit 9d9958f

Please sign in to comment.