From a7667374c8a60b96646650c94a858d55cfb53124 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 7 Mar 2025 14:23:28 -0800 Subject: nwc date comparison in seconds --- index.ts | 4 +--- lib/nwc.ts | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/index.ts b/index.ts index 6820dfaf..8f45adad 100644 --- a/index.ts +++ b/index.ts @@ -48,9 +48,7 @@ app.get("/invoices", auth, invoices.list); app.post("/invoice", optional, invoices.create); app.post("/sign", auth, invoices.sign); -app.get("/assetlinks.json", (_,res) => { - res.sendFile('assetlinks.json'); -}); +app.get("/assetlinks.json", (_, res) => res.sendFile("assetlinks.json")); app.get("/nostr.json", nostr.identities); app.get("/profile/:profile", nostr.profile); app.get("/:pubkey/count", nostr.count); diff --git a/lib/nwc.ts b/lib/nwc.ts index 81476248..a5a25d87 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -361,14 +361,15 @@ const handle = (method, params, ev, app, user) => let transactions = []; for (const pid of payments) { const p = await g(`payment:${pid}`); - if (p.created < from || p.created > until) continue; + const created_at = Math.floor(p.created / 1000); + if (created_at < from || created_at > until) continue; if (p.amount < 0 && type === "incoming") continue; if (p.amount > 0 && type === "outgoing") continue; let payment_hash = p.payment_hash || pid; if (p.type === "lightning") { try { - if(p.amount > 0) { + if (p.amount > 0) { const { invoices } = await ln.listinvoices({ invstring: p.hash }); payment_hash ||= invoices[0].payment_hash; } else { @@ -378,8 +379,6 @@ const handle = (method, params, ev, app, user) => } catch (e) {} } - const created_at = Math.floor(p.created / 1000); - transactions.push({ type: p.amount > 0 ? "incoming" : "outgoing", invoice: p.hash, -- cgit v1.2.3