aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-02-10 00:05:19 -0800
committerAdam Soltys <[email protected]>2025-02-10 00:05:19 -0800
commit2e508845545c4b56e96289adf0b7706b572bb182 (patch)
tree7409d14487db408833f2d4565b8d6a89d8863ab1 /routes
parent9312e1092d27714010b7942ee60b832d2a510321 (diff)
downloadcoinos-server-2e508845545c4b56e96289adf0b7706b572bb182.tar.gz
coinos-server-2e508845545c4b56e96289adf0b7706b572bb182.zip
budget
Diffstat (limited to 'routes')
-rw-r--r--routes/users.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/routes/users.ts b/routes/users.ts
index ddadec5f..e6e11741 100644
--- a/routes/users.ts
+++ b/routes/users.ts
@@ -843,8 +843,16 @@ export default {
if (a.secret)
a.nwc = `nostr+walletconnect://${serverPubkey}?relay=${relay}&secret=${a.secret}&lud16=${lud16}`;
- a.spent = (await db.lRange(`${a.pubkey}:payments`, 0, -1)).reduce(
- (a, b) => a + (Math.abs(b.amount) + b.fee + b.ourfee),
+ const pids = await db.lRange(`${a.pubkey}:payments`, 0, -1);
+ const payments = await Promise.all(
+ pids.map((pid) => g(`payment:${pid}`)),
+ );
+ a.spent = payments.reduce(
+ (a, b) =>
+ a +
+ (Math.abs(parseInt(b.amount || 0)) +
+ parseInt(b.fee || 0) +
+ parseInt(b.ourfee || 0)),
0,
);
}),