SingleNode complete

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

@ -1,5 +1,6 @@
{
"multiPass": "multi",
"port": "3000",
"SSO": {
"rtlSSO": 0,
"rtlCookiePath": "",
@ -10,7 +11,7 @@
"lnNode": "LND Testnet # 1",
"lnImplementation": "LND",
"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"
},
"Settings": {
@ -20,10 +21,9 @@
"menuType": "Regular",
"theme": "dark-blue",
"satsToBTC": "false",
"bitcoindConfigPath": "C:\\Bitcoind\\config\\path",
"bitcoindConfigPath": "C:\\bitcoin\\bitcoin_mainnet\\bitcoin.conf",
"enableLogging": "true",
"port": "3000",
"lndServerUrl": "https://192.168.1.20:8080/v1"
"lndServerUrl": "https://localhost:8080/v1"
}
},
{
@ -42,7 +42,6 @@
"satsToBTC": "false",
"bitcoindConfigPath": "",
"enableLogging": "true",
"port": "3000",
"lndServerUrl": "https://localhost:8080/v1"
}
}]

@ -8,5 +8,5 @@
<link rel="stylesheet" href="styles.bab7f62b489f0c86770d.css"></head>
<body>
<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>

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

@ -71,34 +71,36 @@ connect.normalizePort = val => {
};
connect.setMacaroonPath = (clArgs, config) => {
common.nodes[0] = {};
common.nodes[0].index = 1;
if(undefined !== clArgs.lndir) {
common.macaroon_path = clArgs.lndir;
common.nodes[0].macaroon_path = clArgs.lndir;
} else if (undefined !== process.env.MACAROON_PATH) {
common.macaroon_path = process.env.MACAROON_PATH;
common.nodes[0].macaroon_path = process.env.MACAROON_PATH;
} else {
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 !== '') {
common.macaroon_path = config.Authentication.macaroonPath;
common.nodes[0].macaroon_path = config.Authentication.macaroonPath;
}
}
}
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!';
}
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 {
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!';
} else {
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) {
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;
} else {
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 {
common.node_auth_type = config.Authentication.nodeAuthType;
}
}
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 {
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 {
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!';
@ -126,42 +128,42 @@ connect.validateSingleNodeConfig = (config) => {
}
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 {
if(config.Settings.bitcoindConfigPath !== '' || undefined !== config.Settings.bitcoindConfigPath) {
common.bitcoind_config_path = config.Settings.bitcoindConfigPath;
} else if(config.Authentication.bitcoindConfigPath !== '' || undefined !== config.Authentication.bitcoindConfigPath) {
common.bitcoind_config_path = config.Authentication.bitcoindConfigPath;
if(config.Settings.bitcoindConfigPath !== '' && undefined !== config.Settings.bitcoindConfigPath) {
common.nodes[0].bitcoind_config_path = config.Settings.bitcoindConfigPath;
} else if(config.Authentication.bitcoindConfigPath !== '' && undefined !== config.Authentication.bitcoindConfigPath) {
common.nodes[0].bitcoind_config_path = config.Authentication.bitcoindConfigPath;
}
}
if (undefined !== 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;
}
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) {
common.enable_logging = process.env.ENABLE_LOGGING;
common.nodes[0].enable_logging = process.env.ENABLE_LOGGING;
} 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) {
common.enable_logging = config.Authentication.enableLogging;
common.nodes[0].enable_logging = config.Authentication.enableLogging;
}
if (common.enable_logging) {
common.log_file = common.rtl_conf_file_path + '/logs/RTL.log';
let exists = fs.existsSync(common.log_file);
if (common.nodes[0].enable_logging) {
common.nodes[0].log_file = common.rtl_conf_file_path + '/logs/RTL.log';
let exists = fs.existsSync(common.nodes[0].log_file);
if (exists) {
fs.writeFile(common.log_file, '', () => { });
fs.writeFile(common.nodes[0].log_file, '', () => { });
} else {
try {
var dirname = path.dirname(common.log_file);
var dirname = path.dirname(common.nodes[0].log_file);
connect.createDirectory(dirname);
var createStream = fs.createWriteStream(common.log_file);
var createStream = fs.createWriteStream(common.nodes[0].log_file);
createStream.end();
}
catch (err) {
@ -179,12 +181,14 @@ connect.validateSingleNodeConfig = (config) => {
connect.setSSOParams(config);
if (errMsg !== '') {
throw new Error(errMsg);
}
}
}
connect.validateMultiNodeConfig = (config) => {
common.node_auth_type = 'CUSTOM';
common.rtl_pass = config.multiPass;
common.port = (undefined !== config.port) ? connect.normalizePort(config.port) : 3000;
config.nodes.forEach((node, 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].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].port = (undefined !== node.Settings.port) ? connect.normalizePort(node.Settings.port) : 3000;
if (common.nodes[idx].enable_logging) {
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 LN NODE: ' + node.ln_node, 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 LND_SERVER_URL: ' + node.lnd_server_url, 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);
});
} 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 PORT: ' + common.port);
logger.info('\r\nConfig Setup Variable LND_SERVER_URL: ' + common.lnd_server_url);
logger.info('\r\nConfig Setup Variable MACAROON_PATH: ' + common.macaroon_path);
logger.info('\r\nConfig Setup Variable LND_SERVER_URL: ' + common.nodes[0].lnd_server_url);
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 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 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_COOKIE_PATH: ' + common.rtl_cookie_path);
logger.info('\r\nConfig Setup Variable LOGOUT_REDIRECT_LINK: ' + common.logout_redirect_link);

@ -1,5 +1,4 @@
var ini = require('ini');
var path = require('path');
var fs = require('fs');
var logger = require('./logger');
var common = require('../common');
@ -17,14 +16,13 @@ exports.getRTLConfig = (req, res, next) => {
});
} else {
const jsonConfig = ini.parse(data);
authSettings = {
const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link };
const authentication = {
nodeAuthType: common.node_auth_type,
lndConfigPath: common.lnd_config_path,
bitcoindConfigPath: common.bitcoind_config_path,
rtlSSO: common.rtl_sso,
logoutRedirectLink: common.logout_redirect_link
lndConfigPath: common.nodes[0].lnd_config_path,
bitcoindConfigPath: common.nodes[0].bitcoind_config_path
};
res.status(200).json({ nodes: [{settings: jsonConfig.Settings, authSettings: authSettings}] });
res.status(200).json({ sso: sso, nodes: [{settings: jsonConfig.Settings, authentication: authentication}] });
}
});
} else {
@ -44,55 +42,74 @@ exports.getRTLConfig = (req, res, next) => {
}
} else {
const multiNodeConfig = JSON.parse(data);
const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link };
var nodesArr = [];
multiNodeConfig.nodes.forEach(node => {
authSettings = {
nodeAuthType: 'CUSTOM',
lndConfigPath: node.lnd_config_path,
bitcoindConfigPath: node.bitcoind_config_path,
rtlSSO: common.rtl_sso,
logoutRedirectLink: common.logout_redirect_link
};
nodesArr.push({settings: node.Settings, authSettings: authSettings})
const authentication = {};
authentication.nodeAuthType = 'CUSTOM';
if(node.Authentication.lndConfigPath) {
authentication.lndConfigPath = node.Authentication.lndConfigPath;
}
if(node.Settings.bitcoindConfigPath) {
authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath;
}
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) => {
var RTLConfFile = common.rtl_conf_file_path + '/RTL.conf';
var config = ini.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
delete config.Settings;
fs.writeFileSync(RTLConfFile, ini.stringify(config));
fs.appendFile(RTLConfFile, ini.stringify(req.body.updatedSettings, { 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'});
}
});
var RTLConfFile = '';
if(common.multi_node_setup) {
RTLConfFile = common.rtl_conf_file_path + '/RTL-Multi-Node-Conf.json';
} else {
RTLConfFile = common.rtl_conf_file_path + '/RTL.conf';
var config = ini.parse(fs.readFileSync(RTLConfFile, 'utf-8'));
var settingsTemp = config.Settings;
settingsTemp.flgSidenavOpened = req.body.updatedSettings.flgSidenavOpened;
settingsTemp.flgSidenavPinned = req.body.updatedSettings.flgSidenavPinned;
settingsTemp.menu = req.body.updatedSettings.menu;
settingsTemp.menuType = req.body.updatedSettings.menuType;
settingsTemp.theme = req.body.updatedSettings.theme;
settingsTemp.satsToBTC = req.body.updatedSettings.satsToBTC;
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) => {
let confFile = '';
let JSONFormat = false;
switch (req.params.nodeType) {
case 'lnd':
confFile = common.lnd_config_path
JSONFormat = false;
confFile = common.nodes[0].lnd_config_path;
break;
case 'bitcoind':
confFile = common.bitcoind_config_path
JSONFormat = false;
confFile = common.nodes[0].bitcoind_config_path;
break;
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;
default:
JSONFormat = false;
confFile = '';
break;
}
@ -105,14 +122,24 @@ exports.getConfig = (req, res, next) => {
error: err
});
} else {
const jsonConfig = ini.parse(data);
const jsonConfig = (JSONFormat) ? JSON.parse(data) : ini.parse(data);
if (undefined !== jsonConfig.Authentication && undefined !== jsonConfig.Authentication.rtlPass) {
jsonConfig.Authentication.rtlPass = jsonConfig.Authentication.rtlPass.replace(/./g, '*');
}
if (undefined !== jsonConfig.Bitcoind && undefined !== jsonConfig.Bitcoind['bitcoind.rpcpass']) {
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) {
connect.refreshCookie(common.rtl_cookie_path);
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
);
res.status(200).json({ token: token });
@ -47,13 +47,29 @@ exports.authenticateUser = (req, res, next) => {
}
} else {
const password = atob(req.body.password);
selNode = req.body.node;
if (undefined === selNode || selNode === '') {
if (common.multi_node_setup) {
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 (common.rtl_pass === password) {
var rpcUser = 'Custom_User';
var rpcUser = 'Single_Node_User';
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
);
res.status(200).json({ token: token });
@ -64,7 +80,7 @@ exports.authenticateUser = (req, res, next) => {
});
}
} 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) {
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.';
@ -81,7 +97,7 @@ exports.authenticateUser = (req, res, next) => {
var rpcUser = (undefined !== jsonLNDConfig.Bitcoind && undefined !== jsonLNDConfig.Bitcoind['bitcoind.rpcuser']) ? jsonLNDConfig.Bitcoind['bitcoind.rpcuser'] : '';
rpcUser = (rpcUser === '' && undefined !== jsonLNDConfig['bitcoind.rpcuser']) ? jsonLNDConfig['bitcoind.rpcuser'] : '';
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
);
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 = {};
exports.getBalance = (req, res, next) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/balance/' + req.params.source;
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/balance/' + req.params.source;
options.qs = req.query;
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));

