From 13f3c21b9ddf9884f190a6fcf7acf50440c82547 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 23 Nov 2023 23:08:09 -0800 Subject: use payment ids --- lib/lightning.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/lightning.js') diff --git a/lib/lightning.js b/lib/lightning.js index 1788fd12..77a429ed 100644 --- a/lib/lightning.js +++ b/lib/lightning.js @@ -8,7 +8,7 @@ import { g, s, t, db } from "$lib/db"; import { credit, types } from "$lib/payments"; export async function listenForLightning() { - let event = await ln.waitanyinvoice(await g("pay_index")); + let event = await ln.waitanyinvoice((await g("pay_index")) || 0); let { bolt11, pay_index, @@ -31,8 +31,10 @@ export async function listenForLightning() { let invoice = await g(`invoice:${id}`); if (!invoice) return warn("received lightning with no invoice", bolt11); - let payment = await g(`payment:${bolt11}`); - if (payment) return warn("already processed", bolt11); + let p = await g(`payment:${bolt11}`); + if (typeof p === "string") p = await g(`payment:${p}`); + + if (p) return warn("already processed", bolt11); await credit(bolt11, received, invoice.memo, preimage, types.lightning); } catch (e) { -- cgit v1.2.3