SingleNode complete

SingleNode complete
pull/121/head
ShahanaFarooqui 5 years ago
parent c4f0efa295
commit 9d18a888d8

@ -1,5 +1,6 @@
{ {
"multiPass": "multi", "multiPass": "multi",
"port": "3000",
"SSO": { "SSO": {
"rtlSSO": 0, "rtlSSO": 0,
"rtlCookiePath": "", "rtlCookiePath": "",
@ -10,7 +11,7 @@
"lnNode": "LND Testnet # 1", "lnNode": "LND Testnet # 1",
"lnImplementation": "LND", "lnImplementation": "LND",
"Authentication": { "Authentication": {
"macaroonPath": "/Users/suheb/Downloads", "macaroonPath": "C:\\Users\\suheb\\AppData\\Local\\Lnd\\data\\chain\\bitcoin\\testnet",
"lndConfigPath": "C:\\Users\\suheb\\AppData\\Local\\Lnd\\lnd.conf" "lndConfigPath": "C:\\Users\\suheb\\AppData\\Local\\Lnd\\lnd.conf"
}, },
"Settings": { "Settings": {
@ -20,10 +21,9 @@
"menuType": "Regular", "menuType": "Regular",
"theme": "dark-blue", "theme": "dark-blue",
"satsToBTC": "false", "satsToBTC": "false",
"bitcoindConfigPath": "C:\\Bitcoind\\config\\path", "bitcoindConfigPath": "C:\\bitcoin\\bitcoin_mainnet\\bitcoin.conf",
"enableLogging": "true", "enableLogging": "true",
"port": "3000", "lndServerUrl": "https://localhost:8080/v1"
"lndServerUrl": "https://192.168.1.20:8080/v1"
} }
}, },
{ {
@ -42,7 +42,6 @@
"satsToBTC": "false", "satsToBTC": "false",
"bitcoindConfigPath": "", "bitcoindConfigPath": "",
"enableLogging": "true", "enableLogging": "true",
"port": "3000",
"lndServerUrl": "https://localhost:8080/v1" "lndServerUrl": "https://localhost:8080/v1"
} }
}] }]

