diff options
| author | Adam Soltys <[email protected]> | 2026-01-30 20:31:59 +0000 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-01-30 20:31:59 +0000 |
| commit | edd76a99a90d56ab641c48b95dd5891558baa133 (patch) | |
| tree | 7298026a3823645ab67d7cd8093d7a9c89433ade /lib/nwc.ts | |
| parent | 3e2b756e5b97db690b9a707049060805ca88c9de (diff) | |
| download | coinos-server-edd76a99a90d56ab641c48b95dd5891558baa133.tar.gz coinos-server-edd76a99a90d56ab641c48b95dd5891558baa133.zip | |
consult archive for older payments
Diffstat (limited to 'lib/nwc.ts')
| -rw-r--r-- | lib/nwc.ts | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1,5 +1,5 @@ import config from "$config"; -import { db, g } from "$lib/db"; +import { archive, db, g, gf } from "$lib/db"; import { generate } from "$lib/invoices"; import ln from "$lib/ln"; import { err, l, warn } from "$lib/logging"; @@ -428,11 +428,15 @@ const handle = (method, params, ev, app, user) => async list_transactions() { const { from, until, limit = 10, offset = 0, type } = params; - const payments = await db.lRange(`${user.id}:payments`, 0, -1); + const listKey = `${user.id}:payments`; + const main = (await db.lRange(listKey, 0, -1)) || []; + const archived = (await archive.lRange(listKey, 0, -1)) || []; + const payments = [...new Set([...main, ...archived])]; let transactions = []; for (const pid of payments) { - const p = await g(`payment:${pid}`); + const p = await gf(`payment:${pid}`); + if (!p) continue; const created_at = Math.floor(p.created / 1000); if (created_at < from || created_at > until) continue; if (p.amount < 0 && type === "incoming") continue; @@ -457,7 +461,7 @@ const handle = (method, params, ev, app, user) => description: p.memo, preimage: p.ref, payment_hash, - amount: (Math.abs(p.amount) + p.tip) * 1000, + amount: (Math.abs(p.amount) + (p.tip || 0)) * 1000, fees_paid: (p?.fee || 0) * 1000, created_at, expires_at: created_at + week, |
