aboutsummaryrefslogtreecommitdiffstats
path: root/routes/balances.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-06-13 21:39:22 -0700
committerAdam Soltys <[email protected]>2020-06-13 21:39:22 -0700
commit74b7d2a0d614f170ba5aea3a1a172a7a68356d80 (patch)
treebe2a73a9917616c0b49c24dc99642378e5a47549 /routes/balances.js
parentdcb21adb40a44c8108f1d652cc6ddd59ae7c4024 (diff)
downloadcoinos-server-74b7d2a0d614f170ba5aea3a1a172a7a68356d80.tar.gz
coinos-server-74b7d2a0d614f170ba5aea3a1a172a7a68356d80.zip
push notifications
Diffstat (limited to 'routes/balances.js')
-rw-r--r--routes/balances.js61
1 files changed, 0 insertions, 61 deletions
diff --git a/routes/balances.js b/routes/balances.js
deleted file mode 100644
index ba834306..00000000
--- a/routes/balances.js
+++ /dev/null
@@ -1,61 +0,0 @@
-const sequelize = require("sequelize");
-const { Op } = sequelize;
-
-app.get("/info", async (req, res) => {
- const accounts = await db.Account.findAll({
- attributes: [
- "asset",
- [sequelize.fn("sum", sequelize.col("balance")), "total"]
- ],
- group: ["asset"],
- });
-
- let lnchannel;
- let lnwallet;
- let lninfo;
-
- if (config.lna) {
- if (config.lna.clightning) {
- const funds = await lna.listfunds();
- lninfo = await lna.getinfo();
- lnchannel = parseInt(funds.channels.reduce((a, b) => a + b.channel_sat, 0));
- lnwallet = parseInt(funds.outputs.reduce((a, b) => a + b.value, 0));
- } else {
- lninfo = await lna.getInfo({});
- lnchannel = parseInt((await lna.channelBalance({})).balance);
- lnwallet = parseInt((await lna.walletBalance({})).total_balance);
- }
- }
-
- let bitcoin, bitcoind;
- if (config.bitcoin) {
- bitcoin = parseInt((await bc.getBalance()) * SATS);
- bitcoind = await bc.getNetworkInfo();
- }
-
- let assets, liquid, elementsd;
- if (config.liquid) {
- assets = await lq.getBalance();
- liquid = parseInt(assets.bitcoin * SATS);
- elementsd = await lq.getNetworkInfo();
- }
-
- const info = {
- bitcoind,
- elementsd,
- accounts,
- assets,
- bitcoin,
- liquid,
- lnchannel,
- lnwallet,
- };
-
- info.total =
- parseInt(bitcoin) +
- parseInt(liquid) +
- parseInt(lnchannel) +
- parseInt(lnwallet);
-
- res.send(info);
-});