@ -8,5 +8,5 @@
<link rel="stylesheet" href="styles.bab7f62b489f0c86770d.css"></head> <link rel="stylesheet" href="styles.bab7f62b489f0c86770d.css"></head>
<body> <body>
<rtl-app></rtl-app> <rtl-app></rtl-app>
<script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="polyfills.181b5a67c421a167a96a.js"></script><script type="text/javascript" src="main.84473d627eea13535d51.js"></script></body> <script type="text/javascript" src="runtime.26209474bfa8dc87a77c.js"></script><script type="text/javascript" src="polyfills.181b5a67c421a167a96a.js"></script><script type="text/javascript" src="main.44d71616582faa38697e.js"></script></body>
</html> </html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -3,59 +3,33 @@ var crypto = require('crypto');
var common = {}; var common = {};
common.multi_node_setup = false; common.multi_node_setup = false;
common.port = 3000;
common.rtl_conf_file_path = ''; common.rtl_conf_file_path = '';
common.lnd_server_url = '';
common.lnd_config_path = '';
common.node_auth_type = 'DEFAULT'; common.node_auth_type = 'DEFAULT';
common.macaroon_path = '';
common.bitcoind_config_path = '';
common.rtl_pass = ''; common.rtl_pass = '';
common.enable_logging = false;
common.log_file = '';
common.rtl_sso = 0; common.rtl_sso = 0;
common.port = 3000;
common.rtl_cookie_path = ''; common.rtl_cookie_path = '';
common.logout_redirect_link = '/login'; common.logout_redirect_link = '/login';
common.cookie = ''; common.cookie = '';
common.secret_key = crypto.randomBytes(64).toString('hex'); common.secret_key = crypto.randomBytes(64).toString('hex');
common.options = {};
common.nodes = []; common.nodes = [];
common.getOptions = (selNodeIndex) => { common.getOptions = (selNodeIndex) => {
if(selNodeIndex === '') { return common.findNode(selNodeIndex).options;
return common.options;
} else {
return common.findNode(selNodeIndex).options;
}
}; };
common.setOptions = (selNodeIndex) => { common.setOptions = () => {
if(selNodeIndex === '') { common.nodes.forEach(node => {
const macaroon = fs.readFileSync(common.macaroon_path + '/admin.macaroon').toString('hex'); node.options = {
common.options = {
url: '',
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': macaroon,
},
form: ''
};
return common.options;
} else {
const selNode = common.findNode(selNodeIndex);
const macaroon = fs.readFileSync(selNode.macaroon_path + '/admin.macaroon').toString('hex');
selNode.options = {
url: '', url: '',
rejectUnauthorized: false, rejectUnauthorized: false,
json: true, json: true,
headers: { headers: {
'Grpc-Metadata-macaroon': macaroon, 'Grpc-Metadata-macaroon': fs.readFileSync(node.macaroon_path + '/admin.macaroon').toString('hex'),
}, },
form: '' form: ''
}; };
return selNode.options; });
}
} }
common.findNode = (selNodeIndex) => { common.findNode = (selNodeIndex) => {

@ -71,34 +71,36 @@ connect.normalizePort = val => {
}; };
connect.setMacaroonPath = (clArgs, config) => { connect.setMacaroonPath = (clArgs, config) => {
common.nodes[0] = {};
common.nodes[0].index = 1;
if(undefined !== clArgs.lndir) { if(undefined !== clArgs.lndir) {
common.macaroon_path = clArgs.lndir; common.nodes[0].macaroon_path = clArgs.lndir;
} else if (undefined !== process.env.MACAROON_PATH) { } else if (undefined !== process.env.MACAROON_PATH) {
common.macaroon_path = process.env.MACAROON_PATH; common.nodes[0].macaroon_path = process.env.MACAROON_PATH;
} else { } else {
if(undefined !== config.Authentication.macroonPath && config.Authentication.macroonPath !== '') { if(undefined !== config.Authentication.macroonPath && config.Authentication.macroonPath !== '') {
common.macaroon_path = config.Authentication.macroonPath; common.nodes[0].macaroon_path = config.Authentication.macroonPath;
} else if(undefined !== config.Authentication.macaroonPath && config.Authentication.macaroonPath !== '') { } else if(undefined !== config.Authentication.macaroonPath && config.Authentication.macaroonPath !== '') {
common.macaroon_path = config.Authentication.macaroonPath; common.nodes[0].macaroon_path = config.Authentication.macaroonPath;
} }
} }
} }
connect.validateSingleNodeConfig = (config) => { connect.validateSingleNodeConfig = (config) => {
if(common.macaroon_path === '' || undefined === common.macaroon_path) { if(common.nodes[0].macaroon_path === '' || undefined === common.nodes[0].macaroon_path) {
errMsg = 'Please set macaroon path through environment or RTL.conf!'; errMsg = 'Please set macaroon path through environment or RTL.conf!';
} }
if(undefined !== process.env.LND_SERVER_URL) { if(undefined !== process.env.LND_SERVER_URL) {
common.lnd_server_url = process.env.LND_SERVER_URL; common.nodes[0].lnd_server_url = process.env.LND_SERVER_URL;
} else { } else {
if((config.Authentication.lndServerUrl === '' || undefined === config.Authentication.lndServerUrl) && (config.Settings.lndServerUrl === '' || undefined === config.Settings.lndServerUrl)) { if((config.Authentication.lndServerUrl === '' || undefined === config.Authentication.lndServerUrl) && (config.Settings.lndServerUrl === '' || undefined === config.Settings.lndServerUrl)) {
errMsg = errMsg + '\nPlease set LND Server URL through environment or RTL.conf!'; errMsg = errMsg + '\nPlease set LND Server URL through environment or RTL.conf!';
} else { } else {
if (config.Settings.lndServerUrl !== '' && undefined !== config.Settings.lndServerUrl) { if (config.Settings.lndServerUrl !== '' && undefined !== config.Settings.lndServerUrl) {
common.lnd_server_url = config.Settings.lndServerUrl; common.nodes[0].lnd_server_url = config.Settings.lndServerUrl;
} else if (config.Authentication.lndServerUrl !== '' && undefined !== config.Authentication.lndServerUrl) { } else if (config.Authentication.lndServerUrl !== '' && undefined !== config.Authentication.lndServerUrl) {
common.lnd_server_url = config.Authentication.lndServerUrl; common.nodes[0].lnd_server_url = config.Authentication.lndServerUrl;
} }
} }
} }
@ -107,17 +109,17 @@ connect.validateSingleNodeConfig = (config) => {
common.node_auth_type = process.env.NODE_AUTH_TYPE; common.node_auth_type = process.env.NODE_AUTH_TYPE;
} else { } else {
if(config.Authentication.nodeAuthType === '' || undefined === config.Authentication.nodeAuthType) { if(config.Authentication.nodeAuthType === '' || undefined === config.Authentication.nodeAuthType) {
errMsg = errMsg + '\nPlease set Node Auth Type through environment/RTL.conf!'; errMsg = errMsg + '\nPlease set Node Auth Type through environment or RTL.conf!';
} else { } else {
common.node_auth_type = config.Authentication.nodeAuthType; common.node_auth_type = config.Authentication.nodeAuthType;
} }
} }
if(undefined !== process.env.LND_CONFIG_PATH) { if(undefined !== process.env.LND_CONFIG_PATH) {
common.lnd_config_path = process.env.LND_CONFIG_PATH; common.nodes[0].lnd_config_path = process.env.LND_CONFIG_PATH;
} else { } else {
if(config.Authentication.lndConfigPath !== '' && undefined !== config.Authentication.lndConfigPath) { if(config.Authentication.lndConfigPath !== '' && undefined !== config.Authentication.lndConfigPath) {
common.lnd_config_path = config.Authentication.lndConfigPath; common.nodes[0].lnd_config_path = config.Authentication.lndConfigPath;
} else { } else {
if(upperCase(common.node_auth_type) === 'DEFAULT') { if(upperCase(common.node_auth_type) === 'DEFAULT') {
errMsg = errMsg + '\nDefault Node Authentication can be set with LND Config Path only. Please set LND Config Path through environment or RTL.conf!'; errMsg = errMsg + '\nDefault Node Authentication can be set with LND Config Path only. Please set LND Config Path through environment or RTL.conf!';
@ -126,42 +128,42 @@ connect.validateSingleNodeConfig = (config) => {
} }
if(undefined !== process.env.BITCOIND_CONFIG_PATH) { if(undefined !== process.env.BITCOIND_CONFIG_PATH) {
common.bitcoind_config_path = process.env.BITCOIND_CONFIG_PATH; common.nodes[0].bitcoind_config_path = process.env.BITCOIND_CONFIG_PATH;
} else { } else {
if(config.Settings.bitcoindConfigPath !== '' || undefined !== config.Settings.bitcoindConfigPath) { if(config.Settings.bitcoindConfigPath !== '' && undefined !== config.Settings.bitcoindConfigPath) {
common.bitcoind_config_path = config.Settings.bitcoindConfigPath; common.nodes[0].bitcoind_config_path = config.Settings.bitcoindConfigPath;
} else if(config.Authentication.bitcoindConfigPath !== '' || undefined !== config.Authentication.bitcoindConfigPath) { } else if(config.Authentication.bitcoindConfigPath !== '' && undefined !== config.Authentication.bitcoindConfigPath) {
common.bitcoind_config_path = config.Authentication.bitcoindConfigPath; common.nodes[0].bitcoind_config_path = config.Authentication.bitcoindConfigPath;
} }
} }
if (undefined !== process.env.RTL_PASS) { if (undefined !== process.env.RTL_PASS) {
common.rtl_pass = process.env.RTL_PASS; common.rtl_pass = process.env.RTL_PASS;
} else if (config.Authentication.rtlPass !== '' || undefined !== config.Authentication.rtlPass) { } else if (config.Authentication.rtlPass !== '' && undefined !== config.Authentication.rtlPass) {
common.rtl_pass = config.Authentication.rtlPass; common.rtl_pass = config.Authentication.rtlPass;
} }
if (upperCase(common.node_auth_type) === 'CUSTOM' && (common.rtl_pass === '' || undefined === common.rtl_pass)) { if (upperCase(common.node_auth_type) === 'CUSTOM' && (common.rtl_pass === '' || undefined === common.rtl_pass)) {
errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password through environment/RTL.conf'; errMsg = errMsg + '\nCustom Node Authentication can be set with RTL password only. Please set RTL Password through environment or RTL.conf';
} }
if (undefined !== process.env.ENABLE_LOGGING) { if (undefined !== process.env.ENABLE_LOGGING) {
common.enable_logging = process.env.ENABLE_LOGGING; common.nodes[0].enable_logging = process.env.ENABLE_LOGGING;
} else if (undefined !== config.Settings.enableLogging) { } else if (undefined !== config.Settings.enableLogging) {
common.enable_logging = config.Settings.enableLogging; common.nodes[0].enable_logging = config.Settings.enableLogging;
} else if (undefined !== config.Authentication.enableLogging) { } else if (undefined !== config.Authentication.enableLogging) {
common.enable_logging = config.Authentication.enableLogging; common.nodes[0].enable_logging = config.Authentication.enableLogging;
} }
if (common.enable_logging) { if (common.nodes[0].enable_logging) {
common.log_file = common.rtl_conf_file_path + '/logs/RTL.log'; common.nodes[0].log_file = common.rtl_conf_file_path + '/logs/RTL.log';
let exists = fs.existsSync(common.log_file); let exists = fs.existsSync(common.nodes[0].log_file);
if (exists) { if (exists) {
fs.writeFile(common.log_file, '', () => { }); fs.writeFile(common.nodes[0].log_file, '', () => { });
} else { } else {
try { try {
var dirname = path.dirname(common.log_file); var dirname = path.dirname(common.nodes[0].log_file);
connect.createDirectory(dirname); connect.createDirectory(dirname);
var createStream = fs.createWriteStream(common.log_file); var createStream = fs.createWriteStream(common.nodes[0].log_file);
createStream.end(); createStream.end();
} }
catch (err) { catch (err) {
@ -179,12 +181,14 @@ connect.validateSingleNodeConfig = (config) => {
connect.setSSOParams(config); connect.setSSOParams(config);
if (errMsg !== '') { if (errMsg !== '') {
throw new Error(errMsg); throw new Error(errMsg);
} }
} }
connect.validateMultiNodeConfig = (config) => { connect.validateMultiNodeConfig = (config) => {
common.node_auth_type = 'CUSTOM'; common.node_auth_type = 'CUSTOM';
common.rtl_pass = config.multiPass; common.rtl_pass = config.multiPass;
common.port = (undefined !== config.port) ? connect.normalizePort(config.port) : 3000;
config.nodes.forEach((node, idx) => { config.nodes.forEach((node, idx) => {
common.nodes[idx] = {}; common.nodes[idx] = {};
@ -206,7 +210,6 @@ connect.validateMultiNodeConfig = (config) => {
common.nodes[idx].lnd_config_path = (undefined !== node.Authentication.lndConfigPath) ? node.Authentication.lndConfigPath : ''; common.nodes[idx].lnd_config_path = (undefined !== node.Authentication.lndConfigPath) ? node.Authentication.lndConfigPath : '';
common.nodes[idx].bitcoind_config_path = (undefined !== node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : ''; common.nodes[idx].bitcoind_config_path = (undefined !== node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
common.nodes[idx].enable_logging = (undefined !== node.Settings.enableLogging) ? node.Settings.enableLogging : false; common.nodes[idx].enable_logging = (undefined !== node.Settings.enableLogging) ? node.Settings.enableLogging : false;
common.nodes[idx].port = (undefined !== node.Settings.port) ? connect.normalizePort(node.Settings.port) : 3000;
if (common.nodes[idx].enable_logging) { if (common.nodes[idx].enable_logging) {
common.nodes[idx].log_file = common.rtl_conf_file_path + '/logs/RTL-Node-' + node.index + '.log'; common.nodes[idx].log_file = common.rtl_conf_file_path + '/logs/RTL-Node-' + node.index + '.log';
@ -310,7 +313,7 @@ connect.logEnvVariables = () => {
logger.info('\r\nConfig Setup Variable INDEX: ' + node.index, node); logger.info('\r\nConfig Setup Variable INDEX: ' + node.index, node);
logger.info('\r\nConfig Setup Variable LN NODE: ' + node.ln_node, node); logger.info('\r\nConfig Setup Variable LN NODE: ' + node.ln_node, node);
logger.info('\r\nConfig Setup Variable LN IMPLEMENTATION: ' + node.ln_implementation, node); logger.info('\r\nConfig Setup Variable LN IMPLEMENTATION: ' + node.ln_implementation, node);
logger.info('\r\nConfig Setup Variable PORT: ' + node.port, node); logger.info('\r\nConfig Setup Variable PORT: ' + common.port, node);
logger.info('\r\nConfig Setup Variable MACAROON_PATH: ' + node.macaroon_path, node); logger.info('\r\nConfig Setup Variable MACAROON_PATH: ' + node.macaroon_path, node);
logger.info('\r\nConfig Setup Variable LND_SERVER_URL: ' + node.lnd_server_url, node); logger.info('\r\nConfig Setup Variable LND_SERVER_URL: ' + node.lnd_server_url, node);
logger.info('\r\nConfig Setup Variable RTL_CONFIG_PATH: ' + node.rtl_conf_file_path, node); logger.info('\r\nConfig Setup Variable RTL_CONFIG_PATH: ' + node.rtl_conf_file_path, node);
@ -318,15 +321,15 @@ connect.logEnvVariables = () => {
logger.info('\r\nConfig Setup Variable BITCOIND_CONFIG_PATH: ' + node.bitcoind_config_path, node); logger.info('\r\nConfig Setup Variable BITCOIND_CONFIG_PATH: ' + node.bitcoind_config_path, node);
}); });
} else { } else {
if (!common.enable_logging) { return; } if (!common.nodes[0].enable_logging) { return; }
logger.info('\r\nConfig Setup Variable NODE_SETUP: SINGLE'); logger.info('\r\nConfig Setup Variable NODE_SETUP: SINGLE');
logger.info('\r\nConfig Setup Variable PORT: ' + common.port); logger.info('\r\nConfig Setup Variable PORT: ' + common.port);
logger.info('\r\nConfig Setup Variable LND_SERVER_URL: ' + common.lnd_server_url); logger.info('\r\nConfig Setup Variable LND_SERVER_URL: ' + common.nodes[0].lnd_server_url);
logger.info('\r\nConfig Setup Variable MACAROON_PATH: ' + common.macaroon_path); logger.info('\r\nConfig Setup Variable MACAROON_PATH: ' + common.nodes[0].macaroon_path);
logger.info('\r\nConfig Setup Variable NODE_AUTH_TYPE: ' + common.node_auth_type); logger.info('\r\nConfig Setup Variable NODE_AUTH_TYPE: ' + common.node_auth_type);
logger.info('\r\nConfig Setup Variable LND_CONFIG_PATH: ' + common.lnd_config_path); logger.info('\r\nConfig Setup Variable LND_CONFIG_PATH: ' + common.nodes[0].lnd_config_path);
logger.info('\r\nConfig Setup Variable RTL_CONFIG_PATH: ' + common.rtl_conf_file_path); logger.info('\r\nConfig Setup Variable RTL_CONFIG_PATH: ' + common.rtl_conf_file_path);
logger.info('\r\nConfig Setup Variable BITCOIND_CONFIG_PATH: ' + common.bitcoind_config_path); logger.info('\r\nConfig Setup Variable BITCOIND_CONFIG_PATH: ' + common.nodes[0].bitcoind_config_path);
logger.info('\r\nConfig Setup Variable RTL_SSO: ' + common.rtl_sso); logger.info('\r\nConfig Setup Variable RTL_SSO: ' + common.rtl_sso);
logger.info('\r\nConfig Setup Variable RTL_COOKIE_PATH: ' + common.rtl_cookie_path); logger.info('\r\nConfig Setup Variable RTL_COOKIE_PATH: ' + common.rtl_cookie_path);
logger.info('\r\nConfig Setup Variable LOGOUT_REDIRECT_LINK: ' + common.logout_redirect_link); logger.info('\r\nConfig Setup Variable LOGOUT_REDIRECT_LINK: ' + common.logout_redirect_link);

@ -1,5 +1,4 @@
var ini = require('ini'); var ini = require('ini');
var path = require('path');
var fs = require('fs'); var fs = require('fs');
var logger = require('./logger'); var logger = require('./logger');
var common = require('../common'); var common = require('../common');
@ -17,14 +16,13 @@ exports.getRTLConfig = (req, res, next) => {
}); });
} else { } else {
const jsonConfig = ini.parse(data); const jsonConfig = ini.parse(data);
authSettings = { const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link };
const authentication = {
nodeAuthType: common.node_auth_type, nodeAuthType: common.node_auth_type,
lndConfigPath: common.lnd_config_path, lndConfigPath: common.nodes[0].lnd_config_path,
bitcoindConfigPath: common.bitcoind_config_path, bitcoindConfigPath: common.nodes[0].bitcoind_config_path
rtlSSO: common.rtl_sso,
logoutRedirectLink: common.logout_redirect_link
}; };
res.status(200).json({ nodes: [{settings: jsonConfig.Settings, authSettings: authSettings}] }); res.status(200).json({ sso: sso, nodes: [{settings: jsonConfig.Settings, authentication: authentication}] });
} }
}); });
} else { } else {
@ -44,55 +42,74 @@ exports.getRTLConfig = (req, res, next) => {
} }
} else { } else {
const multiNodeConfig = JSON.parse(data); const multiNodeConfig = JSON.parse(data);
const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link };
var nodesArr = []; var nodesArr = [];
multiNodeConfig.nodes.forEach(node => { multiNodeConfig.nodes.forEach(node => {
authSettings = { const authentication = {};
nodeAuthType: 'CUSTOM', authentication.nodeAuthType = 'CUSTOM';
lndConfigPath: node.lnd_config_path, if(node.Authentication.lndConfigPath) {
bitcoindConfigPath: node.bitcoind_config_path, authentication.lndConfigPath = node.Authentication.lndConfigPath;
rtlSSO: common.rtl_sso, }
logoutRedirectLink: common.logout_redirect_link if(node.Settings.bitcoindConfigPath) {
}; authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath;
nodesArr.push({settings: node.Settings, authSettings: authSettings}) }
nodesArr.push({settings: node.Settings, authentication: authentication})
}); });
res.status(200).json({ nodes: nodesArr }); res.status(200).json({ sso: sso, nodes: nodesArr });
} }
}); });
} }
}; };
exports.updateUISettings = (req, res, next) => { exports.updateUISettings = (req, res, next) => {
var RTLConfFile = common.rtl_conf_file_path + '/RTL.conf'; var RTLConfFile = '';
var config = ini.parse(fs.readFileSync(RTLConfFile, 'utf-8')); if(common.multi_node_setup) {
delete config.Settings; RTLConfFile = common.rtl_conf_file_path + '/RTL-Multi-Node-Conf.json';
fs.writeFileSync(RTLConfFile, ini.stringify(config)); } else {
fs.appendFile(RTLConfFile, ini.stringify(req.body.updatedSettings, { section: 'Settings' }), function(err) { RTLConfFile = common.rtl_conf_file_path + '/RTL.conf';
if (err) { var config = ini.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
logger.error('\r\nConf: 71: ' + JSON.stringify(Date.now()) + ': ERROR: Updating UI Settings Failed!'); var settingsTemp = config.Settings;
res.status(500).json({ settingsTemp.flgSidenavOpened = req.body.updatedSettings.flgSidenavOpened;
message: "Updating UI Settings Failed!", settingsTemp.flgSidenavPinned = req.body.updatedSettings.flgSidenavPinned;
error: 'Updating UI Settings Failed!' settingsTemp.menu = req.body.updatedSettings.menu;
}); settingsTemp.menuType = req.body.updatedSettings.menuType;
} else { settingsTemp.theme = req.body.updatedSettings.theme;
logger.info('\r\nConf: 77: ' + JSON.stringify(Date.now()) + ': INFO: Updating UI Settings Succesful!'); settingsTemp.satsToBTC = req.body.updatedSettings.satsToBTC;
res.status(201).json({message: 'UI Settings Updated Successfully'}); delete config.Settings;
} fs.writeFileSync(RTLConfFile, ini.stringify(config));
}); fs.appendFile(RTLConfFile, ini.stringify(settingsTemp, { section: 'Settings' }), function(err) {
if (err) {
logger.error('\r\nConf: 71: ' + JSON.stringify(Date.now()) + ': ERROR: Updating UI Settings Failed!');
res.status(500).json({
message: "Updating UI Settings Failed!",
error: 'Updating UI Settings Failed!'
});
} else {
logger.info('\r\nConf: 77: ' + JSON.stringify(Date.now()) + ': INFO: Updating UI Settings Succesful!');
res.status(201).json({message: 'UI Settings Updated Successfully'});
}
});
}
}; };
exports.getConfig = (req, res, next) => { exports.getConfig = (req, res, next) => {
let confFile = ''; let confFile = '';
let JSONFormat = false;
switch (req.params.nodeType) { switch (req.params.nodeType) {
case 'lnd': case 'lnd':
confFile = common.lnd_config_path JSONFormat = false;
confFile = common.nodes[0].lnd_config_path;
break; break;
case 'bitcoind': case 'bitcoind':
confFile = common.bitcoind_config_path JSONFormat = false;
confFile = common.nodes[0].bitcoind_config_path;
break; break;
case 'rtl': case 'rtl':
confFile = common.rtl_conf_file_path + '/RTL.conf'; JSONFormat = (common.multi_node_setup) ? true : false;
confFile = (common.multi_node_setup) ? common.rtl_conf_file_path + '/RTL-Multi-Node-Conf.json' : common.rtl_conf_file_path + '/RTL.conf';
break; break;
default: default:
JSONFormat = false;
confFile = ''; confFile = '';
break; break;
} }
@ -105,14 +122,24 @@ exports.getConfig = (req, res, next) => {
error: err error: err
}); });
} else { } else {
const jsonConfig = ini.parse(data); const jsonConfig = (JSONFormat) ? JSON.parse(data) : ini.parse(data);
if (undefined !== jsonConfig.Authentication && undefined !== jsonConfig.Authentication.rtlPass) { if (undefined !== jsonConfig.Authentication && undefined !== jsonConfig.Authentication.rtlPass) {
jsonConfig.Authentication.rtlPass = jsonConfig.Authentication.rtlPass.replace(/./g, '*'); jsonConfig.Authentication.rtlPass = jsonConfig.Authentication.rtlPass.replace(/./g, '*');
} }
if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) { if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) {
jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*'); jsonConfig.Bitcoind['bitcoind.rpcpass'] = jsonConfig.Bitcoind['bitcoind.rpcpass'].replace(/./g, '*');
} }
res.status(200).json(ini.stringify(jsonConfig)); if (undefined !== jsonConfig['bitcoind.rpcpass']) {
jsonConfig['bitcoind.rpcpass'] = jsonConfig['bitcoind.rpcpass'].replace(/./g, '*');
}
if (undefined !== jsonConfig['rpcpassword']) {
jsonConfig['rpcpassword'] = jsonConfig['rpcpassword'].replace(/./g, '*');
}
if (undefined !== jsonConfig.multiPass) {
jsonConfig.multiPass = jsonConfig.multiPass.replace(/./g, '*');
}
const responseJSON = (JSONFormat) ? jsonConfig : ini.stringify(jsonConfig);
res.status(200).json({format: (JSONFormat) ? 'JSON' : 'INI', data: responseJSON});
} }
}); });
}; };