@ -6,9 +6,9 @@ var options = {};
getAliasForChannel = (channel, channelType) => {
return new Promise(function(resolve, reject) {
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 {
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) {
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) => {
options = common.getOptions('');
options = common.getOptions(1);
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 {
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;
request(options).then(function (body) {
@ -74,8 +74,8 @@ exports.getChannels = (req, res, next) => {
};
exports.postChannel = (req, res, next) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/channels';
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/channels';
options.form = {
node_pubkey_string: req.body.node_pubkey,
local_funding_amount: req.body.local_funding_amount,
@ -108,8 +108,8 @@ exports.postChannel = (req, res, next) => {
};
exports.postTransactions = (req, res, next) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/channels/transactions';
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/channels/transactions';
if(req.body.paymentReq) {
options.form = JSON.stringify({
payment_request: req.body.paymentReq
@ -149,9 +149,9 @@ exports.postTransactions = (req, res, next) => {
exports.closeChannel = (req, res, next) => {
req.setTimeout(60000 * 10); // timeout 10 mins
options = common.getOptions('');
options = common.getOptions(1);
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);
request.delete(options).then((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) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/chanpolicy';
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/chanpolicy';
if(req.body.chanPoint === 'all') {
options.form = JSON.stringify({
global: true,

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

@ -4,8 +4,10 @@ var logger = require('./logger');
var options = {};
exports.getInfo = (req, res, next) => {
options = common.setOptions('');
options.url = common.lnd_server_url + '/getinfo';
common.setOptions();
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);
request(options).then((body) => {
logger.info('\r\nGetInfo: 9: ' + JSON.stringify(Date.now()) + ': INFO: ' + JSON.stringify(body));

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

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

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

@ -1,21 +1,11 @@
var fs = require('fs');
var common = require('../common');
exports.info = (msgStr, selNode = {}) => {
exports.info = (msgStr, selNode = common.nodes[0]) => {
if (msgStr.indexOf('Config Setup Variable') === -1) {
console.log('Console: ' + msgStr);
}
if(!common.multi_node_setup && common.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) {
if(selNode.enable_logging) {
fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) {
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);
if(!common.multi_node_setup && common.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) {
if(selNode.enable_logging) {
fs.appendFile(selNode.log_file, msgStr, function(err) {
if (err) {
return ({ error: 'Updating Log Failed!' });

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

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

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

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

@ -4,8 +4,8 @@ var logger = require('./logger');
var options = {};
exports.forwardingHistory = (req, res, next) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/switch';
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/switch';
options.form = {};
if (undefined !== 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 = {};
exports.getTransactions = (req, res, next) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/transactions';
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/transactions';
request(options).then((body) => {
const body_str = (undefined === body) ? '' : JSON.stringify(body);
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) => {
options = common.getOptions('');
options.url = common.lnd_server_url + '/transactions';
options = common.getOptions(1);
options.url = common.findNode(1).lnd_server_url + '/transactions';
options.form = {
amount: req.body.amount,
addr: req.body.address,

@ -4,16 +4,16 @@ var logger = require('./logger');
var options = {};
exports.operateWallet = (req, res, next) => {
options = common.getOptions('');
options = common.getOptions(1);
var requestBody = {
wallet_password: Buffer.from(req.body.wallet_password).toString('base64')
};
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);
err_message = 'Unlocking wallet failed! Verify that lnd is running and the wallet is locked!';
} else {
options.url = common.lnd_server_url + '/initwallet';
options.url = common.findNode(1).lnd_server_url + '/initwallet';
options.form = JSON.stringify(requestBody);
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 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">
<rtl-side-navigation (ChildNavClicked)="onNavigationClicked($event)"></rtl-side-navigation>
</mat-sidenav>
<mat-sidenav-content perfectScrollbar class="overflow-auto">
<mat-toolbar fxLayout="row" fxLayoutAlign="space-between center" color="primary" class="padding-gap-x">
<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>
</button>
</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>
</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">
<rtl-horizontal-navigation></rtl-horizontal-navigation>
</div>
@ -41,7 +41,7 @@
<rtl-settings-nav (done)="settingSidenav.toggle()"></rtl-settings-nav>
</mat-sidenav>
</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>
<h4>Loading RTL...</h4>
</div>

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

@ -88,7 +88,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.flgLoading[6] = 'error';
}
});
this.settings = rtlStore.settings;
this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information;
if (this.flgLoading[0] !== 'error') {
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.settings = rtlStore.settings;
this.settings = rtlStore.appConfig.nodes[0].settings;
this.information = rtlStore.information;
this.logger.info(rtlStore);
this.loadInvoicesTable(rtlStore.invoices);

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

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

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

@ -7,7 +7,7 @@
</mat-card-subtitle>
</mat-card-header>
<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-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>
@ -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>
</div>
</form>
<div *ngIf="configData !== ''">
<div *ngIf="configData !== '' && fileFormat === 'JSON'">
<pre>{{configData | json}}</pre>
</div>
<div *ngIf="configData !== '' && fileFormat === 'INI'">
<mat-list>
<mat-list-item *ngFor="let conf of configData; index as i;">
<mat-card-subtitle class="my-1">

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

@ -17,7 +17,7 @@
</svg>
</mat-card-content>
<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>
</span>
</mat-card-content>
@ -40,7 +40,7 @@
</svg>
</mat-card-content>
<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>
</span>
</mat-card-content>
@ -63,7 +63,7 @@
</svg>
</mat-card-content>
<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>
</span>
</mat-card-content>

@ -5,7 +5,7 @@ import { Store } from '@ngrx/store';
import { Settings } from '../../../shared/models/RTLconfig';
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 { RTLEffects } from '../../../shared/store/rtl.effects';
@ -18,13 +18,12 @@ import * as fromRTLReducer from '../../../shared/store/rtl.reducers';
styleUrls: ['./send-receive-trans.component.scss']
})
export class SendReceiveTransComponent implements OnInit, OnDestroy {
public settings: Settings;
public appConfig: RTLConfiguration;
public addressTypes = [];
public flgLoadingWallet: Boolean | 'error' = true;
public selectedAddress: AddressType = {};
public blockchainBalance: Balance = {};
public information: GetInfo = {};
public authSettings: Authentication = {};
public newAddress = '';
public transaction: ChannelsTransaction = {};
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.settings = rtlStore.settings;
this.appConfig = rtlStore.appConfig;
this.information = rtlStore.information;
this.addressTypes = rtlStore.addressTypes;
this.authSettings = rtlStore.authSettings;
this.blockchainBalance = rtlStore.blockchainBalance;
if (undefined === this.blockchainBalance.total_balance) {
@ -103,7 +101,7 @@ export class SendReceiveTransComponent implements OnInit, OnDestroy {
.pipe(takeUntil(this.unsub[2]))
.subscribe(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:
{type: 'CONFIRM', titleMessage: 'Enter Login Password', noBtnText: 'Cancel', yesBtnText: 'Authorize', flgShowInput: true, getInputs: [
{placeholder: 'Enter Login Password', inputType: 'password', inputValue: ''}

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

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

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

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

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

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