aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-06 08:29:42 -0800
committerAdam Soltys <[email protected]>2024-11-06 08:31:30 -0800
commitd0de00fab7b474c9b691bef0cd3b2da2dd2d67c1 (patch)
treebc35d3323b7f7c466091276a59643711fa5d7101 /routes
parent6973aaa259b45ecf038051bda0d3689cac6523b6 (diff)
downloadcoinos-server-d0de00fab7b474c9b691bef0cd3b2da2dd2d67c1.tar.gz
coinos-server-d0de00fab7b474c9b691bef0cd3b2da2dd2d67c1.zip
cash balance
Diffstat (limited to 'routes')
-rw-r--r--routes/info.ts20
1 files changed, 13 insertions, 7 deletions
diff --git a/routes/info.ts b/routes/info.ts
index 09361a01..8892b7f7 100644
--- a/routes/info.ts
+++ b/routes/info.ts
@@ -1,12 +1,10 @@
import { archive } from "$lib/db";
-import db from "$lib/db";
+import { db, g } from "$lib/db";
import ln from "$lib/ln";
+import { getDecodedToken } from "@cashu/cashu-ts";
export default {
- async balances(req, res) {
- let lnchannel;
- let lnwallet;
-
+ async balances(_, res) {
let total = 0;
for await (const k of db.scanIterator({ MATCH: "balance:*" })) {
@@ -18,10 +16,18 @@ export default {
}
const funds = await ln.listfunds();
- lnchannel = parseInt(funds.channels.reduce((a, b) => a + b.channel_sat, 0));
- lnwallet = parseInt(funds.outputs.reduce((a, b) => a + b.value, 0));
+ const lnchannel = parseInt(
+ funds.channels.reduce((a, b) => a + b.channel_sat, 0),
+ );
+ const lnwallet = parseInt(funds.outputs.reduce((a, b) => a + b.value, 0));
+
+ const cash = getDecodedToken(await g("cash")).token[0].proofs.reduce(
+ (a, b) => a + b.amount,
+ 0,
+ );
const info = {
+ cash,
lnchannel,
lnwallet,
total,