@ -35,7 +35,7 @@ exports.authenticateUser = (req, res, next) => {
if (common.cookie === access_key) { if (common.cookie === access_key) {
connect.refreshCookie(common.rtl_cookie_path); connect.refreshCookie(common.rtl_cookie_path);
const token = jwt.sign( const token = jwt.sign(
{ user: 'Custom_User', lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path }, { user: 'Custom_User', lndConfigPath: common.nodes[0].lnd_config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key common.secret_key
); );
res.status(200).json({ token: token }); res.status(200).json({ token: token });
@ -47,13 +47,29 @@ exports.authenticateUser = (req, res, next) => {
} }
} else { } else {
const password = atob(req.body.password); const password = atob(req.body.password);
selNode = req.body.node; if (common.multi_node_setup) {
if (undefined === selNode || selNode === '') { console.log('\n\nHERE:\n');
console.log(common.nodes);
console.log(common.rtl_pass);
if (common.rtl_pass === password) {
var rpcUser = 'Multi_Node_User';
const token = jwt.sign(
{ user: rpcUser, lndConfigPath: common.nodes[0].lnd_config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key
);
res.status(200).json({ token: token });
} else {
res.status(401).json({
message: "Authentication Failed!",
error: "Password Validation Failed!"
});
}
} else {
if(upperCase(common.node_auth_type) === 'CUSTOM') { if(upperCase(common.node_auth_type) === 'CUSTOM') {
if (common.rtl_pass === password) { if (common.rtl_pass === password) {
var rpcUser = 'Custom_User'; var rpcUser = 'Single_Node_User';
const token = jwt.sign( const token = jwt.sign(
{ user: rpcUser, lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path }, { user: rpcUser, lndConfigPath: common.nodes[0].lnd_config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key common.secret_key
); );
res.status(200).json({ token: token }); res.status(200).json({ token: token });
@ -64,7 +80,7 @@ exports.authenticateUser = (req, res, next) => {
}); });
} }
} else { } else {
fs.readFile(common.lnd_config_path, 'utf8', function (err, data) { fs.readFile(common.nodes[0].lnd_config_path, 'utf8', function (err, data) {
if (err) { if (err) {
logger.error('\r\nAuthenticate: 45: ' + JSON.stringify(Date.now()) + ': ERROR: LND Config Reading Failed!'); logger.error('\r\nAuthenticate: 45: ' + JSON.stringify(Date.now()) + ': ERROR: LND Config Reading Failed!');
err.description = 'You might be connecting RTL remotely to your LND node OR You might be missing rpcpass in your lnd.conf.'; err.description = 'You might be connecting RTL remotely to your LND node OR You might be missing rpcpass in your lnd.conf.';
@ -81,7 +97,7 @@ exports.authenticateUser = (req, res, next) => {
var rpcUser = (undefined !== jsonLNDConfig.Bitcoind && undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : ''; var rpcUser = (undefined !== jsonLNDConfig.Bitcoind && undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : '';
rpcUser = (rpcUser === '' && undefined !== jsonLNDConfig['bitcoind.rpcuser']) ? jsonLNDConfig['bitcoind.rpcuser'] : ''; rpcUser = (rpcUser === '' && undefined !== jsonLNDConfig['bitcoind.rpcuser']) ? jsonLNDConfig['bitcoind.rpcuser'] : '';
const token = jwt.sign( const token = jwt.sign(
{ user: rpcUser, lndConfigPath: common.lnd_config_path, macaroonPath: common.macaroon_path }, { user: rpcUser, lndConfigPath: common.nodes[0].lnd_config_path, macaroonPath: common.nodes[0].macaroon_path },
common.secret_key common.secret_key
); );
res.status(200).json({ token: token }); res.status(200).json({ token: token });
@ -100,7 +116,6 @@ exports.authenticateUser = (req, res, next) => {
} }
}); });
} }
} else {
} }
} }
}; };

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getBalance = (req, res, next) => { exports.getBalance = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/balance/' + req.params.source; options.url = common.findNode(1).lnd_server_url + '/balance/' + req.params.source;
options.qs = req.query; options.qs = req.query;
request(options).then((body) => { request(options).then((body) => {
logger.info('\r\nBalance: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + 'Request params: ' + JSON.stringify(req.params) + 'Request Query: ' + JSON.stringify(req.query) + ' Balance Received: ' + JSON.stringify(body)); logger.info('\r\nBalance: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + 'Request params: ' + JSON.stringify(req.params) + 'Request Query: ' + JSON.stringify(req.query) + ' Balance Received: ' + JSON.stringify(body));

@ -6,9 +6,9 @@ var options = {};
getAliasForChannel = (channel, channelType) => { getAliasForChannel = (channel, channelType) => {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
if (undefined === channelType || channelType === 'all') { if (undefined === channelType || channelType === 'all') {
options.url = common.lnd_server_url + '/graph/node/' + channel.remote_pubkey; options.url = common.findNode(1).lnd_server_url + '/graph/node/' + channel.remote_pubkey;
} else { } else {
options.url = common.lnd_server_url + '/graph/node/' + channel.channel.remote_node_pub; options.url = common.findNode(1).lnd_server_url + '/graph/node/' + channel.channel.remote_node_pub;
} }
request(options).then(function(aliasBody) { request(options).then(function(aliasBody) {
logger.info('\r\nChannels: 13: ' + JSON.stringify(Date.now()) + ': INFO: Alias: ' + JSON.stringify(aliasBody.node.alias)); logger.info('\r\nChannels: 13: ' + JSON.stringify(Date.now()) + ': INFO: Alias: ' + JSON.stringify(aliasBody.node.alias));
@ -25,11 +25,11 @@ getAliasForChannel = (channel, channelType) => {
} }
exports.getChannels = (req, res, next) => { exports.getChannels = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
if (undefined === req.params.channelType || req.params.channelType === 'all') { if (undefined === req.params.channelType || req.params.channelType === 'all') {
options.url = common.lnd_server_url + '/channels'; options.url = common.findNode(1).lnd_server_url + '/channels';
} else { } else {
options.url = common.lnd_server_url + '/channels/' + req.params.channelType; options.url = common.findNode(1).lnd_server_url + '/channels/' + req.params.channelType;
} }
options.qs = req.query; options.qs = req.query;
request(options).then(function (body) { request(options).then(function (body) {
@ -74,8 +74,8 @@ exports.getChannels = (req, res, next) => {
}; };
exports.postChannel = (req, res, next) => { exports.postChannel = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/channels'; options.url = common.findNode(1).lnd_server_url + '/channels';
options.form = { options.form = {
node_pubkey_string: req.body.node_pubkey, node_pubkey_string: req.body.node_pubkey,
local_funding_amount: req.body.local_funding_amount, local_funding_amount: req.body.local_funding_amount,
@ -108,8 +108,8 @@ exports.postChannel = (req, res, next) => {
}; };
exports.postTransactions = (req, res, next) => { exports.postTransactions = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/channels/transactions'; options.url = common.findNode(1).lnd_server_url + '/channels/transactions';
if(req.body.paymentReq) { if(req.body.paymentReq) {
options.form = JSON.stringify({ options.form = JSON.stringify({
payment_request: req.body.paymentReq payment_request: req.body.paymentReq
@ -149,9 +149,9 @@ exports.postTransactions = (req, res, next) => {
exports.closeChannel = (req, res, next) => { exports.closeChannel = (req, res, next) => {
req.setTimeout(60000 * 10); // timeout 10 mins req.setTimeout(60000 * 10); // timeout 10 mins
options = common.getOptions(''); options = common.getOptions(1);
let channelpoint = req.params.channelPoint.replace(':', '/'); let channelpoint = req.params.channelPoint.replace(':', '/');
options.url = common.lnd_server_url + '/channels/' + channelpoint + '?force=' + req.query.force; options.url = common.findNode(1).lnd_server_url + '/channels/' + channelpoint + '?force=' + req.query.force;
logger.info('\r\nChannels: 144: ' + JSON.stringify(Date.now()) + ': INFO: Closing Channel: ' + options.url); logger.info('\r\nChannels: 144: ' + JSON.stringify(Date.now()) + ': INFO: Closing Channel: ' + options.url);
request.delete(options).then((body) => { request.delete(options).then((body) => {
logger.info('\r\nChannels: 146: ' + JSON.stringify(Date.now()) + ': INFO: Close Channel Response: ' + JSON.stringify(body)); logger.info('\r\nChannels: 146: ' + JSON.stringify(Date.now()) + ': INFO: Close Channel Response: ' + JSON.stringify(body));
@ -174,8 +174,8 @@ exports.closeChannel = (req, res, next) => {
} }
exports.postChanPolicy = (req, res, next) => { exports.postChanPolicy = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/chanpolicy'; options.url = common.findNode(1).lnd_server_url + '/chanpolicy';
if(req.body.chanPoint === 'all') { if(req.body.chanPoint === 'all') {
options.form = JSON.stringify({ options.form = JSON.stringify({
global: true, global: true,

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getFees = (req, res, next) => { exports.getFees = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/fees'; options.url = common.findNode(1).lnd_server_url + '/fees';
request(options).then((body) => { request(options).then((body) => {
logger.info('\r\nFees: 8: ' + JSON.stringify(Date.now()) + ': INFO: Fee Received: ' + JSON.stringify(body)); logger.info('\r\nFees: 8: ' + JSON.stringify(Date.now()) + ': INFO: Fee Received: ' + JSON.stringify(body));
if(undefined === body || body.error) { if(undefined === body || body.error) {

@ -4,8 +4,10 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getInfo = (req, res, next) => { exports.getInfo = (req, res, next) => {
options = common.setOptions(''); common.setOptions();
options.url = common.lnd_server_url + '/getinfo'; options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/getinfo';
console.log(common.nodes);
logger.info('\r\nCalling getinfo from lnd server url: INFO: ' + options.url); logger.info('\r\nCalling getinfo from lnd server url: INFO: ' + options.url);
request(options).then((body) => { request(options).then((body) => {
logger.info('\r\nGetInfo: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + JSON.stringify(body)); logger.info('\r\nGetInfo: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + JSON.stringify(body));

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getDescribeGraph = (req, res, next) => { exports.getDescribeGraph = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/graph'; options.url = common.findNode(1).lnd_server_url + '/graph';
request.get(options).then((body) => { request.get(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
@ -28,8 +28,8 @@ exports.getDescribeGraph = (req, res, next) => {
}; };
exports.getGraphInfo = (req, res, next) => { exports.getGraphInfo = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/graph/info'; options.url = common.findNode(1).lnd_server_url + '/graph/info';
request.get(options).then((body) => { request.get(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
@ -57,8 +57,8 @@ exports.getGraphInfo = (req, res, next) => {
}; };
exports.getGraphNode = (req, res, next) => { exports.getGraphNode = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/graph/node/' + req.params.pubKey; options.url = common.findNode(1).lnd_server_url + '/graph/node/' + req.params.pubKey;
request(options).then((body) => { request(options).then((body) => {
logger.info('\r\nGraph: 59: ' + JSON.stringify(Date.now()) + ': INFO: Node Info Received: ' + JSON.stringify(body)); logger.info('\r\nGraph: 59: ' + JSON.stringify(Date.now()) + ': INFO: Node Info Received: ' + JSON.stringify(body));
if(undefined === body || body.error) { if(undefined === body || body.error) {
@ -81,8 +81,8 @@ exports.getGraphNode = (req, res, next) => {
}; };
exports.getGraphEdge = (req, res, next) => { exports.getGraphEdge = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/graph/edge/' + req.params.chanid; options.url = common.findNode(1).lnd_server_url + '/graph/edge/' + req.params.chanid;
request(options).then((body) => { request(options).then((body) => {
logger.info('\r\nGraph: 79: ' + JSON.stringify(Date.now()) + ': INFO: Edge Info Received: ' + JSON.stringify(body)); logger.info('\r\nGraph: 79: ' + JSON.stringify(Date.now()) + ': INFO: Edge Info Received: ' + JSON.stringify(body));
if(undefined === body || body.error) { if(undefined === body || body.error) {

@ -3,8 +3,8 @@ var options = require("../connect");
var common = require('../common'); var common = require('../common');
exports.getGraphInfo = (req, res, next) => { exports.getGraphInfo = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/graph/info'; options.url = common.findNode(1).lnd_server_url + '/graph/info';
request.get(options, (error, response, body) => { request.get(options, (error, response, body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getInvoice = (req, res, next) => { exports.getInvoice = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/invoice/' + req.params.rHashStr; options.url = common.findNode(1).lnd_server_url + '/invoice/' + req.params.rHashStr;
request(options).then((body) => { request(options).then((body) => {
logger.info('\r\nInvoice: 8: ' + JSON.stringify(Date.now()) + ': INFO: Invoice Info Received: ' + JSON.stringify(body)); logger.info('\r\nInvoice: 8: ' + JSON.stringify(Date.now()) + ': INFO: Invoice Info Received: ' + JSON.stringify(body));
if(undefined === body || body.error) { if(undefined === body || body.error) {
@ -25,8 +25,8 @@ exports.getInvoice = (req, res, next) => {
}; };
exports.listInvoices = (req, res, next) => { exports.listInvoices = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/invoices'; options.url = common.findNode(1).lnd_server_url + '/invoices';
request(options).then((body) => { request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
@ -59,8 +59,8 @@ exports.listInvoices = (req, res, next) => {
}; };
exports.addInvoice = (req, res, next) => { exports.addInvoice = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/invoices'; options.url = common.findNode(1).lnd_server_url + '/invoices';
options.form = JSON.stringify({ options.form = JSON.stringify({
memo: req.body.memo, memo: req.body.memo,
value: req.body.amount value: req.body.amount

@ -1,21 +1,11 @@
var fs = require('fs'); var fs = require('fs');
var common = require('../common'); var common = require('../common');
exports.info = (msgStr, selNode = {}) => { exports.info = (msgStr, selNode = common.nodes[0]) => {
if (msgStr.indexOf('Config Setup Variable') === -1) { if (msgStr.indexOf('Config Setup Variable') === -1) {
console.log('Console: ' + msgStr); console.log('Console: ' + msgStr);
} }
if(!common.multi_node_setup && common.enable_logging) { if(selNode.enable_logging) {
fs.appendFile(common.log_file, msgStr, function(err) {
if (err) {
return ({ error: 'Updating Log Failed!' });
} else {
return ({ message: 'Log Updated Successfully' });
}
});
}
if(common.multi_node_setup && selNode.enable_logging) {
fs.appendFile(selNode.log_file, msgStr, function(err) { fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) { if (err) {
return ({ error: 'Updating Log Failed!' }); return ({ error: 'Updating Log Failed!' });
@ -26,19 +16,9 @@ exports.info = (msgStr, selNode = {}) => {
} }
} }
exports.error = (msgStr, selNode = {}) => { exports.error = (msgStr, selNode = common.nodes[0]) => {
console.error('Console: ' + msgStr); console.error('Console: ' + msgStr);
if(!common.multi_node_setup && common.enable_logging) { if(selNode.enable_logging) {
fs.appendFile(common.log_file, msgStr, function(err) {
if (err) {
return ({ error: 'Updating Log Failed!' });
} else {
return ({ message: 'Log Updated Successfully' });
}
});
}
if(common.multi_node_setup && selNode.enable_logging) {
fs.appendFile(selNode.log_file, msgStr, function(err) { fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) { if (err) {
return ({ error: 'Updating Log Failed!' }); return ({ error: 'Updating Log Failed!' });

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getNewAddress = (req, res, next) => { exports.getNewAddress = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/newaddress?type=' + req.query.type; options.url = common.findNode(1).lnd_server_url + '/newaddress?type=' + req.query.type;
request(options).then((body) => { request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.decodePayment = (req, res, next) => { exports.decodePayment = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/payreq/' + req.params.payRequest; options.url = common.findNode(1).lnd_server_url + '/payreq/' + req.params.payRequest;
request(options).then((body) => { request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getPayments = (req, res, next) => { exports.getPayments = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/payments'; options.url = common.findNode(1).lnd_server_url + '/payments';
request(options).then((body) => { request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');

@ -5,7 +5,7 @@ var options = {};
getAliasForPeers = (peer) => { getAliasForPeers = (peer) => {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
options.url = common.lnd_server_url + '/graph/node/' + peer.pub_key; options.url = common.findNode(1).lnd_server_url + '/graph/node/' + peer.pub_key;
request(options) request(options)
.then(function(aliasBody) { .then(function(aliasBody) {
logger.info('\r\nPeers: 11: ' + JSON.stringify(Date.now()) + ': INFO: Alias: ' + JSON.stringify(aliasBody.node.alias)); logger.info('\r\nPeers: 11: ' + JSON.stringify(Date.now()) + ': INFO: Alias: ' + JSON.stringify(aliasBody.node.alias));
@ -17,8 +17,8 @@ getAliasForPeers = (peer) => {
} }
exports.getPeers = (req, res, next) => { exports.getPeers = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/peers'; options.url = common.findNode(1).lnd_server_url + '/peers';
request(options).then(function (body) { request(options).then(function (body) {
let peers = (undefined === body.peers) ? [] : body.peers; let peers = (undefined === body.peers) ? [] : body.peers;
Promise.all( Promise.all(
@ -42,8 +42,8 @@ exports.getPeers = (req, res, next) => {
}; };
exports.postPeer = (req, res, next) => { exports.postPeer = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/peers'; options.url = common.findNode(1).lnd_server_url + '/peers';
options.form = JSON.stringify({ options.form = JSON.stringify({
addr: { host: req.body.host, pubkey: req.body.pubkey }, addr: { host: req.body.host, pubkey: req.body.pubkey },
perm: req.body.perm perm: req.body.perm
@ -56,7 +56,7 @@ exports.postPeer = (req, res, next) => {
error: (undefined === body) ? 'Error From Server!' : body.error error: (undefined === body) ? 'Error From Server!' : body.error
}); });
} else { } else {
options.url = common.lnd_server_url + '/peers'; options.url = common.findNode(1).lnd_server_url + '/peers';
request(options).then(function (body) { request(options).then(function (body) {
let peers = (undefined === body.peers) ? [] : body.peers; let peers = (undefined === body.peers) ? [] : body.peers;
Promise.all( Promise.all(
@ -85,8 +85,8 @@ exports.postPeer = (req, res, next) => {
}; };
exports.deletePeer = (req, res, next) => { exports.deletePeer = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/peers/' + req.params.peerPubKey; options.url = common.findNode(1).lnd_server_url + '/peers/' + req.params.peerPubKey;
request.delete(options).then((body) => { request.delete(options).then((body) => {
logger.info('\r\nPeers: 81: ' + JSON.stringify(Date.now()) + ': INFO: Detach Peer Response: ' + JSON.stringify(body)); logger.info('\r\nPeers: 81: ' + JSON.stringify(Date.now()) + ': INFO: Detach Peer Response: ' + JSON.stringify(body));
if(undefined === body || body.error) { if(undefined === body || body.error) {

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.forwardingHistory = (req, res, next) => { exports.forwardingHistory = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/switch'; options.url = common.findNode(1).lnd_server_url + '/switch';
options.form = {}; options.form = {};
if (undefined !== req.body.num_max_events) { if (undefined !== req.body.num_max_events) {
options.form.num_max_events = req.body.num_max_events; options.form.num_max_events = req.body.num_max_events;

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.getTransactions = (req, res, next) => { exports.getTransactions = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/transactions'; options.url = common.findNode(1).lnd_server_url + '/transactions';
request(options).then((body) => { request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body); const body_str = (undefined === body) ? '' : JSON.stringify(body);
const search_idx = (undefined === body) ? -1 : body_str.search('Not Found'); const search_idx = (undefined === body) ? -1 : body_str.search('Not Found');
@ -34,8 +34,8 @@ exports.getTransactions = (req, res, next) => {
}; };
exports.postTransactions = (req, res, next) => { exports.postTransactions = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
options.url = common.lnd_server_url + '/transactions'; options.url = common.findNode(1).lnd_server_url + '/transactions';
options.form = { options.form = {
amount: req.body.amount, amount: req.body.amount,
addr: req.body.address, addr: req.body.address,

@ -4,16 +4,16 @@ var logger = require('./logger');
var options = {}; var options = {};
exports.operateWallet = (req, res, next) => { exports.operateWallet = (req, res, next) => {
options = common.getOptions(''); options = common.getOptions(1);
var requestBody = { var requestBody = {
wallet_password: Buffer.from(req.body.wallet_password).toString('base64') wallet_password: Buffer.from(req.body.wallet_password).toString('base64')
}; };
if (undefined === req.params.operation || req.params.operation === 'unlock') { if (undefined === req.params.operation || req.params.operation === 'unlock') {
options.url = common.lnd_server_url + '/unlockwallet'; options.url = common.findNode(1).lnd_server_url + '/unlockwallet';
options.form = JSON.stringify(requestBody); options.form = JSON.stringify(requestBody);
err_message = 'Unlocking wallet failed! Verify that lnd is running and the wallet is locked!'; err_message = 'Unlocking wallet failed! Verify that lnd is running and the wallet is locked!';
} else { } else {
options.url = common.lnd_server_url + '/initwallet'; options.url = common.findNode(1).lnd_server_url + '/initwallet';
options.form = JSON.stringify(requestBody); options.form = JSON.stringify(requestBody);
err_message = 'Initializing wallet failed!'; err_message = 'Initializing wallet failed!';
} }

@ -1,13 +1,13 @@
<div fxLayout="column" id="rtl-container" class="rtl-container" [ngClass]="settings.theme" [class.horizontal]="settings.menu === 'Horizontal'" [class.compact]="settings.menuType === 'Compact'" [class.mini]="settings.menuType === 'Mini'"> <div fxLayout="column" id="rtl-container" class="rtl-container" [ngClass]="appConfig.nodes[0].settings.theme" [class.horizontal]="appConfig.nodes[0].settings.menu === 'Horizontal'" [class.compact]="appConfig.nodes[0].settings.menuType === 'Compact'" [class.mini]="appConfig.nodes[0].settings.menuType === 'Mini'">
<mat-sidenav-container> <mat-sidenav-container>
<mat-sidenav perfectScrollbar *ngIf="settings.menu === 'Vertical'" [opened]="settings.flgSidenavOpened" [mode]="(settings.flgSidenavPinned) ? 'side' : 'over'" <mat-sidenav perfectScrollbar *ngIf="appConfig.nodes[0].settings.menu === 'Vertical'" [opened]="appConfig.nodes[0].settings.flgSidenavOpened" [mode]="(appConfig.nodes[0].settings.flgSidenavPinned) ? 'side' : 'over'"
#sideNavigation class="sidenav mat-elevation-z6 overflow-auto"> #sideNavigation class="sidenav mat-elevation-z6 overflow-auto">
<rtl-side-navigation (ChildNavClicked)="onNavigationClicked($event)"></rtl-side-navigation> <rtl-side-navigation (ChildNavClicked)="onNavigationClicked($event)"></rtl-side-navigation>
</mat-sidenav> </mat-sidenav>
<mat-sidenav-content perfectScrollbar class="overflow-auto"> <mat-sidenav-content perfectScrollbar class="overflow-auto">
<mat-toolbar fxLayout="row" fxLayoutAlign="space-between center" color="primary" class="padding-gap-x"> <mat-toolbar fxLayout="row" fxLayoutAlign="space-between center" color="primary" class="padding-gap-x">
<div fxLayoutAlign="center center"> <div fxLayoutAlign="center center">
<button *ngIf="settings.menu === 'Vertical'" mat-icon-button (click)="sideNavToggle(sideNavigation)"> <button *ngIf="appConfig.nodes[0].settings.menu === 'Vertical'" mat-icon-button (click)="sideNavToggle(sideNavigation)">
<mat-icon>menu</mat-icon> <mat-icon>menu</mat-icon>
</button> </button>
</div> </div>
@ -25,7 +25,7 @@
<mat-icon [ngClass]="{'icon-smaller cursor-pointer copy-icon-smaller': smallScreen, 'icon-small cursor-pointer copy-icon': !smallScreen}">file_copy</mat-icon><span [hidden]="!flgCopied">Copied</span> <mat-icon [ngClass]="{'icon-smaller cursor-pointer copy-icon-smaller': smallScreen, 'icon-small cursor-pointer copy-icon': !smallScreen}">file_copy</mat-icon><span [hidden]="!flgCopied">Copied</span>
</div> </div>
</div> </div>
<mat-toolbar color="primary" *ngIf="settings.menu === 'Horizontal'" class="padding-gap-x horizontal-nav"> <mat-toolbar color="primary" *ngIf="appConfig.nodes[0].settings.menu === 'Horizontal'" class="padding-gap-x horizontal-nav">
<div fxLayout="row" fxFlex="100" fxLayoutAlign="center center" class="h-100"> <div fxLayout="row" fxFlex="100" fxLayoutAlign="center center" class="h-100">
<rtl-horizontal-navigation></rtl-horizontal-navigation> <rtl-horizontal-navigation></rtl-horizontal-navigation>
</div> </div>
@ -41,7 +41,7 @@
<rtl-settings-nav (done)="settingSidenav.toggle()"></rtl-settings-nav> <rtl-settings-nav (done)="settingSidenav.toggle()"></rtl-settings-nav>
</mat-sidenav> </mat-sidenav>
</mat-sidenav-container> </mat-sidenav-container>
<div class="rtl-spinner" *ngIf="undefined === settings.theme"> <div class="rtl-spinner" *ngIf="undefined === appConfig.nodes[0].settings.theme">
<mat-spinner color="accent"></mat-spinner> <mat-spinner color="accent"></mat-spinner>
<h4>Loading RTL...</h4> <h4>Loading RTL...</h4>
</div> </div>

@ -7,7 +7,7 @@ import { Actions } from '@ngrx/effects';
import { UserIdleService } from 'angular-user-idle'; import { UserIdleService } from 'angular-user-idle';
import { LoggerService } from './shared/services/logger.service'; import { LoggerService } from './shared/services/logger.service';
import { Settings, Authentication } from './shared/models/RTLconfig'; import { Settings, Authentication, SSO, RTLConfiguration } from './shared/models/RTLconfig';
import { GetInfo } from './shared/models/lndModels'; import { GetInfo } from './shared/models/lndModels';
import * as RTLActions from './shared/store/rtl.actions'; import * as RTLActions from './shared/store/rtl.actions';
@ -24,8 +24,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
public information: GetInfo = {}; public information: GetInfo = {};
public flgLoading: Array<Boolean | 'error'> = [true]; // 0: Info public flgLoading: Array<Boolean | 'error'> = [true]; // 0: Info
public flgCopied = false; public flgCopied = false;
public settings: Settings; public appConfig: RTLConfiguration;
public authSettings: Authentication;
public accessKey = ''; public accessKey = '';
public smallScreen = false; public smallScreen = false;
unsubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()]; unsubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()];
@ -34,24 +33,23 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
private userIdle: UserIdleService, private router: Router) {} private userIdle: UserIdleService, private router: Router) {}
ngOnInit() { ngOnInit() {
this.store.dispatch(new RTLActions.FetchSettings()); this.store.dispatch(new RTLActions.FetchRTLConfig());
this.accessKey = this.readAccessKey(); this.accessKey = this.readAccessKey();
this.store.select('rtlRoot') this.store.select('rtlRoot')
.pipe(takeUntil(this.unsubs[0])) .pipe(takeUntil(this.unsubs[0]))
.subscribe(rtlStore => { .subscribe(rtlStore => {
this.settings = rtlStore.settings; this.appConfig = rtlStore.appConfig;
this.information = rtlStore.information; this.information = rtlStore.information;
this.authSettings = rtlStore.authSettings;
this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true; this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true;
if (window.innerWidth <= 768) { if (window.innerWidth <= 768) {
this.settings.menu = 'Vertical'; this.appConfig.nodes[0].settings.menu = 'Vertical';
this.settings.flgSidenavOpened = false; this.appConfig.nodes[0].settings.flgSidenavOpened = false;
this.settings.flgSidenavPinned = false; this.appConfig.nodes[0].settings.flgSidenavPinned = false;
} }
if (window.innerWidth <= 414) { if (window.innerWidth <= 414) {
this.smallScreen = true; this.smallScreen = true;
} }
this.logger.info(this.settings); this.logger.info(this.appConfig.nodes[0].settings);
if (!sessionStorage.getItem('token')) { if (!sessionStorage.getItem('token')) {
this.flgLoading[0] = false; this.flgLoading[0] = false;
} }
@ -62,23 +60,25 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
this.actions$ this.actions$
.pipe( .pipe(
takeUntil(this.unsubs[1]), takeUntil(this.unsubs[1]),
filter((action) => action.type === RTLActions.INIT_APP_DATA || action.type === RTLActions.SET_SETTINGS || action.type === RTLActions.SET_AUTH_SETTINGS) filter((action) => action.type === RTLActions.INIT_APP_DATA || action.type === RTLActions.SET_RTL_CONFIG)
).subscribe((actionPayload: (RTLActions.InitAppData | RTLActions.SetSettings | RTLActions.SetAuthSettings)) => { ).subscribe((actionPayload: (RTLActions.InitAppData | RTLActions.SetRTLConfig)) => {
if (actionPayload.type === RTLActions.SET_AUTH_SETTINGS) { if (actionPayload.type === RTLActions.SET_RTL_CONFIG) {
if (!sessionStorage.getItem('token')) { if (!sessionStorage.getItem('token')) {
if (+actionPayload.payload.rtlSSO) { if (+actionPayload.payload.sso.rtlSSO) {
this.store.dispatch(new RTLActions.Signin(window.btoa(this.accessKey))); this.store.dispatch(new RTLActions.Signin(window.btoa(this.accessKey)));
} else { } else {
this.router.navigate([this.authSettings.logoutRedirectLink]); this.router.navigate([this.appConfig.sso.logoutRedirectLink]);
} }
} }
} else if (actionPayload.type === RTLActions.INIT_APP_DATA) { if (
this.store.dispatch(new RTLActions.FetchInfo()); this.appConfig.nodes[0].settings.menu === 'Horizontal' ||
} else if (actionPayload.type === RTLActions.SET_SETTINGS) { this.appConfig.nodes[0].settings.menuType === 'Compact' ||
if (this.settings.menu === 'Horizontal' || this.settings.menuType === 'Compact' || this.settings.menuType === 'Mini') { this.appConfig.nodes[0].settings.menuType === 'Mini') {
this.settingSidenav.toggle(); // To dynamically update the width to 100% after side nav is closed this.settingSidenav.toggle(); // To dynamically update the width to 100% after side nav is closed
setTimeout(() => { this.settingSidenav.toggle(); }, 100); setTimeout(() => { this.settingSidenav.toggle(); }, 100);
} }
} else if (actionPayload.type === RTLActions.INIT_APP_DATA) {
this.store.dispatch(new RTLActions.FetchInfo());
} }
}); });
this.actions$ this.actions$
@ -122,7 +122,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
} }
ngAfterViewInit() { ngAfterViewInit() {
if (!this.settings.flgSidenavPinned) { if (!this.appConfig.nodes[0].settings.flgSidenavPinned) {
this.sideNavigation.close(); this.sideNavigation.close();
this.settingSidenav.toggle(); this.settingSidenav.toggle();
} }
@ -135,9 +135,9 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
@HostListener('window:resize') @HostListener('window:resize')
public onWindowResize(): void { public onWindowResize(): void {
if (window.innerWidth <= 768) { if (window.innerWidth <= 768) {
this.settings.menu = 'Vertical'; this.appConfig.nodes[0].settings.menu = 'Vertical';
this.settings.flgSidenavOpened = false; this.appConfig.nodes[0].settings.flgSidenavOpened = false;
this.settings.flgSidenavPinned = false; this.appConfig.nodes[0].settings.flgSidenavPinned = false;
} }
} }

@ -105,7 +105,7 @@ export class ChannelPendingComponent implements OnInit, OnDestroy {
} }
}); });
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information; this.information = rtlStore.information;
this.pendingChannels = rtlStore.pendingChannels; this.pendingChannels = rtlStore.pendingChannels;
if (undefined !== this.pendingChannels.total_limbo_balance) { if (undefined !== this.pendingChannels.total_limbo_balance) {

@ -88,7 +88,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.flgLoading[6] = 'error'; this.flgLoading[6] = 'error';
} }
}); });
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information; this.information = rtlStore.information;
if (this.flgLoading[0] !== 'error') { if (this.flgLoading[0] !== 'error') {
this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true; this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true;

@ -67,7 +67,7 @@ export class InvoicesComponent implements OnInit, OnDestroy {
this.flgLoading[0] = 'error'; this.flgLoading[0] = 'error';
} }
}); });
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information; this.information = rtlStore.information;
this.logger.info(rtlStore); this.logger.info(rtlStore);
this.loadInvoicesTable(rtlStore.invoices); this.loadInvoicesTable(rtlStore.invoices);

@ -62,7 +62,7 @@ export class SideNavigationComponent implements OnInit, OnDestroy {
this.store.select('rtlRoot') this.store.select('rtlRoot')
.pipe(takeUntil(this.unSubs[0])) .pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore: fromRTLReducer.State) => { .subscribe((rtlStore: fromRTLReducer.State) => {
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information; this.information = rtlStore.information;
this.numPendingChannels = rtlStore.numberOfPendingChannels; this.numPendingChannels = rtlStore.numberOfPendingChannels;

@ -35,7 +35,7 @@ export class TopMenuComponent implements OnInit, OnDestroy {
this.store.select('rtlRoot') this.store.select('rtlRoot')
.pipe(takeUntil(this.unSubs[0])) .pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore: fromRTLReducer.State) => { .subscribe((rtlStore: fromRTLReducer.State) => {
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information; this.information = rtlStore.information;
this.flgLoading = (undefined !== this.information.identity_pubkey) ? false : true; this.flgLoading = (undefined !== this.information.identity_pubkey) ? false : true;

@ -67,7 +67,7 @@ export class PaymentsComponent implements OnInit, OnDestroy {
this.flgLoading[0] = 'error'; this.flgLoading[0] = 'error';
} }
}); });
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information; this.information = rtlStore.information;
this.paymentJSONArr = (rtlStore.payments.length > 0) ? rtlStore.payments : []; this.paymentJSONArr = (rtlStore.payments.length > 0) ? rtlStore.payments : [];
this.payments = (undefined === rtlStore.payments) ? new MatTableDataSource([]) : new MatTableDataSource<Payment>([...this.paymentJSONArr]); this.payments = (undefined === rtlStore.payments) ? new MatTableDataSource([]) : new MatTableDataSource<Payment>([...this.paymentJSONArr]);

@ -7,7 +7,7 @@
</mat-card-subtitle> </mat-card-subtitle>
</mat-card-header> </mat-card-header>
<mat-card-content> <mat-card-content>
<form fxLayout="column" fxLayoutAlign="space-between stretch" fxLayout.gt-md="row wrap"> <form fxLayout="column" fxLayoutAlign="space-between stretch" fxLayout.gt-md="row wrap" class="mb-2">
<mat-radio-group fxFlex="20" fxLayoutAlign="start" (change)="onSelectionChange($event)" class="mt-1 mb-1"> <mat-radio-group fxFlex="20" fxLayoutAlign="start" (change)="onSelectionChange($event)" class="mt-1 mb-1">
<mat-radio-button class="pr-5" value="lnd" *ngIf="showLND" [checked]="selectedNodeType=='lnd'">LND</mat-radio-button> <mat-radio-button class="pr-5" value="lnd" *ngIf="showLND" [checked]="selectedNodeType=='lnd'">LND</mat-radio-button>
<mat-radio-button class="pr-5" value="bitcoind" *ngIf="showBitcoind" [checked]="selectedNodeType=='bitcoind'">BITCOIND</mat-radio-button> <mat-radio-button class="pr-5" value="bitcoind" *ngIf="showBitcoind" [checked]="selectedNodeType=='bitcoind'">BITCOIND</mat-radio-button>
@ -18,7 +18,10 @@
<button fxFlex="50" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="3" type="reset" class="ml-2" (click)="resetData()">Clear</button> <button fxFlex="50" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="3" type="reset" class="ml-2" (click)="resetData()">Clear</button>
</div> </div>
</form> </form>
<div *ngIf="configData !== ''"> <div *ngIf="configData !== '' && fileFormat === 'JSON'">
<pre>{{configData | json}}</pre>
</div>
<div *ngIf="configData !== '' && fileFormat === 'INI'">
<mat-list> <mat-list>
<mat-list-item *ngFor="let conf of configData; index as i;"> <mat-list-item *ngFor="let conf of configData; index as i;">
<mat-card-subtitle class="my-1"> <mat-card-subtitle class="my-1">

@ -19,6 +19,7 @@ export class ServerConfigComponent implements OnInit, OnDestroy {
public showLND = false; public showLND = false;
public showBitcoind = false; public showBitcoind = false;
public configData = ''; public configData = '';
public fileFormat = 'INI';
private unsubs: Array<Subject<void>> = [new Subject(), new Subject()]; private unsubs: Array<Subject<void>> = [new Subject(), new Subject()];
constructor(private store: Store<fromRTLReducer.State>, private rtlEffects: RTLEffects) {} constructor(private store: Store<fromRTLReducer.State>, private rtlEffects: RTLEffects) {}
@ -32,7 +33,7 @@ export class ServerConfigComponent implements OnInit, OnDestroy {
this.resetData(); this.resetData();
} }
}); });
this.authSettings = rtlStore.authSettings; this.authSettings = rtlStore.appConfig.nodes[0].authentication;
if (undefined !== this.authSettings && this.authSettings.lndConfigPath !== '') { if (undefined !== this.authSettings && this.authSettings.lndConfigPath !== '') {
this.showLND = true; this.showLND = true;
} }
@ -52,8 +53,16 @@ export class ServerConfigComponent implements OnInit, OnDestroy {
this.store.dispatch(new RTLActions.FetchConfig(this.selectedNodeType)); this.store.dispatch(new RTLActions.FetchConfig(this.selectedNodeType));
this.rtlEffects.showLNDConfig this.rtlEffects.showLNDConfig
.pipe(takeUntil(this.unsubs[1])) .pipe(takeUntil(this.unsubs[1]))
.subscribe((configFile: any) => { .subscribe((config: any) => {
this.configData = (configFile === '' || undefined === configFile) ? [] : configFile.split('\n'); const configFile = config.data;
this.fileFormat = config.format;
if (configFile !== '' && undefined !== configFile && this.fileFormat === 'INI') {
this.configData = configFile.split('\n');
} else if (configFile !== '' && undefined !== configFile && this.fileFormat === 'JSON') {
this.configData = configFile;
} else {
this.configData = '';
}
}); });
} }

@ -31,7 +31,7 @@ export class SigninComponent implements OnInit, OnDestroy {
rtlStore.effectErrors.forEach(effectsErr => { rtlStore.effectErrors.forEach(effectsErr => {
this.logger.error(effectsErr); this.logger.error(effectsErr);
}); });
this.nodeAuthType = rtlStore.authSettings.nodeAuthType; this.nodeAuthType = rtlStore.appConfig.nodes[0].authentication.nodeAuthType;
this.logger.info(rtlStore); this.logger.info(rtlStore);
if (this.nodeAuthType.toUpperCase() === 'DEFAULT') { if (this.nodeAuthType.toUpperCase() === 'DEFAULT') {
this.hintStr = 'Enter RPC password'; this.hintStr = 'Enter RPC password';

@ -17,7 +17,7 @@
</svg> </svg>
</mat-card-content> </mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData"> <span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="settings?.satsToBTC; else smallerUnit1">{{blockchainBalance?.btc_total_balance | number}} {{information?.currency_unit}}</h3> <h3 *ngIf="appConfig.nodes[0].settings?.satsToBTC; else smallerUnit1">{{blockchainBalance?.btc_total_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit1><h3>{{blockchainBalance?.total_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template> <ng-template #smallerUnit1><h3>{{blockchainBalance?.total_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span> </span>
</mat-card-content> </mat-card-content>
@ -40,7 +40,7 @@
</svg> </svg>
</mat-card-content> </mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData"> <span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="settings?.satsToBTC; else smallerUnit2">{{blockchainBalance?.btc_confirmed_balance | number}} {{information?.currency_unit}}</h3> <h3 *ngIf="appConfig.nodes[0].settings?.satsToBTC; else smallerUnit2">{{blockchainBalance?.btc_confirmed_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit2><h3>{{blockchainBalance?.confirmed_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template> <ng-template #smallerUnit2><h3>{{blockchainBalance?.confirmed_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span> </span>
</mat-card-content> </mat-card-content>
@ -63,7 +63,7 @@
</svg> </svg>
</mat-card-content> </mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData"> <span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="settings?.satsToBTC; else smallerUnit3">{{blockchainBalance?.btc_unconfirmed_balance | number}} {{information?.currency_unit}}</h3> <h3 *ngIf="appConfig.nodes[0].settings?.satsToBTC; else smallerUnit3">{{blockchainBalance?.btc_unconfirmed_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit3><h3>{{blockchainBalance?.unconfirmed_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template> <ng-template #smallerUnit3><h3>{{blockchainBalance?.unconfirmed_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span> </span>
</mat-card-content> </mat-card-content>

@ -5,7 +5,7 @@ import { Store } from '@ngrx/store';
import { Settings } from '../../../shared/models/RTLconfig'; import { Settings } from '../../../shared/models/RTLconfig';
import { GetInfo, Balance, ChannelsTransaction, AddressType } from '../../../shared/models/lndModels'; import { GetInfo, Balance, ChannelsTransaction, AddressType } from '../../../shared/models/lndModels';
import { Authentication } from '../../../shared/models/RTLconfig'; import { RTLConfiguration } from '../../../shared/models/RTLconfig';
import { LoggerService } from '../../../shared/services/logger.service'; import { LoggerService } from '../../../shared/services/logger.service';
import { RTLEffects } from '../../../shared/store/rtl.effects'; import { RTLEffects } from '../../../shared/store/rtl.effects';
@ -18,13 +18,12 @@ import * as fromRTLReducer from '../../../shared/store/rtl.reducers';
styleUrls: ['./send-receive-trans.component.scss'] styleUrls: ['./send-receive-trans.component.scss']
}) })
export class SendReceiveTransComponent implements OnInit, OnDestroy { export class SendReceiveTransComponent implements OnInit, OnDestroy {
public settings: Settings; public appConfig: RTLConfiguration;
public addressTypes = []; public addressTypes = [];
public flgLoadingWallet: Boolean | 'error' = true; public flgLoadingWallet: Boolean | 'error' = true;
public selectedAddress: AddressType = {}; public selectedAddress: AddressType = {};
public blockchainBalance: Balance = {}; public blockchainBalance: Balance = {};
public information: GetInfo = {}; public information: GetInfo = {};
public authSettings: Authentication = {};
public newAddress = ''; public newAddress = '';
public transaction: ChannelsTransaction = {}; public transaction: ChannelsTransaction = {};
public transTypes = [{id: '1', name: 'Target Confirmation Blocks'}, {id: '2', name: 'Fee'}]; public transTypes = [{id: '1', name: 'Target Confirmation Blocks'}, {id: '2', name: 'Fee'}];
@ -43,10 +42,9 @@ export class SendReceiveTransComponent implements OnInit, OnDestroy {
this.flgLoadingWallet = 'error'; this.flgLoadingWallet = 'error';
} }
}); });
this.settings = rtlStore.settings; this.appConfig = rtlStore.appConfig;
this.information = rtlStore.information; this.information = rtlStore.information;
this.addressTypes = rtlStore.addressTypes; this.addressTypes = rtlStore.addressTypes;
this.authSettings = rtlStore.authSettings;
this.blockchainBalance = rtlStore.blockchainBalance; this.blockchainBalance = rtlStore.blockchainBalance;
if (undefined === this.blockchainBalance.total_balance) { if (undefined === this.blockchainBalance.total_balance) {
@ -103,7 +101,7 @@ export class SendReceiveTransComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.unsub[2])) .pipe(takeUntil(this.unsub[2]))
.subscribe(confirmRes => { .subscribe(confirmRes => {
if (confirmRes) { if (confirmRes) {
if (this.transaction.sendAll && !+this.authSettings.rtlSSO) { if (this.transaction.sendAll && !+this.appConfig.sso.rtlSSO) {
this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data: this.store.dispatch(new RTLActions.OpenConfirmation({ width: '70%', data:
{type: 'CONFIRM', titleMessage: 'Enter Login Password', noBtnText: 'Cancel', yesBtnText: 'Authorize', flgShowInput: true, getInputs: [ {type: 'CONFIRM', titleMessage: 'Enter Login Password', noBtnText: 'Cancel', yesBtnText: 'Authorize', flgShowInput: true, getInputs: [
{placeholder: 'Enter Login Password', inputType: 'password', inputValue: ''} {placeholder: 'Enter Login Password', inputType: 'password', inputValue: ''}

@ -33,7 +33,7 @@ export class SettingsNavComponent implements OnInit, OnDestroy {
this.store.select('rtlRoot') this.store.select('rtlRoot')
.pipe(takeUntil(this.unsubs[0])) .pipe(takeUntil(this.unsubs[0]))
.subscribe((rtlStore: fromRTLReducer.State) => { .subscribe((rtlStore: fromRTLReducer.State) => {
this.settings = rtlStore.settings; this.settings = rtlStore.appConfig.nodes[0].settings;
this.selectedMenu = this.settings.menu; this.selectedMenu = this.settings.menu;
this.selectedMenuType = this.settings.menuType; this.selectedMenuType = this.settings.menuType;
if (window.innerWidth <= 768) { if (window.innerWidth <= 768) {

@ -1,3 +1,10 @@
export class SSO {
constructor(
public rtlSSO: number,
public logoutRedirectLink: string
) { }
}
export class Settings { export class Settings {
constructor( constructor(
public flgSidenavOpened: boolean, public flgSidenavOpened: boolean,
@ -5,35 +12,32 @@ export class Settings {
public menu: string, public menu: string,
public menuType: string, public menuType: string,
public theme: string, public theme: string,
public satsToBTC: boolean public satsToBTC: boolean,
public bitcoindConfigPath?: string
) { } ) { }
} }
export class MultiNode { export class Authentication {
constructor( constructor(
public index: string, public nodeAuthType?: string,
public lnNode: string, public lndConfigPath?: string,
public lnImplementation: string public bitcoindConfigPath?: string
) { } ) { }
} }
export class Authentication { export class Node {
constructor( constructor(
public lndServerUrl?: string, public settings: Settings,
public macaroonPath?: string, public authentication: Authentication,
public nodeAuthType?: string, public index?: string,
public lndConfigPath?: string, public lnNode?: string,
public bitcoindConfigPath?: string, public lnImplementation?: string
public rtlPass?: string,
public enableLogging?: string,
public rtlSSO?: number,
public logoutRedirectLink?: string
) { } ) { }
} }
export class RTLConfiguration { export class RTLConfiguration {
constructor( constructor(
public settings: Settings, public sso: SSO,
public authentication: Authentication public nodes: Node[]
) { } ) { }
} }

@ -1,5 +1,5 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { Settings, Authentication } from '../models/RTLconfig'; import { RTLConfiguration, Settings } from '../models/RTLconfig';
import { ErrorPayload } from '../models/errorPayload'; import { ErrorPayload } from '../models/errorPayload';
import { import {
GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, Payment, GraphNode, AddressType, GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, Payment, GraphNode, AddressType,
@ -17,9 +17,8 @@ export const OPEN_CONFIRMATION = 'OPEN_CONFIRMATION';
export const CLOSE_CONFIRMATION = 'CLOSE_CONFIRMATION'; export const CLOSE_CONFIRMATION = 'CLOSE_CONFIRMATION';
export const FETCH_STORE = 'FETCH_STORE'; export const FETCH_STORE = 'FETCH_STORE';
export const SET_STORE = 'SET_STORE'; export const SET_STORE = 'SET_STORE';
export const FETCH_SETTINGS = 'FETCH_SETTINGS'; export const FETCH_RTL_CONFIG = 'FETCH_RTL_CONFIG';
export const SET_SETTINGS = 'SET_SETTINGS'; export const SET_RTL_CONFIG = 'SET_RTL_CONFIG';
export const SET_AUTH_SETTINGS = 'SET_AUTH_SETTINGS';
export const SAVE_SETTINGS = 'SAVE_SETTINGS'; export const SAVE_SETTINGS = 'SAVE_SETTINGS';
export const FETCH_INFO = 'FETCH_INFO'; export const FETCH_INFO = 'FETCH_INFO';
export const SET_INFO = 'SET_INFO'; export const SET_INFO = 'SET_INFO';
@ -112,18 +111,13 @@ export class CloseConfirmation implements Action {
constructor(public payload: boolean) {} constructor(public payload: boolean) {}
} }
export class FetchSettings implements Action { export class FetchRTLConfig implements Action {
readonly type = FETCH_SETTINGS; readonly type = FETCH_RTL_CONFIG;
} }
export class SetSettings implements Action { export class SetRTLConfig implements Action {
readonly type = SET_SETTINGS; readonly type = SET_RTL_CONFIG;
constructor(public payload: Settings) {} constructor(public payload: RTLConfiguration) {}
}
export class SetAuthSettings implements Action {
readonly type = SET_AUTH_SETTINGS;
constructor(public payload: Authentication) {}
} }
export class SaveSettings implements Action { export class SaveSettings implements Action {
@ -385,7 +379,7 @@ export class InitAppData implements Action {
export type RTLActions = export type RTLActions =
ClearEffectError | EffectError | OpenSpinner | CloseSpinner | ClearEffectError | EffectError | OpenSpinner | CloseSpinner |
FetchSettings | SetSettings | SaveSettings | SetAuthSettings | FetchRTLConfig | SetRTLConfig | SaveSettings |
OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation | OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation |
FetchInfo | SetInfo | FetchInfo | SetInfo |
FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer | FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer |

@ -85,24 +85,22 @@ export class RTLEffects implements OnDestroy {
)); ));
@Effect() @Effect()
settingFetch = this.actions$.pipe( appConfigFetch = this.actions$.pipe(
ofType(RTLActions.FETCH_SETTINGS), ofType(RTLActions.FETCH_RTL_CONFIG),
mergeMap((action: RTLActions.FetchSettings) => { mergeMap((action: RTLActions.FetchRTLConfig) => {
this.store.dispatch(new RTLActions.ClearEffectError('FetchSettings')); this.store.dispatch(new RTLActions.ClearEffectError('FetchRTLConfig'));
return this.httpClient.get(environment.CONF_API + '/rtlconf'); return this.httpClient.get(environment.CONF_API + '/rtlconf');
}), }),
map((rtlConfig: any) => { map((rtlConfig: any) => {
this.logger.info(rtlConfig); this.logger.info(rtlConfig);
this.store.dispatch(new RTLActions.SetAuthSettings(rtlConfig.authSettings));
return { return {
type: RTLActions.SET_SETTINGS, type: RTLActions.SET_RTL_CONFIG,
payload: (undefined !== rtlConfig && undefined !== rtlConfig.settings) ? rtlConfig.settings : payload: rtlConfig
{'flgSidenavOpened': true, 'flgSidenavPinned': true, 'menu': 'Vertical', 'menuType': 'Regular', 'theme': 'dark-blue', 'satsToBTC': false}
}; };
}, },
catchError((err) => { catchError((err) => {
this.logger.error(err); this.logger.error(err);
this.store.dispatch(new RTLActions.EffectError({ action: 'FetchSettings', code: err.status, message: err.error.error })); this.store.dispatch(new RTLActions.EffectError({ action: 'FetchRTLConfig', code: err.status, message: err.error.error }));
return of(); return of();
}) })
)); ));
@ -141,12 +139,12 @@ export class RTLEffects implements OnDestroy {
catchError((err) => { catchError((err) => {
this.logger.error(err); this.logger.error(err);
this.store.dispatch(new RTLActions.EffectError({ action: 'FetchInfo', code: err.status, message: err.error.error })); this.store.dispatch(new RTLActions.EffectError({ action: 'FetchInfo', code: err.status, message: err.error.error }));
if (+store.authSettings.rtlSSO) { if (+store.appConfig.sso.rtlSSO) {
this.router.navigate(['/ssoerror']); this.router.navigate(['/ssoerror']);
} else { } else {
if (err.status === 401) { if (err.status === 401) {
this.logger.info('Redirecting to Signin'); this.logger.info('Redirecting to Signin');
this.router.navigate([store.authSettings.logoutRedirectLink]); this.router.navigate([store.appConfig.sso.logoutRedirectLink]);
return of(); return of();
} else { } else {
this.logger.info('Redirecting to Unlock'); this.logger.info('Redirecting to Unlock');
@ -915,10 +913,10 @@ export class RTLEffects implements OnDestroy {
this.store.dispatch(new RTLActions.EffectError({ action: 'Signin', code: err.status, message: err.error.message })); this.store.dispatch(new RTLActions.EffectError({ action: 'Signin', code: err.status, message: err.error.message }));
this.logger.error(err.error); this.logger.error(err.error);
this.logger.info('Redirecting to Signin Error Page'); this.logger.info('Redirecting to Signin Error Page');
if (+store.authSettings.rtlSSO) { if (+store.appConfig.sso.rtlSSO) {
this.router.navigate(['/ssoerror']); this.router.navigate(['/ssoerror']);
} else { } else {
this.router.navigate([store.authSettings.logoutRedirectLink]); this.router.navigate([store.appConfig.sso.logoutRedirectLink]);
} }
return of(); return of();
}) })
@ -930,10 +928,10 @@ export class RTLEffects implements OnDestroy {
ofType(RTLActions.SIGNOUT), ofType(RTLActions.SIGNOUT),
withLatestFrom(this.store.select('rtlRoot')), withLatestFrom(this.store.select('rtlRoot')),
mergeMap(([action, store]: [RTLActions.Signout, fromRTLReducer.State]) => { mergeMap(([action, store]: [RTLActions.Signout, fromRTLReducer.State]) => {
if (+store.authSettings.rtlSSO) { if (+store.appConfig.sso.rtlSSO) {
window.location.href = store.authSettings.logoutRedirectLink; window.location.href = store.appConfig.sso.logoutRedirectLink;
} else { } else {
this.router.navigate([store.authSettings.logoutRedirectLink]); this.router.navigate([store.appConfig.sso.logoutRedirectLink]);
} }
sessionStorage.removeItem('lndUnlocked'); sessionStorage.removeItem('lndUnlocked');
sessionStorage.removeItem('token'); sessionStorage.removeItem('token');

@ -1,15 +1,14 @@
import * as RTLActions from './rtl.actions'; import * as RTLActions from './rtl.actions';
import { ErrorPayload } from '../models/errorPayload'; import { ErrorPayload } from '../models/errorPayload';
import { Settings, Authentication } from '../models/RTLconfig'; import { RTLConfiguration } from '../models/RTLconfig';
import { import {
GetInfo, GetInfoChain, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, Invoice, PendingChannels, ClosedChannel, Transaction, SwitchRes GetInfo, GetInfoChain, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, Invoice, PendingChannels, ClosedChannel, Transaction, SwitchRes
} from '../models/lndModels'; } from '../models/lndModels';
export interface State { export interface State {
effectErrors: ErrorPayload[]; effectErrors: ErrorPayload[];
settings: Settings; appConfig: RTLConfiguration;
authSettings: Authentication;
information: GetInfo; information: GetInfo;
peers: Peer[]; peers: Peer[];
fees: Fees; fees: Fees;
@ -33,8 +32,13 @@ export interface State {
const initialState: State = { const initialState: State = {
effectErrors: [], effectErrors: [],
settings: {flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false}, appConfig: {
authSettings: {nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '', rtlSSO: 0, logoutRedirectLink: '/login' }, sso: { rtlSSO: 0, logoutRedirectLink: '/login' },
nodes: [{
settings: { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false },
authentication: { nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '' }
}]
},
information: {}, information: {},
peers: [], peers: [],
fees: {}, fees: {},
@ -78,15 +82,10 @@ export function RTLRootReducer(state = initialState, action: RTLActions.RTLActio
...state, ...state,
effectErrors: [...state.effectErrors, action.payload] effectErrors: [...state.effectErrors, action.payload]
}; };
case RTLActions.SET_SETTINGS: case RTLActions.SET_RTL_CONFIG:
return { return {
...state, ...state,
settings: action.payload appConfig: action.payload
};
case RTLActions.SET_AUTH_SETTINGS:
return {
...state,
authSettings: action.payload
}; };
case RTLActions.SET_INFO: case RTLActions.SET_INFO:
if (undefined !== action.payload.chains) { if (undefined !== action.payload.chains) {

@ -1 +1 @@
export const VERSION = '0.2.16-beta'; export const VERSION = '0.2.17-beta';
Loading…
Cancel
Save