Browse Source

full

dependabot/npm_and_yarn/ini-1.3.7
Evan Feenstra 4 years ago
parent
commit
f372c18f3a
  1. 9
      dist/src/controllers/details.js
  2. 2
      dist/src/controllers/details.js.map
  3. 14
      src/controllers/details.ts

9
dist/src/controllers/details.js

@ -100,8 +100,13 @@ exports.getBalance = (req, res) => __awaiter(void 0, void 0, void 0, function* (
const response = yield lightning_1.channelBalance();
const channelList = yield lightning_1.listChannels();
const { channels } = channelList;
response.reserve = channels.reduce((a, chan) => a + parseInt(chan.local_chan_reserve_sat), 0);
res.json({ success: true, response });
const reserve = channels.reduce((a, chan) => a + parseInt(chan.local_chan_reserve_sat), 0);
res.json({ success: true, response: {
reserve,
full_balance: parseInt(response.balance),
balance: parseInt(response.balance) - reserve,
pending_open_balance: parseInt(response.pending_open_balance),
} });
}
catch (e) {
console.log("ERROR getBalance", e);

2
dist/src/controllers/details.js.map

File diff suppressed because one or more lines are too long

14
src/controllers/details.ts

@ -76,6 +76,11 @@ export const getChannels = async (req, res) => {
});
};
interface BalanceRes {
pending_open_balance: number
balance: number
reserve: number
}
export const getBalance = async (req, res) => {
var date = new Date()
@ -88,8 +93,13 @@ export const getBalance = async (req, res) => {
const response = await channelBalance()
const channelList = await listChannels()
const { channels } = channelList
response.reserve = channels.reduce((a, chan) => a + parseInt(chan.local_chan_reserve_sat), 0)
res.json({ success: true, response });
const reserve = channels.reduce((a, chan) => a + parseInt(chan.local_chan_reserve_sat), 0)
res.json({ success: true, response:<BalanceRes>{
reserve,
full_balance: parseInt(response.balance),
balance: parseInt(response.balance) - reserve,
pending_open_balance: parseInt(response.pending_open_balance),
} });
} catch(e) {
console.log("ERROR getBalance",e)
res.json({ success: false });

Loading…
Cancel
Save