@ -17,30 +17,30 @@ common.path_separator = (platform === 'win32') ? '\\' : '/';
connect . setDefaultConfig = ( ) => {
var homeDir = os . userInfo ( ) . homedir ;
var macaroonPath = '' ;
var lndC onfigPath = '' ;
var c onfigPath = '' ;
switch ( platform ) {
case 'win32' :
macaroonPath = homeDir + '\\AppData\\Local\\Lnd\\data\\chain\\bitcoin\\mainnet' ;
lndC onfigPath = homeDir + '\\AppData\\Local\\Lnd\\lnd.conf' ;
c onfigPath = homeDir + '\\AppData\\Local\\Lnd\\lnd.conf' ;
break ;
case 'darwin' :
macaroonPath = homeDir + '/Library/Application Support/Lnd/data/chain/bitcoin/mainnet' ;
lndC onfigPath = homeDir + '/Library/Application Support/Lnd/lnd.conf' ;
c onfigPath = homeDir + '/Library/Application Support/Lnd/lnd.conf' ;
break ;
case 'linux' :
macaroonPath = homeDir + '/.lnd/data/chain/bitcoin/mainnet' ;
lndC onfigPath = homeDir + '/.lnd/lnd.conf' ;
c onfigPath = homeDir + '/.lnd/lnd.conf' ;
break ;
default :
macaroonPath = '' ;
lndC onfigPath = '' ;
c onfigPath = '' ;
break ;
}
return {
Authentication : {
macaroonPath : macaroonPath ,
nodeAuthType : 'DEFAULT' ,
lndConfigPath: lndC onfigPath,
configPath: c onfigPath,
rtlPass : ''
} ,
Settings : {
@ -51,7 +51,7 @@ connect.setDefaultConfig = () => {
theme : 'dark-blue' ,
satsToBTC : false ,
channelBackupPath : homeDir + common . path _separator + 'backup' + common . path _separator + 'node-0' ,
ln d ServerUrl: 'https://localhost:8080/v1' ,
ln ServerUrl: 'https://localhost:8080/v1' ,
enableLogging : false ,
port : 3000
} ,
@ -129,15 +129,23 @@ connect.validateSingleNodeConfig = (config) => {
}
if ( undefined !== process . env . LND _SERVER _URL ) {
common . nodes [ 0 ] . lnd _server _url = process . env . LND _SERVER _URL ;
common . nodes [ 0 ] . ln _server _url = process . env . LND _SERVER _URL ;
} else if ( undefined !== process . env . LN _SERVER _URL ) {
common . nodes [ 0 ] . ln _server _url = process . env . LN _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!' ;
if (
( config . Authentication . lndServerUrl === '' || undefined === config . Authentication . lndServerUrl )
&& ( config . Settings . lndServerUrl === '' || undefined === config . Settings . lndServerUrl )
&& ( config . Settings . lnServerUrl === '' || undefined === config . Settings . lnServerUrl )
) {
errMsg = errMsg + '\nPlease set Server URL through environment or RTL.conf!' ;
} else {
if ( config . Settings . lndServerUrl !== '' && undefined !== config . Settings . lndServerUrl ) {
common . nodes [ 0 ] . lnd _server _url = config . Settings . lndServerUrl ;
common . nodes [ 0 ] . ln _server _url = config . Settings . lndServerUrl ;
} else if ( config . Authentication . lndServerUrl !== '' && undefined !== config . Authentication . lndServerUrl ) {
common . nodes [ 0 ] . lnd _server _url = config . Authentication . lndServerUrl ;
common . nodes [ 0 ] . ln _server _url = config . Authentication . lndServerUrl ;
} else if ( config . Settings . lnServerUrl !== '' && undefined !== config . Settings . lnServerUrl ) {
common . nodes [ 0 ] . ln _server _url = config . Settings . lnServerUrl ;
}
}
}
@ -153,10 +161,14 @@ connect.validateSingleNodeConfig = (config) => {
}
if ( undefined !== process . env . LND _CONFIG _PATH ) {
common . nodes [ 0 ] . lnd _config _path = process . env . LND _CONFIG _PATH ;
common . nodes [ 0 ] . config _path = process . env . LND _CONFIG _PATH ;
} else if ( undefined !== process . env . CONFIG _PATH ) {
common . nodes [ 0 ] . config _path = process . env . CONFIG _PATH ;
} else {
if ( config . Authentication . lndConfigPath !== '' && undefined !== config . Authentication . lndConfigPath ) {
common . nodes [ 0 ] . lnd _config _path = config . Authentication . lndConfigPath ;
common . nodes [ 0 ] . config _path = config . Authentication . lndConfigPath ;
} else if ( config . Authentication . ConfigPath !== '' && undefined !== config . Authentication . ConfigPath ) {
common . nodes [ 0 ] . config _path = config . Authentication . ConfigPath ;
} 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!' ;
@ -268,16 +280,25 @@ connect.validateMultiNodeConfig = (config) => {
common . nodes [ idx ] . macaroon _path = node . Authentication . macaroonPath ;
}
if ( ( node . Settings . lndServerUrl === '' || undefined === node . Settings . lndServerUrl ) ) {
errMsg = errMsg + '\nPlease set LND server URL for node index ' + node . index + ' in RTL-Multi-Node-Conf.json!' ;
if (
( node . Settings . lndServerUrl === '' || undefined === node . Settings . lndServerUrl )
&& ( node . Settings . lnServerUrl === '' || undefined === node . Settings . lnServerUrl )
) {
errMsg = errMsg + '\nPlease set server URL for node index ' + node . index + ' in RTL-Multi-Node-Conf.json!' ;
} else {
common . nodes [ idx ] . lnd _server _url = node . Settings . lndServerUrl ;
common . nodes [ idx ] . ln _server _url = node . Settings . lnd ServerUrl ? node . Settings . lndServerUrl : node . Settings . ln ServerUrl;
}
common . nodes [ idx ] . index = node . index ;
common . nodes [ idx ] . ln _node = node . lnNode ;
common . nodes [ idx ] . ln _implementation = node . lnImplementation ;
common . nodes [ idx ] . lnd _config _path = ( undefined !== node . Authentication && undefined !== node . Authentication . lndConfigPath ) ? node . Authentication . lndConfigPath : '' ;
if ( undefined !== node . Authentication && undefined !== node . Authentication . lndConfigPath ) {
common . nodes [ idx ] . config _path = node . Authentication . lndConfigPath ;
} else if ( undefined !== node . Authentication && undefined !== node . Authentication . configPath ) {
common . nodes [ idx ] . config _path = node . Authentication . configPath ;
} else {
common . nodes [ idx ] . config _path = '' ;
}
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 ] . channel _backup _path = ( undefined !== node . Settings . channelBackupPath ) ? node . Settings . channelBackupPath : common . rtl _conf _file _path + common . path _separator + 'backup' + common . path _separator + 'node-' + node . index ;
@ -408,9 +429,9 @@ connect.logEnvVariables = () => {
logger . info ( { fileName : 'Config Setup Variable' , msg : 'LN IMPLEMENTATION: ' + node . ln _implementation , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'PORT: ' + common . port , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'MACAROON_PATH: ' + node . macaroon _path , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'LND_SERVER_URL: ' + node . ln d _server _url , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'LND_SERVER_URL: ' + node . ln _server _url , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'RTL_CONFIG_PATH: ' + node . rtl _conf _file _path , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : ' LND_ CONFIG_PATH: ' + node . lnd_ config_path , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : ' CONFIG_PATH: ' + node . config_path , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'BITCOIND_CONFIG_PATH: ' + node . bitcoind _config _path , node } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'CHANNEL_BACKUP_PATH: ' + node . channel _backup _path , node } ) ;
} ) ;
@ -418,10 +439,10 @@ connect.logEnvVariables = () => {
if ( ! common . nodes [ 0 ] . enable _logging ) { return ; }
logger . info ( { fileName : 'Config Setup Variable' , msg : 'NODE_SETUP: SINGLE' } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'PORT: ' + common . port } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'LND_SERVER_URL: ' + common . nodes [ 0 ] . ln d _server _url } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'LND_SERVER_URL: ' + common . nodes [ 0 ] . ln _server _url } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'MACAROON_PATH: ' + common . nodes [ 0 ] . macaroon _path } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'NODE_AUTH_TYPE: ' + common . node _auth _type } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : ' LND_ CONFIG_PATH: ' + common . nodes [ 0 ] . lnd_ config_path } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : ' CONFIG_PATH: ' + common . nodes [ 0 ] . config_path } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'RTL_CONFIG_PATH: ' + common . rtl _conf _file _path } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'BITCOIND_CONFIG_PATH: ' + common . nodes [ 0 ] . bitcoind _config _path } ) ;
logger . info ( { fileName : 'Config Setup Variable' , msg : 'CHANNEL_BACKUP_PATH: ' + common . nodes [ 0 ] . channel _backup _path } ) ;
@ -434,7 +455,7 @@ connect.logEnvVariables = () => {
connect . getAllNodeAllChannelBackup = ( node ) => {
let channel _backup _file = node . channel _backup _path + common . path _separator + 'channel-all.bak' ;
let options = {
url : node . ln d _server _url + '/channels/backup' ,
url : node . ln _server _url + '/channels/backup' ,
rejectUnauthorized : false ,
json : true ,
headers : { 'Grpc-Metadata-macaroon' : fs . readFileSync ( node . macaroon _path + '/admin.macaroon' ) . toString ( 'hex' ) }