@ -61,11 +61,11 @@ export class ConfigService {
index : 1 ,
index : 1 ,
lnNode : 'Node 1' ,
lnNode : 'Node 1' ,
lnImplementation : 'LND' ,
lnImplementation : 'LND' ,
A uthentication: {
a uthentication: {
macaroonPath : macaroonPath ,
macaroonPath : macaroonPath ,
configPath : configPath
configPath : configPath
} ,
} ,
S ettings: {
s ettings: {
userPersona : 'MERCHANT' ,
userPersona : 'MERCHANT' ,
themeMode : 'DAY' ,
themeMode : 'DAY' ,
themeColor : 'PURPLE' ,
themeColor : 'PURPLE' ,
@ -100,10 +100,10 @@ export class ConfigService {
const RTLConfFile = this . common . appConfig . rtlConfFilePath + sep + 'RTL-Config.json' ;
const RTLConfFile = this . common . appConfig . rtlConfFilePath + sep + 'RTL-Config.json' ;
const config = JSON . parse ( fs . readFileSync ( RTLConfFile , 'utf-8' ) ) ;
const config = JSON . parse ( fs . readFileSync ( RTLConfFile , 'utf-8' ) ) ;
config . nodes . forEach ( ( node ) => {
config . nodes . forEach ( ( node ) => {
if ( node . S ettings. hasOwnProperty ( 'enableLogging' ) ) {
if ( node . s ettings. hasOwnProperty ( 'enableLogging' ) ) {
updateLogFlag = true ;
updateLogFlag = true ;
node . Settings. logLevel = node . S ettings. enableLogging ? 'INFO' : 'ERROR' ;
node . settings. logLevel = node . s ettings. enableLogging ? 'INFO' : 'ERROR' ;
delete node . S ettings. enableLogging ;
delete node . s ettings. enableLogging ;
}
}
} ) ;
} ) ;
if ( updateLogFlag ) {
if ( updateLogFlag ) {
@ -142,7 +142,7 @@ export class ConfigService {
config . dbDirectoryPath = ( process ? . env ? . DB _DIRECTORY _PATH ) ? process ? . env ? . DB _DIRECTORY _PATH : ( config . dbDirectoryPath ) ? config . dbDirectoryPath : join ( dirname ( fileURLToPath ( import . meta . url ) ) , '..' , '..' ) ;
config . dbDirectoryPath = ( process ? . env ? . DB _DIRECTORY _PATH ) ? process ? . env ? . DB _DIRECTORY _PATH : ( config . dbDirectoryPath ) ? config . dbDirectoryPath : join ( dirname ( fileURLToPath ( import . meta . url ) ) , '..' , '..' ) ;
if ( config . nodes && config . nodes . length > 0 ) {
if ( config . nodes && config . nodes . length > 0 ) {
config . nodes . forEach ( ( node , idx ) => {
config . nodes . forEach ( ( node , idx ) => {
this . common . nodes [ idx ] = { Settings: { } , A uthentication: { } } ;
this . common . nodes [ idx ] = { settings: { } , a uthentication: { } } ;
this . common . nodes [ idx ] . index = node . index ;
this . common . nodes [ idx ] . index = node . index ;
this . common . nodes [ idx ] . lnNode = node . lnNode ;
this . common . nodes [ idx ] . lnNode = node . lnNode ;
this . common . nodes [ idx ] . lnImplementation = ( process ? . env ? . lnImplementation ) ? process ? . env ? . lnImplementation : node . lnImplementation ? node . lnImplementation : 'LND' ;
this . common . nodes [ idx ] . lnImplementation = ( process ? . env ? . lnImplementation ) ? process ? . env ? . lnImplementation : node . lnImplementation ? node . lnImplementation : 'LND' ;
@ -152,10 +152,10 @@ export class ConfigService {
switch ( this . common . nodes [ idx ] . lnImplementation ) {
switch ( this . common . nodes [ idx ] . lnImplementation ) {
case 'CLN' :
case 'CLN' :
if ( process ? . env ? . RUNE _PATH && process ? . env ? . RUNE _PATH . trim ( ) !== '' ) {
if ( process ? . env ? . RUNE _PATH && process ? . env ? . RUNE _PATH . trim ( ) !== '' ) {
this . common . nodes [ idx ] . A uthentication. runePath = process ? . env ? . RUNE _PATH ;
this . common . nodes [ idx ] . a uthentication. runePath = process ? . env ? . RUNE _PATH ;
}
}
else if ( node . Authentication && node . Authentication . runePath && node . A uthentication. runePath . trim ( ) !== '' ) {
else if ( node . authentication && node . authentication . runePath && node . a uthentication. runePath . trim ( ) !== '' ) {
this . common . nodes [ idx ] . Authentication. runePath = node . A uthentication. runePath ;
this . common . nodes [ idx ] . authentication. runePath = node . a uthentication. runePath ;
}
}
else {
else {
this . errMsg = 'Please set rune path for node index ' + node . index + ' in RTL-Config.json!' ;
this . errMsg = 'Please set rune path for node index ' + node . index + ' in RTL-Config.json!' ;
@ -163,21 +163,21 @@ export class ConfigService {
break ;
break ;
case 'ECL' :
case 'ECL' :
if ( process ? . env ? . LN _API _PASSWORD ) {
if ( process ? . env ? . LN _API _PASSWORD ) {
this . common . nodes [ idx ] . A uthentication. lnApiPassword = process ? . env ? . LN _API _PASSWORD ;
this . common . nodes [ idx ] . a uthentication. lnApiPassword = process ? . env ? . LN _API _PASSWORD ;
}
}
else if ( node . Authentication && node . A uthentication. lnApiPassword ) {
else if ( node . authentication && node . a uthentication. lnApiPassword ) {
this . common . nodes [ idx ] . Authentication. lnApiPassword = node . A uthentication. lnApiPassword ;
this . common . nodes [ idx ] . authentication. lnApiPassword = node . a uthentication. lnApiPassword ;
}
}
else {
else {
this . common . nodes [ idx ] . A uthentication. lnApiPassword = '' ;
this . common . nodes [ idx ] . a uthentication. lnApiPassword = '' ;
}
}
break ;
break ;
default :
default :
if ( process ? . env ? . MACAROON _PATH && process ? . env ? . MACAROON _PATH . trim ( ) !== '' ) {
if ( process ? . env ? . MACAROON _PATH && process ? . env ? . MACAROON _PATH . trim ( ) !== '' ) {
this . common . nodes [ idx ] . A uthentication. macaroonPath = process ? . env ? . MACAROON _PATH ;
this . common . nodes [ idx ] . a uthentication. macaroonPath = process ? . env ? . MACAROON _PATH ;
}
}
else if ( node . Authentication && node . Authentication . macaroonPath && node . A uthentication. macaroonPath . trim ( ) !== '' ) {
else if ( node . authentication && node . authentication . macaroonPath && node . a uthentication. macaroonPath . trim ( ) !== '' ) {
this . common . nodes [ idx ] . Authentication. macaroonPath = node . A uthentication. macaroonPath ;
this . common . nodes [ idx ] . authentication. macaroonPath = node . a uthentication. macaroonPath ;
}
}
else {
else {
this . errMsg = 'Please set macaroon path for node index ' + node . index + ' in RTL-Config.json!' ;
this . errMsg = 'Please set macaroon path for node index ' + node . index + ' in RTL-Config.json!' ;
@ -185,100 +185,100 @@ export class ConfigService {
break ;
break ;
}
}
if ( process ? . env ? . CONFIG _PATH ) {
if ( process ? . env ? . CONFIG _PATH ) {
this . common . nodes [ idx ] . A uthentication. configPath = process ? . env ? . CONFIG _PATH ;
this . common . nodes [ idx ] . a uthentication. configPath = process ? . env ? . CONFIG _PATH ;
}
}
else if ( node . Authentication && node . A uthentication. configPath ) {
else if ( node . authentication && node . a uthentication. configPath ) {
this . common . nodes [ idx ] . Authentication. configPath = node . A uthentication. configPath ;
this . common . nodes [ idx ] . authentication. configPath = node . a uthentication. configPath ;
}
}
else {
else {
this . common . nodes [ idx ] . A uthentication. configPath = '' ;
this . common . nodes [ idx ] . a uthentication. configPath = '' ;
}
}
if ( this . common . nodes [ idx ] . lnImplementation === 'ECL' && this . common . nodes [ idx ] . A uthentication. lnApiPassword === '' && this . common . nodes [ idx ] . A uthentication. configPath !== '' ) {
if ( this . common . nodes [ idx ] . lnImplementation === 'ECL' && this . common . nodes [ idx ] . a uthentication. lnApiPassword === '' && this . common . nodes [ idx ] . a uthentication. configPath !== '' ) {
try {
try {
const exists = fs . existsSync ( this . common . nodes [ idx ] . A uthentication. configPath || '' ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . a uthentication. configPath || '' ) ;
if ( exists ) {
if ( exists ) {
try {
try {
const configFile = fs . readFileSync ( ( this . common . nodes [ idx ] . A uthentication. configPath || '' ) , 'utf-8' ) ;
const configFile = fs . readFileSync ( ( this . common . nodes [ idx ] . a uthentication. configPath || '' ) , 'utf-8' ) ;
const iniParsed = ini . parse ( configFile ) ;
const iniParsed = ini . parse ( configFile ) ;
this . common . nodes [ idx ] . A uthentication. lnApiPassword = iniParsed [ 'eclair.api.password' ] ? iniParsed [ 'eclair.api.password' ] : parseHocon ( configFile ) . eclair . api . password ;
this . common . nodes [ idx ] . a uthentication. lnApiPassword = iniParsed [ 'eclair.api.password' ] ? iniParsed [ 'eclair.api.password' ] : parseHocon ( configFile ) . eclair . api . password ;
}
}
catch ( err ) {
catch ( err ) {
this . errMsg = this . errMsg + '\nSomething went wrong while reading config file: \n' + err ;
this . errMsg = this . errMsg + '\nSomething went wrong while reading config file: \n' + err ;
}
}
}
}
else {
else {
this . errMsg = this . errMsg + '\nInvalid config path: ' + this . common . nodes [ idx ] . A uthentication. configPath ;
this . errMsg = this . errMsg + '\nInvalid config path: ' + this . common . nodes [ idx ] . a uthentication. configPath ;
}
}
}
}
catch ( err ) {
catch ( err ) {
this . errMsg = this . errMsg + '\nUnable to read config file: \n' + err ;
this . errMsg = this . errMsg + '\nUnable to read config file: \n' + err ;
}
}
}
}
if ( this . common . nodes [ idx ] . lnImplementation === 'ECL' && this . common . nodes [ idx ] . A uthentication. lnApiPassword === '' ) {
if ( this . common . nodes [ idx ] . lnImplementation === 'ECL' && this . common . nodes [ idx ] . a uthentication. lnApiPassword === '' ) {
this . errMsg = this . errMsg + '\nPlease set config path Or api password for node index ' + node . index + ' in RTL-Config.json! It is mandatory for Eclair authentication!' ;
this . errMsg = this . errMsg + '\nPlease set config path Or api password for node index ' + node . index + ' in RTL-Config.json! It is mandatory for Eclair authentication!' ;
}
}
if ( process ? . env ? . LN _SERVER _URL && process ? . env ? . LN _SERVER _URL . trim ( ) !== '' ) {
if ( process ? . env ? . LN _SERVER _URL && process ? . env ? . LN _SERVER _URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . S ettings. lnServerUrl = process ? . env ? . LN _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . LN _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . LN _SERVER _URL ;
this . common . nodes [ idx ] . s ettings. lnServerUrl = process ? . env ? . LN _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . LN _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . LN _SERVER _URL ;
}
}
else if ( process ? . env ? . LND _SERVER _URL && process ? . env ? . LND _SERVER _URL . trim ( ) !== '' ) {
else if ( process ? . env ? . LND _SERVER _URL && process ? . env ? . LND _SERVER _URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . S ettings. lnServerUrl = process ? . env ? . LND _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . LND _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . LND _SERVER _URL ;
this . common . nodes [ idx ] . s ettings. lnServerUrl = process ? . env ? . LND _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . LND _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . LND _SERVER _URL ;
}
}
else if ( node . Settings. lnServerUrl && node . S ettings. lnServerUrl . trim ( ) !== '' ) {
else if ( node . settings. lnServerUrl && node . s ettings. lnServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . Settings. lnServerUrl = node . S ettings. lnServerUrl . endsWith ( '/v1' ) ? node . S ettings. lnServerUrl . slice ( 0 , - 3 ) : node . S ettings. lnServerUrl ;
this . common . nodes [ idx ] . settings. lnServerUrl = node . s ettings. lnServerUrl . endsWith ( '/v1' ) ? node . s ettings. lnServerUrl . slice ( 0 , - 3 ) : node . s ettings. lnServerUrl ;
}
}
else if ( node . Settings. lndServerUrl && node . S ettings. lndServerUrl . trim ( ) !== '' ) {
else if ( node . settings. lndServerUrl && node . s ettings. lndServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . Settings. lnServerUrl = node . S ettings. lndServerUrl . endsWith ( '/v1' ) ? node . S ettings. lndServerUrl . slice ( 0 , - 3 ) : node . S ettings. lndServerUrl ;
this . common . nodes [ idx ] . settings. lnServerUrl = node . s ettings. lndServerUrl . endsWith ( '/v1' ) ? node . s ettings. lndServerUrl . slice ( 0 , - 3 ) : node . s ettings. lndServerUrl ;
}
}
else {
else {
this . errMsg = this . errMsg + '\nPlease set LN Server URL for node index ' + node . index + ' in RTL-Config.json!' ;
this . errMsg = this . errMsg + '\nPlease set LN Server URL for node index ' + node . index + ' in RTL-Config.json!' ;
}
}
this . common . nodes [ idx ] . Settings. userPersona = node . Settings . userPersona ? node . S ettings. userPersona : 'MERCHANT' ;
this . common . nodes [ idx ] . settings. userPersona = node . settings . userPersona ? node . s ettings. userPersona : 'MERCHANT' ;
this . common . nodes [ idx ] . Settings. themeMode = node . Settings . themeMode ? node . S ettings. themeMode : 'DAY' ;
this . common . nodes [ idx ] . settings. themeMode = node . settings . themeMode ? node . s ettings. themeMode : 'DAY' ;
this . common . nodes [ idx ] . Settings. themeColor = node . Settings . themeColor ? node . S ettings. themeColor : 'PURPLE' ;
this . common . nodes [ idx ] . settings. themeColor = node . settings . themeColor ? node . s ettings. themeColor : 'PURPLE' ;
this . common . nodes [ idx ] . Settings. unannouncedChannels = node . S ettings. unannouncedChannels ? ! ! node . S ettings. unannouncedChannels : false ;
this . common . nodes [ idx ] . settings. unannouncedChannels = node . s ettings. unannouncedChannels ? ! ! node . s ettings. unannouncedChannels : false ;
this . common . nodes [ idx ] . Settings. logLevel = node . Settings . logLevel ? node . S ettings. logLevel : 'ERROR' ;
this . common . nodes [ idx ] . settings. logLevel = node . settings . logLevel ? node . s ettings. logLevel : 'ERROR' ;
this . common . nodes [ idx ] . Settings. fiatConversion = node . Settings . fiatConversion ? ! ! node . S ettings. fiatConversion : false ;
this . common . nodes [ idx ] . settings. fiatConversion = node . settings . fiatConversion ? ! ! node . s ettings. fiatConversion : false ;
if ( this . common . nodes [ idx ] . S ettings. fiatConversion ) {
if ( this . common . nodes [ idx ] . s ettings. fiatConversion ) {
this . common . nodes [ idx ] . Settings. currencyUnit = node . Settings . currencyUnit ? node . S ettings. currencyUnit : 'USD' ;
this . common . nodes [ idx ] . settings. currencyUnit = node . settings . currencyUnit ? node . s ettings. currencyUnit : 'USD' ;
}
}
if ( process ? . env ? . SWAP _SERVER _URL && process ? . env ? . SWAP _SERVER _URL . trim ( ) !== '' ) {
if ( process ? . env ? . SWAP _SERVER _URL && process ? . env ? . SWAP _SERVER _URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . S ettings. swapServerUrl = process ? . env ? . SWAP _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . SWAP _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . SWAP _SERVER _URL ;
this . common . nodes [ idx ] . s ettings. swapServerUrl = process ? . env ? . SWAP _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . SWAP _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . SWAP _SERVER _URL ;
this . common . nodes [ idx ] . A uthentication. swapMacaroonPath = process ? . env ? . SWAP _MACAROON _PATH ;
this . common . nodes [ idx ] . a uthentication. swapMacaroonPath = process ? . env ? . SWAP _MACAROON _PATH ;
}
}
else if ( node . Settings. swapServerUrl && node . S ettings. swapServerUrl . trim ( ) !== '' ) {
else if ( node . settings. swapServerUrl && node . s ettings. swapServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . Settings. swapServerUrl = node . S ettings. swapServerUrl . endsWith ( '/v1' ) ? node . S ettings. swapServerUrl . slice ( 0 , - 3 ) : node . S ettings. swapServerUrl ;
this . common . nodes [ idx ] . settings. swapServerUrl = node . s ettings. swapServerUrl . endsWith ( '/v1' ) ? node . s ettings. swapServerUrl . slice ( 0 , - 3 ) : node . s ettings. swapServerUrl ;
this . common . nodes [ idx ] . Authentication. swapMacaroonPath = node . Authentication . swapMacaroonPath ? node . A uthentication. swapMacaroonPath : '' ;
this . common . nodes [ idx ] . authentication. swapMacaroonPath = node . authentication . swapMacaroonPath ? node . a uthentication. swapMacaroonPath : '' ;
}
}
else {
else {
this . common . nodes [ idx ] . S ettings. swapServerUrl = '' ;
this . common . nodes [ idx ] . s ettings. swapServerUrl = '' ;
this . common . nodes [ idx ] . A uthentication. swapMacaroonPath = '' ;
this . common . nodes [ idx ] . a uthentication. swapMacaroonPath = '' ;
}
}
if ( process ? . env ? . BOLTZ _SERVER _URL && process ? . env ? . BOLTZ _SERVER _URL . trim ( ) !== '' ) {
if ( process ? . env ? . BOLTZ _SERVER _URL && process ? . env ? . BOLTZ _SERVER _URL . trim ( ) !== '' ) {
this . common . nodes [ idx ] . S ettings. boltzServerUrl = process ? . env ? . BOLTZ _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . BOLTZ _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . BOLTZ _SERVER _URL ;
this . common . nodes [ idx ] . s ettings. boltzServerUrl = process ? . env ? . BOLTZ _SERVER _URL . endsWith ( '/v1' ) ? process ? . env ? . BOLTZ _SERVER _URL . slice ( 0 , - 3 ) : process ? . env ? . BOLTZ _SERVER _URL ;
this . common . nodes [ idx ] . A uthentication. boltzMacaroonPath = process ? . env ? . BOLTZ _MACAROON _PATH ;
this . common . nodes [ idx ] . a uthentication. boltzMacaroonPath = process ? . env ? . BOLTZ _MACAROON _PATH ;
}
}
else if ( node . Settings. boltzServerUrl && node . S ettings. boltzServerUrl . trim ( ) !== '' ) {
else if ( node . settings. boltzServerUrl && node . s ettings. boltzServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . Settings. boltzServerUrl = node . S ettings. boltzServerUrl . endsWith ( '/v1' ) ? node . S ettings. boltzServerUrl . slice ( 0 , - 3 ) : node . S ettings. boltzServerUrl ;
this . common . nodes [ idx ] . settings. boltzServerUrl = node . s ettings. boltzServerUrl . endsWith ( '/v1' ) ? node . s ettings. boltzServerUrl . slice ( 0 , - 3 ) : node . s ettings. boltzServerUrl ;
this . common . nodes [ idx ] . Authentication. boltzMacaroonPath = node . Authentication . boltzMacaroonPath ? node . A uthentication. boltzMacaroonPath : '' ;
this . common . nodes [ idx ] . authentication. boltzMacaroonPath = node . authentication . boltzMacaroonPath ? node . a uthentication. boltzMacaroonPath : '' ;
}
}
else {
else {
this . common . nodes [ idx ] . S ettings. boltzServerUrl = '' ;
this . common . nodes [ idx ] . s ettings. boltzServerUrl = '' ;
this . common . nodes [ idx ] . A uthentication. boltzMacaroonPath = '' ;
this . common . nodes [ idx ] . a uthentication. boltzMacaroonPath = '' ;
}
}
this . common . nodes [ idx ] . S ettings. enableOffers = process ? . env ? . ENABLE _OFFERS ? process ? . env ? . ENABLE _OFFERS : ( node . Settings. enableOffers ) ? node . S ettings. enableOffers : false ;
this . common . nodes [ idx ] . s ettings. enableOffers = process ? . env ? . ENABLE _OFFERS ? process ? . env ? . ENABLE _OFFERS : ( node . settings. enableOffers ) ? node . s ettings. enableOffers : false ;
this . common . nodes [ idx ] . S ettings. enablePeerswap = process ? . env ? . ENABLE _PEERSWAP ? process ? . env ? . ENABLE _PEERSWAP : ( node . Settings. enablePeerswap ) ? node . S ettings. enablePeerswap : false ;
this . common . nodes [ idx ] . s ettings. enablePeerswap = process ? . env ? . ENABLE _PEERSWAP ? process ? . env ? . ENABLE _PEERSWAP : ( node . settings. enablePeerswap ) ? node . s ettings. enablePeerswap : false ;
this . common . nodes [ idx ] . S ettings. bitcoindConfigPath = process ? . env ? . BITCOIND _CONFIG _PATH ? process ? . env ? . BITCOIND _CONFIG _PATH : ( node . Settings. bitcoindConfigPath ) ? node . S ettings. bitcoindConfigPath : '' ;
this . common . nodes [ idx ] . s ettings. bitcoindConfigPath = process ? . env ? . BITCOIND _CONFIG _PATH ? process ? . env ? . BITCOIND _CONFIG _PATH : ( node . settings. bitcoindConfigPath ) ? node . s ettings. bitcoindConfigPath : '' ;
this . common . nodes [ idx ] . S ettings. channelBackupPath = process ? . env ? . CHANNEL _BACKUP _PATH ? process ? . env ? . CHANNEL _BACKUP _PATH : ( node . Settings. channelBackupPath ) ? node . S ettings. channelBackupPath : this . common . appConfig . rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node . index ;
this . common . nodes [ idx ] . s ettings. channelBackupPath = process ? . env ? . CHANNEL _BACKUP _PATH ? process ? . env ? . CHANNEL _BACKUP _PATH : ( node . settings. channelBackupPath ) ? node . s ettings. channelBackupPath : this . common . appConfig . rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node . index ;
try {
try {
this . common . createDirectory ( this . common . nodes [ idx ] . S ettings. channelBackupPath ) ;
this . common . createDirectory ( this . common . nodes [ idx ] . s ettings. channelBackupPath ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . S ettings. channelBackupPath + sep + 'channel-all.bak' ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . s ettings. channelBackupPath + sep + 'channel-all.bak' ) ;
if ( ! exists ) {
if ( ! exists ) {
try {
try {
if ( this . common . nodes [ idx ] . lnImplementation === 'LND' ) {
if ( this . common . nodes [ idx ] . lnImplementation === 'LND' ) {
this . common . getAllNodeAllChannelBackup ( this . common . nodes [ idx ] ) ;
this . common . getAllNodeAllChannelBackup ( this . common . nodes [ idx ] ) ;
}
}
else {
else {
const createStream = fs . createWriteStream ( this . common . nodes [ idx ] . S ettings. channelBackupPath + sep + 'channel-all.bak' ) ;
const createStream = fs . createWriteStream ( this . common . nodes [ idx ] . s ettings. channelBackupPath + sep + 'channel-all.bak' ) ;
createStream . end ( ) ;
createStream . end ( ) ;
}
}
}
}
@ -290,9 +290,9 @@ export class ConfigService {
catch ( err ) {
catch ( err ) {
this . logger . log ( { selectedNode : this . common . selectedNode , level : 'ERROR' , fileName : 'Config' , msg : 'Something went wrong while creating the backup directory: \n' + err } ) ;
this . logger . log ( { selectedNode : this . common . selectedNode , level : 'ERROR' , fileName : 'Config' , msg : 'Something went wrong while creating the backup directory: \n' + err } ) ;
}
}
this . common . nodes [ idx ] . S ettings. logFile = config . rtlConfFilePath + '/logs/RTL-Node-' + node . index + '.log' ;
this . common . nodes [ idx ] . s ettings. logFile = config . rtlConfFilePath + '/logs/RTL-Node-' + node . index + '.log' ;
this . logger . log ( { selectedNode : this . common . selectedNode , level : 'INFO' , fileName : 'Config' , msg : 'Node Config: ' + JSON . stringify ( this . common . nodes [ idx ] ) } ) ;
this . logger . log ( { selectedNode : this . common . selectedNode , level : 'INFO' , fileName : 'Config' , msg : 'Node Config: ' + JSON . stringify ( this . common . nodes [ idx ] ) } ) ;
const log _file = this . common . nodes [ idx ] . S ettings. logFile ;
const log _file = this . common . nodes [ idx ] . s ettings. logFile ;
if ( fs . existsSync ( log _file || '' ) ) {
if ( fs . existsSync ( log _file || '' ) ) {
fs . writeFile ( ( log _file || '' ) , '' , ( ) => { } ) ;
fs . writeFile ( ( log _file || '' ) , '' , ( ) => { } ) ;
}
}
@ -353,14 +353,34 @@ export class ConfigService {
this . common . selectedNode = this . common . findNode ( this . common . nodes [ 0 ] . index ) || { } ;
this . common . selectedNode = this . common . findNode ( this . common . nodes [ 0 ] . index ) || { } ;
}
}
} ;
} ;
this . updateConfig = ( confFileFullPath , config ) => {
// Update Config file to change Settings to settings and Authentication to authentication
// Added in v0.15.1, remove in a year?
if ( ! config . nodes || config . nodes [ 0 ] . settings ) {
return ;
}
config . nodes . map ( ( node ) => {
if ( node . Authentication ) {
node . authentication = JSON . parse ( JSON . stringify ( node . Authentication ) ) ;
delete node . Authentication ;
}
if ( node . Settings ) {
node . settings = JSON . parse ( JSON . stringify ( node . Settings ) ) ;
delete node . Settings ;
}
return node ;
} ) ;
fs . writeFileSync ( confFileFullPath , JSON . stringify ( config , null , 2 ) , 'utf-8' ) ;
} ;
this . setServerConfiguration = ( ) => {
this . setServerConfiguration = ( ) => {
try {
try {
const rtlConfFilePath = ( process ? . env ? . RTL _CONFIG _PATH ) ? process ? . env ? . RTL _CONFIG _PATH : join ( this . directoryName , '../..' ) ;
const rtlConfFilePath = ( process ? . env ? . RTL _CONFIG _PATH ) ? process ? . env ? . RTL _CONFIG _PATH : join ( this . directoryName , '../..' ) ;
const confFileFullPath = rtlConfFilePath + sep + 'RTL-Config.json' ;
const confFileFullPath = rtlConfFilePath + sep + 'RTL-Config.json' ;
if ( ! fs . existsSync ( confFileFullPath ) ) {
if ( ! fs . existsSync ( confFileFullPath ) ) {
fs . writeFileSync ( confFileFullPath , JSON . stringify ( this . setDefaultConfig ( ) ) ) ;
fs . writeFileSync ( confFileFullPath , JSON . stringify ( this . setDefaultConfig ( ) , null , 2 ), 'utf-8' ) ;
}
}
const config = JSON . parse ( fs . readFileSync ( confFileFullPath , 'utf-8' ) ) ;
const config = JSON . parse ( fs . readFileSync ( confFileFullPath , 'utf-8' ) ) ;
this . updateConfig ( confFileFullPath , config ) ;
config . rtlConfFilePath = rtlConfFilePath ;
config . rtlConfFilePath = rtlConfFilePath ;
this . updateLogByLevel ( ) ;
this . updateLogByLevel ( ) ;
this . validateNodeConfig ( config ) ;
this . validateNodeConfig ( config ) ;