From 949dea4980d1c9ddb2c00213c09efc2f2fb726e8 Mon Sep 17 00:00:00 2001 From: Nick Klockenga Date: Fri, 19 Jul 2024 12:32:46 -0400 Subject: [PATCH 1/3] move from listinvoices endpoint to sql endpoint for invoices --- backends/CLNRest.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/backends/CLNRest.ts b/backends/CLNRest.ts index 0007fc114..13f479c76 100644 --- a/backends/CLNRest.ts +++ b/backends/CLNRest.ts @@ -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 invoices: any[] = []; + data.rows.forEach((invoice: any) => { + invoices.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: invoices + }; + }); createInvoice = (data: any) => this.postRequest('/v1/invoice', { description: data.memo, From 35b944368147ded344d54e27c81aef81397ab665 Mon Sep 17 00:00:00 2001 From: Nick Klockenga Date: Fri, 19 Jul 2024 12:46:27 -0400 Subject: [PATCH 2/3] renamed invoices array object to invoicelist because yarn run lint didn't like the name --- backends/CLNRest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/CLNRest.ts b/backends/CLNRest.ts index 13f479c76..8661f72ba 100644 --- a/backends/CLNRest.ts +++ b/backends/CLNRest.ts @@ -214,9 +214,9 @@ export default class CLNRest { 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 invoices: any[] = []; + const invoicelist: any[] = []; data.rows.forEach((invoice: any) => { - invoices.push({ + invoicelist.push({ label: invoice[0], bolt11: invoice[1], bolt12: invoice[2], @@ -232,7 +232,7 @@ export default class CLNRest { }); return { - invoices: invoices + invoices: invoicelist }; }); createInvoice = (data: any) => From 4a930150e30f5d71eb41b2a7ac94c707b7d09b7d Mon Sep 17 00:00:00 2001 From: Nick Klockenga Date: Fri, 19 Jul 2024 13:19:16 -0400 Subject: [PATCH 3/3] camelCase invoiceList --- backends/CLNRest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backends/CLNRest.ts b/backends/CLNRest.ts index 8661f72ba..8a5166a02 100644 --- a/backends/CLNRest.ts +++ b/backends/CLNRest.ts @@ -214,9 +214,9 @@ export default class CLNRest { 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[] = []; + const invoiceList: any[] = []; data.rows.forEach((invoice: any) => { - invoicelist.push({ + invoiceList.push({ label: invoice[0], bolt11: invoice[1], bolt12: invoice[2], @@ -232,7 +232,7 @@ export default class CLNRest { }); return { - invoices: invoicelist + invoices: invoiceList }; }); createInvoice = (data: any) =>