@ -142,7 +142,7 @@ export class ConfigService {
this . common . appConfig . 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 ) {
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 ] . lnNode = node . lnNode ;
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 ) {
case 'CLN' :
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 . Authentication . runePath . trim ( ) !== '' ) {
this . common . nodes [ idx ] . a uthentication. runePath = node . Authentication . runePath ;
this . common . nodes [ idx ] . A uthentication. runePath = node . Authentication . runePath ;
}
else {
this . errMsg = 'Please set rune path for node index ' + node . index + ' in RTL-Config.json!' ;
@ -163,21 +163,21 @@ export class ConfigService {
break ;
case 'ECL' :
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 . Authentication . lnApiPassword ) {
this . common . nodes [ idx ] . a uthentication. lnApiPassword = node . Authentication . lnApiPassword ;
this . common . nodes [ idx ] . A uthentication. lnApiPassword = node . Authentication . lnApiPassword ;
}
else {
this . common . nodes [ idx ] . a uthentication. lnApiPassword = '' ;
this . common . nodes [ idx ] . A uthentication. lnApiPassword = '' ;
}
break ;
default :
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 . Authentication . macaroonPath . trim ( ) !== '' ) {
this . common . nodes [ idx ] . a uthentication. macaroonPath = node . Authentication . macaroonPath ;
this . common . nodes [ idx ] . A uthentication. macaroonPath = node . Authentication . macaroonPath ;
}
else {
this . errMsg = 'Please set macaroon path for node index ' + node . index + ' in RTL-Config.json!' ;
@ -185,100 +185,100 @@ export class ConfigService {
break ;
}
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 . Authentication . configPath ) {
this . common . nodes [ idx ] . a uthentication. configPath = node . Authentication . configPath ;
this . common . nodes [ idx ] . A uthentication. configPath = node . Authentication . configPath ;
}
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 {
const exists = fs . existsSync ( this . common . nodes [ idx ] . a uthentication. configPath || '' ) ;
const exists = fs . existsSync ( this . common . nodes [ idx ] . A uthentication. configPath || '' ) ;
if ( exists ) {
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 ) ;
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 ) {
this . errMsg = this . errMsg + '\nSomething went wrong while reading config file: \n' + err ;
}
}
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 ) {
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!' ;
}
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 ( ) !== '' ) {
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 . Settings . lnServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . s ettings. lnServerUrl = node . Settings . lnServerUrl . endsWith ( '/v1' ) ? node . Settings . lnServerUrl . slice ( 0 , - 3 ) : node . Settings . lnServerUrl ;
this . common . nodes [ idx ] . S ettings. lnServerUrl = node . Settings . lnServerUrl . endsWith ( '/v1' ) ? node . Settings . lnServerUrl . slice ( 0 , - 3 ) : node . Settings . lnServerUrl ;
}
else if ( node . Settings . lndServerUrl && node . Settings . lndServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . s ettings. lnServerUrl = node . Settings . lndServerUrl . endsWith ( '/v1' ) ? node . Settings . lndServerUrl . slice ( 0 , - 3 ) : node . Settings . lndServerUrl ;
this . common . nodes [ idx ] . S ettings. lnServerUrl = node . Settings . lndServerUrl . endsWith ( '/v1' ) ? node . Settings . lndServerUrl . slice ( 0 , - 3 ) : node . Settings . lndServerUrl ;
}
else {
this . errMsg = this . errMsg + '\nPlease set LN Server URL for node index ' + node . index + ' in RTL-Config.json!' ;
}
this . common . nodes [ idx ] . s ettings. userPersona = node . Settings . userPersona ? node . Settings . userPersona : 'MERCHANT' ;
this . common . nodes [ idx ] . s ettings. themeMode = node . Settings . themeMode ? node . Settings . themeMode : 'DAY' ;
this . common . nodes [ idx ] . s ettings. themeColor = node . Settings . themeColor ? node . Settings . themeColor : 'PURPLE' ;
this . common . nodes [ idx ] . s ettings. unannouncedChannels = node . Settings . unannouncedChannels ? ! ! node . Settings . unannouncedChannels : false ;
this . common . nodes [ idx ] . s ettings. logLevel = node . Settings . logLevel ? node . Settings . logLevel : 'ERROR' ;
this . common . nodes [ idx ] . s ettings. fiatConversion = node . Settings . fiatConversion ? ! ! node . Settings . fiatConversion : false ;
if ( this . common . nodes [ idx ] . s ettings. fiatConversion ) {
this . common . nodes [ idx ] . s ettings. currencyUnit = node . Settings . currencyUnit ? node . Settings . currencyUnit : 'USD' ;
this . common . nodes [ idx ] . S ettings. userPersona = node . Settings . userPersona ? node . Settings . userPersona : 'MERCHANT' ;
this . common . nodes [ idx ] . S ettings. themeMode = node . Settings . themeMode ? node . Settings . themeMode : 'DAY' ;
this . common . nodes [ idx ] . S ettings. themeColor = node . Settings . themeColor ? node . Settings . themeColor : 'PURPLE' ;
this . common . nodes [ idx ] . S ettings. unannouncedChannels = node . Settings . unannouncedChannels ? ! ! node . Settings . unannouncedChannels : false ;
this . common . nodes [ idx ] . S ettings. logLevel = node . Settings . logLevel ? node . Settings . logLevel : 'ERROR' ;
this . common . nodes [ idx ] . S ettings. fiatConversion = node . Settings . fiatConversion ? ! ! node . Settings . fiatConversion : false ;
if ( this . common . nodes [ idx ] . S ettings. fiatConversion ) {
this . common . nodes [ idx ] . S ettings. currencyUnit = node . Settings . currencyUnit ? node . Settings . currencyUnit : 'USD' ;
}
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 ] . a uthentication. swapMacaroonPath = process ? . env ? . SWAP _MACAROON _PATH ;
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 ;
}
else if ( node . Settings . swapServerUrl && node . Settings . swapServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . s ettings. swapServerUrl = node . Settings . swapServerUrl . endsWith ( '/v1' ) ? node . Settings . swapServerUrl . slice ( 0 , - 3 ) : node . Settings . swapServerUrl ;
this . common . nodes [ idx ] . a uthentication. swapMacaroonPath = node . Authentication . swapMacaroonPath ? node . Authentication . swapMacaroonPath : '' ;
this . common . nodes [ idx ] . S ettings. swapServerUrl = node . Settings . swapServerUrl . endsWith ( '/v1' ) ? node . Settings . swapServerUrl . slice ( 0 , - 3 ) : node . Settings . swapServerUrl ;
this . common . nodes [ idx ] . A uthentication. swapMacaroonPath = node . Authentication . swapMacaroonPath ? node . Authentication . swapMacaroonPath : '' ;
}
else {
this . common . nodes [ idx ] . s ettings. swapServerUrl = '' ;
this . common . nodes [ idx ] . a uthentication. swapMacaroonPath = '' ;
this . common . nodes [ idx ] . S ettings. swapServerUrl = '' ;
this . common . nodes [ idx ] . A uthentication. swapMacaroonPath = '' ;
}
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 ] . a uthentication. boltzMacaroonPath = process ? . env ? . BOLTZ _MACAROON _PATH ;
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 ;
}
else if ( node . Settings . boltzServerUrl && node . Settings . boltzServerUrl . trim ( ) !== '' ) {
this . common . nodes [ idx ] . s ettings. boltzServerUrl = node . Settings . boltzServerUrl . endsWith ( '/v1' ) ? node . Settings . boltzServerUrl . slice ( 0 , - 3 ) : node . Settings . boltzServerUrl ;
this . common . nodes [ idx ] . a uthentication. boltzMacaroonPath = node . Authentication . boltzMacaroonPath ? node . Authentication . boltzMacaroonPath : '' ;
this . common . nodes [ idx ] . S ettings. boltzServerUrl = node . Settings . boltzServerUrl . endsWith ( '/v1' ) ? node . Settings . boltzServerUrl . slice ( 0 , - 3 ) : node . Settings . boltzServerUrl ;
this . common . nodes [ idx ] . A uthentication. boltzMacaroonPath = node . Authentication . boltzMacaroonPath ? node . Authentication . boltzMacaroonPath : '' ;
}
else {
this . common . nodes [ idx ] . s ettings. boltzServerUrl = '' ;
this . common . nodes [ idx ] . a uthentication. boltzMacaroonPath = '' ;
this . common . nodes [ idx ] . S ettings. boltzServerUrl = '' ;
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 . Settings . enableOffers : false ;
this . common . nodes [ idx ] . s ettings. enablePeerswap = process ? . env ? . ENABLE _PEERSWAP ? process ? . env ? . ENABLE _PEERSWAP : ( node . Settings . enablePeerswap ) ? node . Settings . enablePeerswap : false ;
this . common . nodes [ idx ] . s ettings. bitcoindConfigPath = process ? . env ? . BITCOIND _CONFIG _PATH ? process ? . env ? . BITCOIND _CONFIG _PATH : ( node . Settings . bitcoindConfigPath ) ? node . Settings . bitcoindConfigPath : '' ;
this . common . nodes [ idx ] . s ettings. channelBackupPath = process ? . env ? . CHANNEL _BACKUP _PATH ? process ? . env ? . CHANNEL _BACKUP _PATH : ( node . Settings . channelBackupPath ) ? node . Settings . channelBackupPath : this . common . appConfig . rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node . index ;
this . common . nodes [ idx ] . S ettings. enableOffers = process ? . env ? . ENABLE _OFFERS ? process ? . env ? . ENABLE _OFFERS : ( node . Settings . enableOffers ) ? node . Settings . enableOffers : false ;
this . common . nodes [ idx ] . S ettings. enablePeerswap = process ? . env ? . ENABLE _PEERSWAP ? process ? . env ? . ENABLE _PEERSWAP : ( node . Settings . enablePeerswap ) ? node . Settings . enablePeerswap : false ;
this . common . nodes [ idx ] . S ettings. bitcoindConfigPath = process ? . env ? . BITCOIND _CONFIG _PATH ? process ? . env ? . BITCOIND _CONFIG _PATH : ( node . Settings . bitcoindConfigPath ) ? node . Settings . bitcoindConfigPath : '' ;
this . common . nodes [ idx ] . S ettings. channelBackupPath = process ? . env ? . CHANNEL _BACKUP _PATH ? process ? . env ? . CHANNEL _BACKUP _PATH : ( node . Settings . channelBackupPath ) ? node . Settings . channelBackupPath : this . common . appConfig . rtlConfFilePath + sep + 'channels-backup' + sep + 'node-' + node . index ;
try {
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' ) ;
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' ) ;
if ( ! exists ) {
try {
if ( this . common . nodes [ idx ] . lnImplementation === 'LND' ) {
this . common . getAllNodeAllChannelBackup ( this . common . nodes [ idx ] ) ;
}
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 ( ) ;
}
}
@ -290,9 +290,9 @@ export class ConfigService {
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 . common . nodes [ idx ] . s ettings. logFile = this . common . appConfig . rtlConfFilePath + '/logs/RTL-Node-' + node . index + '.log' ;
this . common . nodes [ idx ] . S ettings. logFile = this . common . appConfig . 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 ] ) } ) ;
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 || '' ) ) {
fs . writeFile ( ( log _file || '' ) , '' , ( ) => { } ) ;
}