Added missing env

Added missing env
This commit is contained in:
Shahana Farooqui 2020-01-21 17:04:26 -05:00
parent 7dfb355ead
commit 0da59b75da
9 changed files with 81 additions and 63 deletions

View File

@ -12,5 +12,5 @@
<link rel="stylesheet" href="styles.90ee7bcb73e8367b2a29.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.2e6ad7cb977005b4f6b6.js" defer></script><script src="polyfills-es5.37b2eeccc22c1df73ce7.js" nomodule defer></script><script src="polyfills.f1c3d2a0bcdfc4e93ca8.js" defer></script><script src="main.358e40c47b3010ffb98f.js" defer></script></body>
<script src="runtime.2e6ad7cb977005b4f6b6.js" defer></script><script src="polyfills-es5.37b2eeccc22c1df73ce7.js" nomodule defer></script><script src="polyfills.f1c3d2a0bcdfc4e93ca8.js" defer></script><script src="main.0990540ecd60b7ec6d35.js" defer></script></body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -82,22 +82,6 @@ connect.normalizePort = val => {
return false;
};
connect.setMacaroonPath = (clArgs, config) => {
common.nodes[0] = {};
common.nodes[0].index = 1;
if(clArgs.lndir) {
common.nodes[0].macaroon_path = clArgs.lndir;
} else if (process.env.MACAROON_PATH) {
common.nodes[0].macaroon_path = process.env.MACAROON_PATH;
} else {
if(config.Authentication.macroonPath && config.Authentication.macroonPath !== '') {
common.nodes[0].macaroon_path = config.Authentication.macroonPath;
} else if(config.Authentication.macaroonPath && config.Authentication.macaroonPath !== '') {
common.nodes[0].macaroon_path = config.Authentication.macaroonPath;
}
}
}
connect.convertCustomToHash = () => {
common.rtl_conf_file_path = process.env.RTL_CONFIG_PATH ? process.env.RTL_CONFIG_PATH : path.normalize(__dirname);
try {
@ -125,43 +109,50 @@ connect.validateNodeConfig = (config) => {
errMsg = errMsg + '\nNode Authentication can be set with multiPass only. Please set multiPass in RTL-Config.json';
}
}
common.port = (config.port) ? connect.normalizePort(config.port) : 3000;
common.port = (process.env.PORT) ? connect.normalizePort(process.env.PORT) : (config.port) ? connect.normalizePort(config.port) : 3000;
if (config.nodes && config.nodes.length > 0) {
config.nodes.forEach((node, idx) => {
common.nodes[idx] = {};
if(node.Authentication.macaroonPath === '' || !node.Authentication.macaroonPath) {
errMsg = 'Please set macaroon path for node index ' + node.index + ' in RTL-Config.json!';
} else {
if (process.env.MACAROON_PATH && process.env.MACAROON_PATH.trim() !== '') {
common.nodes[idx].macaroon_path = process.env.MACAROON_PATH;
} else if(node.Authentication && node.Authentication.macaroonPath && node.Authentication.macaroonPath.trim() !== '') {
common.nodes[idx].macaroon_path = node.Authentication.macaroonPath;
} else {
errMsg = 'Please set macaroon path for node index ' + node.index + ' in RTL-Config.json!';
}
if(
(node.Settings.lndServerUrl === '' || !node.Settings.lndServerUrl)
&& (node.Settings.lnServerUrl === '' || !node.Settings.lnServerUrl)
) {
errMsg = errMsg + '\nPlease set server URL for node index ' + node.index + ' in RTL-Config.json!';
if(process.env.LN_SERVER_URL && process.env.LN_SERVER_URL.trim() !== '') {
common.nodes[idx].ln_server_url = process.env.LN_SERVER_URL;
} else if(node.Settings.lnServerUrl && node.Settings.lnServerUrl.trim() !== '') {
common.nodes[idx].ln_server_url = node.Settings.lnServerUrl;
} else if(node.Settings.lndServerUrl && node.Settings.lndServerUrl.trim() !== '') {
common.nodes[idx].ln_server_url = node.Settings.lndServerUrl;
} else {
common.nodes[idx].ln_server_url = node.Settings.lndServerUrl ? node.Settings.lndServerUrl : node.Settings.lnServerUrl;
errMsg = errMsg + '\nPlease set LN Server URL for node index ' + node.index + ' in RTL-Config.json!';
}
common.nodes[idx].index = node.index;
common.nodes[idx].ln_node = node.lnNode;
common.nodes[idx].ln_implementation = node.lnImplementation;
common.nodes[idx].fiat_conversion = node.Settings.fiatConversion ? node.Settings.fiatConversion : false;
common.nodes[idx].ln_implementation = (process.env.LN_IMPLEMENTATION) ? process.env.LN_IMPLEMENTATION : node.lnImplementation ? node.lnImplementation : 'LND';
common.nodes[idx].user_persona = node.Settings.userPersona ? node.Settings.userPersona : 'MERCHANT';
common.nodes[idx].theme_mode = node.Settings.themeMode ? node.Settings.themeMode : 'DAY';
common.nodes[idx].theme_color = node.Settings.themeColor ? node.Settings.themeColor : 'PURPLE';
common.nodes[idx].fiat_conversion = node.Settings.fiatConversion ? !!node.Settings.fiatConversion : false;
if(common.nodes[idx].fiat_conversion) {
common.nodes[idx].currency_unit = node.Settings.currencyUnit ? node.Settings.currencyUnit : 'USD';
}
if (node.Authentication && node.Authentication.lndConfigPath) {
if (process.env.CONFIG_PATH) {
common.nodes[idx].config_path = process.env.CONFIG_PATH;
} else if (node.Authentication && node.Authentication.lndConfigPath) {
common.nodes[idx].config_path = node.Authentication.lndConfigPath;
} else if (node.Authentication && node.Authentication.configPath) {
common.nodes[idx].config_path = node.Authentication.configPath;
} else {
common.nodes[idx].config_path = '';
}
common.nodes[idx].bitcoind_config_path = (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
common.nodes[idx].bitcoind_config_path = process.env.BITCOIND_CONFIG_PATH ? process.env.BITCOIND_CONFIG_PATH : (node.Settings.bitcoindConfigPath) ? node.Settings.bitcoindConfigPath : '';
common.nodes[idx].enable_logging = (node.Settings.enableLogging) ? !!node.Settings.enableLogging : false;
common.nodes[idx].channel_backup_path = (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.rtl_conf_file_path + common.path_separator + 'backup' + common.path_separator + 'node-' + node.index;
common.nodes[idx].channel_backup_path = process.env.CHANNEL_BACKUP_PATH ? process.env.CHANNEL_BACKUP_PATH : (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.rtl_conf_file_path + common.path_separator + 'backup' + common.path_separator + 'node-' + node.index;
try {
connect.createDirectory(common.nodes[idx].channel_backup_path);
let exists = fs.existsSync(common.nodes[idx].channel_backup_path + common.path_separator + 'channel-all.bak');
@ -295,7 +286,7 @@ connect.logEnvVariables = () => {
logger.info({fileName: 'Config Setup Variable', msg: 'INDEX: ' + node.index, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN NODE: ' + node.ln_node, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN IMPLEMENTATION: ' + node.ln_implementation, node});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + node.fiatConversion, node});
logger.info({fileName: 'Config Setup Variable', msg: 'FIAT CONVERSION: ' + node.fiat_conversion, node});
logger.info({fileName: 'Config Setup Variable', msg: 'CURRENCY UNIT: ' + node.currency_unit, node});
logger.info({fileName: 'Config Setup Variable', msg: 'LN SERVER URL: ' + node.ln_server_url, node});
});
@ -452,9 +443,13 @@ connect.upgradeIniToJson = (confFileFullPath) => {
if (config.Settings.currencyUnit) {
newConfig.nodes[0].Settings.currencyUnit = config.Settings.currencyUnit;
}
if (config.Settings.bitcoindConfigPath) {
newConfig.nodes[0].Settings.bitcoindConfigPath = config.Settings.bitcoindConfigPath;
} else if(config.Authentication.bitcoindConfigPath) {
newConfig.nodes[0].Settings.bitcoindConfigPath = config.Authentication.bitcoindConfigPath;
}
if (config.Settings.channelBackupPath) {
newConfig.nodes[0].Settings.channelBackupPath = config.Settings.channelBackupPath;
}

View File

@ -8,7 +8,7 @@ var options = {};
exports.updateSelectedNode = (req, res, next) => {
const selNodeIndex = req.body.selNodeIndex;
common.selectedNode = common.findNode(selNodeIndex);
const responseVal = !common.selectedNode ? '' : (common.selectedNode.ln_node ? common.selectedNode.ln_node : common.selectedNode.ln_server_url);
const responseVal = common.selectedNode && common.selectedNode.ln_node ? common.selectedNode.ln_node : '';
logger.info({fileName: 'RTLConf', msg: 'Selected Node Updated To: ' + JSON.stringify(responseVal)});
res.status(200).json({status: 'Selected Node Updated To: ' + JSON.stringify(responseVal) + '!'});
};
@ -32,27 +32,53 @@ exports.getRTLConfig = (req, res, next) => {
const nodeConfData = JSON.parse(data);
const sso = { rtlSSO: common.rtl_sso, logoutRedirectLink: common.logout_redirect_link };
var nodesArr = [];
if (nodeConfData.nodes && nodeConfData.nodes.length > 0) {
nodeConfData.nodes.forEach((node, i) => {
// if (nodeConfData.nodes && nodeConfData.nodes.length > 0) {
// nodeConfData.nodes.forEach((node, i) => {
// const authentication = {};
// if(node.Authentication && node.Authentication.lndConfigPath) {
// authentication.configPath = node.Authentication.lndConfigPath;
// } else if(node.Authentication && node.Authentication.configPath) {
// authentication.configPath = node.Authentication.configPath;
// } else {
// authentication.configPath = '';
// }
// if(node.Settings.bitcoindConfigPath) {
// authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath;
// }
// node.Settings.channelBackupPath = (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.nodes[i].channel_backup_path;
// node.Settings.themeMode = (node.Settings.themeMode) ? node.Settings.themeMode : 'DAY';
// node.Settings.themeColor = (node.Settings.themeColor) ? node.Settings.themeColor : 'PURPLE';
// nodesArr.push({
// index: node.index,
// lnNode: node.lnNode,
// lnImplementation: node.lnImplementation,
// settings: node.Settings,
// authentication: authentication})
// });
// }
if (common.nodes && common.nodes.length > 0) {
common.nodes.forEach((node, i) => {
const authentication = {};
if(node.Authentication && node.Authentication.lndConfigPath) {
authentication.configPath = node.Authentication.lndConfigPath;
} else if(node.Authentication && node.Authentication.configPath) {
authentication.configPath = node.Authentication.configPath;
if(node.config_path) {
authentication.configPath = node.config_path;
} else {
authentication.configPath = '';
}
if(node.Settings.bitcoindConfigPath) {
authentication.bitcoindConfigPath = node.Settings.bitcoindConfigPath;
}
node.Settings.channelBackupPath = (node.Settings.channelBackupPath) ? node.Settings.channelBackupPath : common.nodes[i].channel_backup_path;
node.Settings.themeMode = (node.Settings.themeMode) ? node.Settings.themeMode : 'DAY';
node.Settings.themeColor = (node.Settings.themeColor) ? node.Settings.themeColor : 'PURPLE';
const settings = {};
settings.userPersona = node.user_persona ? node.user_persona : 'MERCHANT';
settings.themeMode = (node.theme_mode) ? node.theme_mode : 'DAY';
settings.themeColor = (node.theme_color) ? node.theme_color : 'PURPLE';
settings.fiatConversion = (node.fiat_conversion) ? !!node.fiat_conversion : false;
settings.bitcoindConfigPath = node.bitcoind_config_path;
settings.enableLogging = node.enable_logging ? !!node.enable_logging : false;
settings.lnServerUrl = node.ln_server_url;
settings.channelBackupPath = node.channel_backup_path;
settings.currencyUnit = node.currency_unit;
nodesArr.push({
index: node.index,
lnNode: node.lnNode,
lnImplementation: node.lnImplementation,
settings: node.Settings,
lnNode: node.ln_node,
lnImplementation: node.ln_implementation,
settings: settings,
authentication: authentication})
});
}

View File

@ -10,7 +10,7 @@ exports.getInfo = (req, res, next) => {
options.url = common.getSelLNServerUrl() + '/getinfo';
logger.info({fileName:'GetInfo', msg: 'Selected Node: ' + JSON.stringify(common.selectedNode.ln_node)});
if (!options.headers || !options.headers['Grpc-Metadata-macaroon']) {
logger.error({fileName: 'GetInfo', lineNum: 17, msg: 'Get info failed due to bad or missing macaroon!'});
logger.error({fileName: 'GetInfo', lineNum: 17, msg: 'LND Get info failed due to bad or missing macaroon!'});
res.status(502).json({
message: "Fetching Info Failed!",
error: "Bad Macaroon"

View File

@ -69,7 +69,7 @@ services:
rtl:
container_name: ${COMPOSE_PROJECT_NAME}_rtl
image: shahanafarooqui/rtl:0.2.16
image: shahanafarooqui/rtl:0.6.4
restart: unless-stopped
depends_on:
- lnd
@ -80,7 +80,6 @@ services:
environment:
PORT: ${RTL_PORT}
MACAROON_PATH: /shared
LND_SERVER_URL: https://${LIGHTNING_HOST}:${LIGHTNING_REST_PORT}/v1
LND_CONFIG_PATH: ''
NODE_AUTH_TYPE: ${RTL_NODE_AUTH_TYPE}
LN_SERVER_URL: https://${LIGHTNING_HOST}:${LIGHTNING_REST_PORT}/v1
CONFIG_PATH: ''
RTL_PASS: ${RTL_PASS}

View File

@ -39,15 +39,14 @@ The parameters can be configured via RTL-Config.json file or through environment
;The environment variable can also be used for all of the above configurations except the UI settings.
;If the environment variables are set, it will take precedence over the parameters in the RTL-Config.json file.
PORT (port number for the rtl node server, default 3000)
NODE_AUTH_TYPE (For stand alone RTL authentication allowed value - CUSTOM)
RTL_PASS (Password for RTL custom authentication)
LN_IMPLEMENTATION (LND, CLT. Default 'LND')
LN_SERVER_URL (LND server URL for REST APIs, default https://localhost:8080/v1) OR LN_SERVER_URL (LN server URL for LNP REST APIs)
LN_CONFIG_PATH (Full path of the lnd.conf file including the file name) OR CONFIG_PATH (Full path of the LNP .conf file including the file name)
CONFIG_PATH (Full path of the lnd.conf file including the file name) OR CONFIG_PATH (Full path of the LNP .conf file including the file name)
MACAROON_PATH (Path for the folder containing 'admin.macaroon' file)
RTL_SSO (1 - single sign on via an external cookie, 0 - stand alone RTL authentication)
RTL_COOKIE_PATH (Full path of the cookie file including the file name)
LOGOUT_REDIRECT_LINK (URL to re-direct to after logout/timeout from RTL)
RTL_CONFIG_PATH (Full path of the RTL-Config.json file including the file name)
RTL_CONFIG_PATH (Path for the folder containing 'RTL-Config.json' file)
BITCOIND_CONFIG_PATH (Full path of the bitcoind.conf file including the file name)
CHANNEL_BACKUP_PATH (folder location for saving the channel backup files, valid for LND implementation only)

View File

@ -30,10 +30,10 @@ export class SettingsComponent implements OnInit, OnDestroy{
this.showBitcoind = false;
this.selNode = rtlStore.selNode;
this.lnImplementationStr = this.selNode.lnImplementation.toUpperCase() === 'CLT' ? 'C-Lightning Config' : 'LND Config';
if (undefined !== this.selNode.authentication && undefined !== this.selNode.authentication.configPath && this.selNode.authentication.configPath !== '') {
if (this.selNode.authentication && this.selNode.authentication.configPath && this.selNode.authentication.configPath.trim() !== '') {
this.showLnConfig = true;
}
if (undefined !== this.selNode.authentication && undefined !== this.selNode.authentication.bitcoindConfigPath && this.selNode.authentication.bitcoindConfigPath !== '') {
if (this.selNode.settings && this.selNode.settings.bitcoindConfigPath && this.selNode.settings.bitcoindConfigPath.trim() !== '') {
this.showBitcoind = true;
}
});

View File

@ -24,8 +24,7 @@ export class Settings {
export class Authentication {
constructor(
public configPath?: string,
public bitcoindConfigPath?: string
public configPath?: string
) { }
}