From 80470a2c66c17e4992f176438025b2b021581d11 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 1 Oct 2024 15:50:46 -0700 Subject: getpayment helper --- lib/lightning.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/lightning.ts') diff --git a/lib/lightning.ts b/lib/lightning.ts index 74869a19..7a35c9f2 100644 --- a/lib/lightning.ts +++ b/lib/lightning.ts @@ -3,6 +3,7 @@ import ln from "$lib/ln"; import { err, warn } from "$lib/logging"; import { g, s } from "$lib/db"; import { credit, types } from "$lib/payments"; +import { getPayment } from "$lib/utils"; export async function listenForLightning() { let inv = await ln.waitanyinvoice((await g("pay_index")) || 0); @@ -35,9 +36,7 @@ export async function listenForLightning() { } } - let p = await g(`payment:${bolt11}`); - if (typeof p === "string") p = await g(`payment:${p}`); - + let p = await getPayment(bolt11); if (p) return warn("already processed", bolt11); await credit({ hash:bolt11, amount:received, memo:invoice.memo, ref:preimage, type:types.lightning}); -- cgit v1.2.3