aboutsummaryrefslogtreecommitdiffstats
path: root/routes/info.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-05 22:58:23 -0700
committerAdam Soltys <[email protected]>2022-09-05 23:01:46 -0700
commit412df5f844de11b3fc71bb7ffaf9c8e1d9f19d65 (patch)
tree209296b3a93bc89b025e8ad0dcf846c23bb82746 /routes/info.js
parent8a82c69419dc358fbaeab322c32d18ee84656feb (diff)
downloadcoinos-server-412df5f844de11b3fc71bb7ffaf9c8e1d9f19d65.tar.gz
coinos-server-412df5f844de11b3fc71bb7ffaf9c8e1d9f19d65.zip
lightning api migration
Diffstat (limited to 'routes/info.js')
-rw-r--r--routes/info.js9
1 files changed, 4 insertions, 5 deletions
diff --git a/routes/info.js b/routes/info.js
index 001caf85..d8785333 100644
--- a/routes/info.js
+++ b/routes/info.js
@@ -2,6 +2,8 @@ import app from "$app";
import sequelize from '@sequelize/core';
import config from "$config";
import store from "$lib/store";
+import ln from "$lib/ln";
+import { getChannelBalance, getChainBalance } from "lightning";
const { Op } = sequelize;
@@ -37,18 +39,15 @@ app.get("/balances", async (req, res, next) => {
let lnchannel;
let lnwallet;
- let l;
if (config.lna) {
if (config.lna.clightning) {
const funds = await lna.listfunds();
- l = 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 {
- l = await lnp.getInfo({});
- lnchannel = parseInt((await lnp.channelBalance({}).balance));
- lnwallet = parseInt((await lnp.walletBalance({}).total_balance));
+ lnchannel = parseInt((await getChannelBalance({ lnd }).channel_balance));
+ lnwallet = parseInt((await getChainBalance({ lnd }).chain_balance));
}
}