Skip to content

Commit

Permalink
fix: return early in getInvoiceFromPaymentHash
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Sep 29, 2023
1 parent 8586e5f commit 5558c5d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/src/lightning-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1491,18 +1491,15 @@ class LightningManager {
paymentHash: string,
): Promise<TInvoice | undefined> => {
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<TLdkSpendableOutputs> => {
Expand Down

0 comments on commit 5558c5d

Please sign in to comment.