aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-01 20:19:37 -0700
committerAdam Soltys <[email protected]>2024-11-01 20:19:37 -0700
commit30b38613981843cc1ac9d8b791121ee6b265b783 (patch)
tree2a88c52ba177820a7d82e0c705a81b06a31dd38c
parentadf42b686517327f30363687009698a37c2fba89 (diff)
downloadcoinos-server-30b38613981843cc1ac9d8b791121ee6b265b783.tar.gz
coinos-server-30b38613981843cc1ac9d8b791121ee6b265b783.zip
limit transactions
-rw-r--r--lib/nwc.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/nwc.ts b/lib/nwc.ts
index e9bcc3a9..a9c8288d 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -228,7 +228,7 @@ const handle = (method, params, user) =>
const payments = await db.lRange(`${user.id}:payments`, 0, -1);
- const transactions = [];
+ let transactions = [];
for (const pid of payments) {
const p = await g(`payment:${pid}`);
if (p.created < from || p.created > until) continue;
@@ -242,21 +242,24 @@ const handle = (method, params, user) =>
: await ln.listpays({ bolt11: p.hash })
: p.id;
+ const created_at = Math.floor(p.created / 1000);
+
transactions.push({
type: p.amount > 0 ? "incoming" : "outgoing",
invoice: p.hash,
description: p.memo,
preimage: p.ref,
- payment_hash: p.hash,
+ payment_hash,
amount: p.amount * 1000,
fees_paid: p.fee * 1000,
- created_at: p.created / 1000,
- expires_at: p.created / 1000 + 7 * 24 * 60 * 60,
- settled_at: p.amount > 0 ? p.created / 1000 : undefined,
+ created_at,
+ expires_at: created_at + 7 * 24 * 60 * 60,
+ settled_at: p.amount > 0 ? created_at : undefined,
metadata: {},
});
}
+ transactions = transactions.slice(offset, offset + limit);
return result({ transactions });
},
})[method](params);