diff options
| author | Adam Soltys <[email protected]> | 2025-02-10 00:05:19 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-10 00:05:19 -0800 |
| commit | 2e508845545c4b56e96289adf0b7706b572bb182 (patch) | |
| tree | 7409d14487db408833f2d4565b8d6a89d8863ab1 /routes | |
| parent | 9312e1092d27714010b7942ee60b832d2a510321 (diff) | |
| download | coinos-server-2e508845545c4b56e96289adf0b7706b572bb182.tar.gz coinos-server-2e508845545c4b56e96289adf0b7706b572bb182.zip | |
budget
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/users.ts | 12 |
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, ); }), |
