diff options
| author | Adam Soltys <[email protected]> | 2020-05-07 20:15:56 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-05-07 20:58:24 -0700 |
| commit | 47aa48402a0d34dd8ab11f0f315393fcc4f5c61b (patch) | |
| tree | 2e907e64628d26c4707660e854e9bc87b332ff08 /routes/balances.js | |
| parent | 2f0f9e640ead76518f7f8013b16704da89421ee4 (diff) | |
| download | coinos-server-47aa48402a0d34dd8ab11f0f315393fcc4f5c61b.tar.gz coinos-server-47aa48402a0d34dd8ab11f0f315393fcc4f5c61b.zip | |
c-lightning support
Diffstat (limited to 'routes/balances.js')
| -rw-r--r-- | routes/balances.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/routes/balances.js b/routes/balances.js index 9e57750b..78567c44 100644 --- a/routes/balances.js +++ b/routes/balances.js @@ -11,19 +11,33 @@ app.get("/info", async (req, res) => { group: ["asset"], }); + let lnchannel; + let lnwallet; + let lninfo; + + if (config.lna.clightning) { + lninfo = await lna.getinfo(); + const funds = await lna.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 { + lninfo = await lna.getInfo({}); + lnchannel = parseInt((await lna.channelBalance({})).balance); + lnwallet = parseInt((await lna.walletBalance({})).total_balance); + } + const info = { - lnd: await lna.getInfo({}), bitcoind: await bc.getNetworkInfo(), elementsd: await lq.getNetworkInfo(), accounts, assets, bitcoin: parseInt((await bc.getBalance()) * SATS), liquid: parseInt(assets.bitcoin * SATS), - lnchannel: parseInt((await lna.channelBalance({})).balance), - lnwallet: parseInt((await lna.walletBalance({})).total_balance), + lnchannel, + lnwallet, }; - const { bitcoin, liquid, lnchannel, user, lnwallet } = info; + const { bitcoin, liquid, user } = info; info.total = parseInt(bitcoin) + |
