aboutsummaryrefslogtreecommitdiffstats
path: root/lib/lightning.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-23 23:08:09 -0800
committerAdam Soltys <[email protected]>2023-11-23 23:34:35 -0800
commit13f3c21b9ddf9884f190a6fcf7acf50440c82547 (patch)
treed29a3d8c91b9f5df5e38990800a3259732dc557b /lib/lightning.js
parent04a941b76b916384a3215502d362f4f3b51074a5 (diff)
downloadcoinos-server-13f3c21b9ddf9884f190a6fcf7acf50440c82547.tar.gz
coinos-server-13f3c21b9ddf9884f190a6fcf7acf50440c82547.zip
use payment ids
Diffstat (limited to 'lib/lightning.js')
-rw-r--r--lib/lightning.js8
1 files changed, 5 insertions, 3 deletions
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) {