From aa4cd39c943b67169def224e224bd07b815b70ec Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 31 Oct 2024 09:29:04 -0700 Subject: biome lint --- lib/lightning.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'lib/lightning.ts') diff --git a/lib/lightning.ts b/lib/lightning.ts index 7a35c9f2..ce39f0ad 100644 --- a/lib/lightning.ts +++ b/lib/lightning.ts @@ -6,8 +6,8 @@ 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); - let { + const inv = await ln.waitanyinvoice((await g("pay_index")) || 0); + const { bolt11, description, pay_index, @@ -18,16 +18,16 @@ export async function listenForLightning() { await s("pay_index", pay_index); setTimeout(listenForLightning); - let received = Math.round(amount_received_msat / 1000); + const received = Math.round(amount_received_msat / 1000); try { if (!preimage) return; - let id = await g(`invoice:${bolt11}`); - let invoice = await g(`invoice:${id}`); + const id = await g(`invoice:${bolt11}`); + const invoice = await g(`invoice:${id}`); if (!invoice) return warn("received lightning with no invoice", bolt11); - if (invoice && invoice.memo) { + if (invoice?.memo) { try { if (JSON.parse(description).kind === 9734) await handleZap(inv); } catch (e) { @@ -36,10 +36,16 @@ export async function listenForLightning() { } } - let p = await getPayment(bolt11); + const 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}); + await credit({ + hash: bolt11, + amount: received, + memo: invoice.memo, + ref: preimage, + type: types.lightning, + }); } catch (e) { console.log(e); err("problem receiving lightning payment", e.message); -- cgit v1.2.3