diff options
| author | Adam Soltys <[email protected]> | 2024-11-06 08:29:42 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-06 08:31:30 -0800 |
| commit | d0de00fab7b474c9b691bef0cd3b2da2dd2d67c1 (patch) | |
| tree | bc35d3323b7f7c466091276a59643711fa5d7101 | |
| parent | 6973aaa259b45ecf038051bda0d3689cac6523b6 (diff) | |
| download | coinos-server-d0de00fab7b474c9b691bef0cd3b2da2dd2d67c1.tar.gz coinos-server-d0de00fab7b474c9b691bef0cd3b2da2dd2d67c1.zip | |
cash balance
| -rw-r--r-- | lib/ecash.ts | 1 | ||||
| -rw-r--r-- | lib/locations.ts | 1 | ||||
| -rw-r--r-- | routes/info.ts | 20 |
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/ecash.ts b/lib/ecash.ts index d9d6728e..9ea4ec38 100644 --- a/lib/ecash.ts +++ b/lib/ecash.ts @@ -90,3 +90,4 @@ export async function init(amount = 10000) { console.log(e); } } + diff --git a/lib/locations.ts b/lib/locations.ts index abf578d8..57658aad 100644 --- a/lib/locations.ts +++ b/lib/locations.ts @@ -45,7 +45,6 @@ export const getLocations = async () => { for await (const l of locations) { const username = l.tags["payment:coinos"]; if (username) { - console.log(username); const uid = await g(`user:${username}`); const user = await g(`user:${uid}`); if (user) l.osm_json.tags.user = pick(user, fields); 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, |
