diff options
| author | Adam Soltys <[email protected]> | 2022-10-05 12:15:48 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-10-05 12:15:48 -0700 |
| commit | fb91aa048617f0894e01c1e890ec957a3170539f (patch) | |
| tree | 5630fbe3bb5eb67fc0fba2bba79b8b763609d93a /routes/info.js | |
| parent | 160d95f693d7d8a17e864313b06790a841d4e160 (diff) | |
| download | coinos-server-fb91aa048617f0894e01c1e890ec957a3170539f.tar.gz coinos-server-fb91aa048617f0894e01c1e890ec957a3170539f.zip | |
prettier
Diffstat (limited to 'routes/info.js')
| -rw-r--r-- | routes/info.js | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/routes/info.js b/routes/info.js index fd77c5d1..6c2c601d 100644 --- a/routes/info.js +++ b/routes/info.js @@ -37,63 +37,63 @@ app.get("/info", async (req, res, next) => { app.get("/balances", async (req, res, next) => { try { - const accounts = await db.Account.findAll({ - attributes: [ - "asset", - "pubkey", - [sequelize.fn("sum", sequelize.col("balance")), "total"] - ], - group: ["asset", "pubkey"] - }); + const accounts = await db.Account.findAll({ + attributes: [ + "asset", + "pubkey", + [sequelize.fn("sum", sequelize.col("balance")), "total"] + ], + group: ["asset", "pubkey"] + }); - let lnchannel; - let lnwallet; + let lnchannel; + let lnwallet; - if (config.lna) { - if (config.lna.clightning) { - 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)); - } else { - lnchannel = parseInt(await getChannelBalance({ lnd }).channel_balance); - lnwallet = parseInt(await getChainBalance({ lnd }).chain_balance); + if (config.lna) { + if (config.lna.clightning) { + 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)); + } else { + lnchannel = parseInt(await getChannelBalance({ lnd }).channel_balance); + lnwallet = parseInt(await getChainBalance({ lnd }).chain_balance); + } } - } - let bitcoin, bitcoind; - if (config.bitcoin) { - bitcoin = parseInt((await bc.getBalance()) * SATS); - bitcoind = await bc.getNetworkInfo(); - } + 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(); - } + 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 - }; + const info = { + bitcoind, + elementsd, + accounts, + assets, + bitcoin, + liquid, + lnchannel, + lnwallet + }; - info.total = - parseInt(bitcoin) + - parseInt(liquid) + - parseInt(lnchannel) + - parseInt(lnwallet); + info.total = + parseInt(bitcoin) + + parseInt(liquid) + + parseInt(lnchannel) + + parseInt(lnwallet); - res.send(info); - } catch(e) { - console.log("problem getting balances", e) - } + res.send(info); + } catch (e) { + console.log("problem getting balances", e); + } }); |
