Skip to content

Commit

Permalink
Merge pull request #173 from synonymdev/return-early
Browse files Browse the repository at this point in the history
fix: return early in getInvoiceFromPaymentHash
  • Loading branch information
Jasonvdb authored Oct 4, 2023
2 parents 8586e5f + 5558c5d commit cd0b189
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 cd0b189

Please sign in to comment.