aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-01-30 20:31:59 +0000
committerAdam Soltys <[email protected]>2026-01-30 20:31:59 +0000
commitedd76a99a90d56ab641c48b95dd5891558baa133 (patch)
tree7298026a3823645ab67d7cd8093d7a9c89433ade /lib
parent3e2b756e5b97db690b9a707049060805ca88c9de (diff)
downloadcoinos-server-edd76a99a90d56ab641c48b95dd5891558baa133.tar.gz
coinos-server-edd76a99a90d56ab641c48b95dd5891558baa133.zip
consult archive for older payments
Diffstat (limited to 'lib')
-rw-r--r--lib/nwc.ts12
-rw-r--r--lib/payments.ts4
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/nwc.ts b/lib/nwc.ts
index c7f8d7e9..c888ee55 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -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,
diff --git a/lib/payments.ts b/lib/payments.ts
index 931bf167..80aee8b7 100644
--- a/lib/payments.ts
+++ b/lib/payments.ts
@@ -1,6 +1,6 @@
import config from "$config";
import api from "$lib/api";
-import { db, g, ga, s } from "$lib/db";
+import { db, g, ga, gf, s } from "$lib/db";
import { generate } from "$lib/invoices";
import ln from "$lib/ln";
import { err, l, warn } from "$lib/logging";
@@ -493,7 +493,7 @@ export const sendKeysend = async ({
}) => {
fee = Math.max(Number.parseInt(fee || amount * 0.005), 5);
- let p = await g(`payment:${hash}`);
+ let p = await gf(`payment:${hash}`);
if (p) fail("duplicate keysend");
p = await debit({