mirror of
https://github.com/Ride-The-Lightning/RTL
synced 2024-11-09 13:10:44 +00:00
e45d6d598a
- Package updates Updated docker NodeJS from 10 to 14 Updated Angular from 11 to 12 Updated Material from 11 to 12 Updated Angular cli from 11 to 12 Updated Karma from 5 to 6 Updated rxjs from 6 to 7 Updated ngrx from 10 to 12 Updated angularx-qrcode from 10 to 11 Updated @angular/flex-layout from 11 to 12 Updated angular-user-idle from 2.2.4 to 2.2.5 Updated typescript from 4.0.2 to 4.2.4 Updated zone.js from 0.10.2 to 0.11.4 Migrated from TSLint to ESLint Installed save-dev crypto-browserify & stream-browserify - Mask password with fixed length #689 - CSRF Token (#696) - Route lock default password (#700) - ECL Invoice amount mislabeled #694 - ECL & LND Fee report time zone offset bug fixes #692 & #693 - Loop remove max routing fee validation #690 - Child route refresh bug - Adding Password Blacklist (#704) - Fee rate in percentage #621 (#705) - ECL Adding BaseFee and FeeRate on Channels - LND Invoice and Payment pagination fix (#707) - Keysend missing QR code bug fix - Login page XS layout fix - Reports tables load time improved (#709) - Report initial table load bug fix
47 lines
2.2 KiB
JavaScript
47 lines
2.2 KiB
JavaScript
var request = require('request-promise');
|
|
var common = require('../../routes/common');
|
|
var logger = require('../shared/logger');
|
|
var options = {};
|
|
|
|
exports.getBalance = (req, res, next) => {
|
|
logger.log({level: 'INFO', fileName: 'Balance', msg: 'Getting Balance..'});
|
|
options = common.getOptions();
|
|
options.url = common.getSelLNServerUrl() + '/v1/balance/' + req.params.source;
|
|
options.qs = req.query;
|
|
request(options).then((body) => {
|
|
logger.log({level: 'DEBUG', fileName: 'Balance', msg: '[Request params, Request Query, Balance Received]', data: [req.params, req.query, body]});
|
|
if (body) {
|
|
if (req.params.source === 'blockchain') {
|
|
if (!body.total_balance) { body.total_balance = 0; }
|
|
if (!body.confirmed_balance) { body.confirmed_balance = 0; }
|
|
if (!body.unconfirmed_balance) { body.unconfirmed_balance = 0; }
|
|
body.btc_total_balance = common.convertToBTC(body.total_balance);
|
|
body.btc_confirmed_balance = common.convertToBTC(body.confirmed_balance);
|
|
body.btc_unconfirmed_balance = common.convertToBTC(body.unconfirmed_balance);
|
|
}
|
|
if (req.params.source === 'channels') {
|
|
if (!body.balance) { body.balance = 0; }
|
|
if (!body.pending_open_balance) { body.pending_open_balance = 0; }
|
|
body.btc_balance = common.convertToBTC(body.balance);
|
|
body.btc_pending_open_balance = common.convertToBTC(body.pending_open_balance);
|
|
}
|
|
logger.log({level: 'INFO', fileName: 'Balance', msg: 'Balance Received'});
|
|
res.status(200).json(body);
|
|
}
|
|
})
|
|
.catch(errRes => {
|
|
let err = JSON.parse(JSON.stringify(errRes));
|
|
if (err.options && err.options.headers && err.options.headers['Grpc-Metadata-macaroon']) {
|
|
delete err.options.headers['Grpc-Metadata-macaroon'];
|
|
}
|
|
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers['Grpc-Metadata-macaroon']) {
|
|
delete err.response.request.headers['Grpc-Metadata-macaroon'];
|
|
}
|
|
logger.log({level: 'ERROR', fileName: 'Balance', msg: 'Fetch Balance Error', error: err});
|
|
return res.status(500).json({
|
|
message: "Fetching balance failed!",
|
|
error: err.error
|
|
});
|
|
});
|
|
};
|