From 5558c5d938d3f68ff37411d00078d46df8189d21 Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Fri, 29 Sep 2023 13:44:45 +0100 Subject: [PATCH] fix: return early in getInvoiceFromPaymentHash --- lib/src/lightning-manager.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/src/lightning-manager.ts b/lib/src/lightning-manager.ts index eeb47d4a..802cf7d2 100644 --- a/lib/src/lightning-manager.ts +++ b/lib/src/lightning-manager.ts @@ -1491,18 +1491,15 @@ class LightningManager { paymentHash: string, ): Promise => { const invoices = await this.getBolt11Invoices(); - let invoice: TInvoice | undefined; for (let index = 0; index < invoices.length; index++) { const paymentRequest = invoices[index]; const invoiceRes = await ldk.decode({ paymentRequest }); if (invoiceRes.isOk()) { if (invoiceRes.value.payment_hash === paymentHash) { - invoice = invoiceRes.value; + return invoiceRes.value; } } } - - return invoice; }; private getLdkSpendableOutputs = async (): Promise => {