From f67fedce2e9a93f262d2d05e9b6ab12489eca2da Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Mon, 22 Apr 2024 19:12:56 -0700 Subject: [PATCH] Unified config models --- backend/controllers/shared/RTLConf.js | 35 +++++++++--- backend/models/config.model.js | 45 +++++++-------- server/controllers/shared/RTLConf.ts | 36 +++++++++--- server/models/config.model.ts | 57 +++++++++---------- src/app/app.component.html | 4 +- src/app/app.component.ts | 6 +- .../side-navigation.component.html | 2 +- .../side-navigation.component.ts | 18 +++--- .../node-config/node-config.component.ts | 2 +- .../node-settings/node-settings.component.ts | 8 +-- .../boltz-service-settings.component.ts | 6 +- .../loop-service-settings.component.html | 4 +- .../loop-service-settings.component.ts | 6 +- .../services-settings.component.html | 10 ++-- .../services-settings.component.ts | 2 +- .../components/settings/settings.component.ts | 2 +- src/app/shared/models/RTLconfig.ts | 24 ++++---- src/app/store/rtl.effects.ts | 10 ++-- src/app/store/rtl.state.ts | 2 +- 19 files changed, 159 insertions(+), 120 deletions(-) diff --git a/backend/controllers/shared/RTLConf.js b/backend/controllers/shared/RTLConf.js index eddf5a6a..94656bec 100644 --- a/backend/controllers/shared/RTLConf.js +++ b/backend/controllers/shared/RTLConf.js @@ -8,7 +8,7 @@ import { Database } from '../../utils/database.js'; import { Logger } from '../../utils/logger.js'; import { Common } from '../../utils/common.js'; import { WSServer } from '../../utils/webSocketServer.js'; -import { NodeAuthentication, SSO } from '../../models/config.model.js'; +import { Authentication, SSO } from '../../models/config.model.js'; const options = { url: '' }; const logger = Logger; const common = Common; @@ -32,7 +32,7 @@ export const maskPasswords = (obj) => { } return obj; }; -export const removeSensitiveData = (config) => { +export const removeSecureData = (config) => { delete config.rtlConfFilePath; delete config.rtlPass; delete config.multiPass; @@ -46,6 +46,26 @@ export const removeSensitiveData = (config) => { }); return config; }; +export const addSecureData = (config) => { + config.SSO.rtlCookiePath = common.appConfig.SSO.rtlCookiePath; + config.rtlPass = common.appConfig.rtlPass; + config.multiPass = common.appConfig.multiPass; + config.multiPassHashed = common.appConfig.multiPassHashed; + config.secret2FA = common.appConfig.secret2FA; + config.nodes.map((node, i) => { + if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.macaroonPath) { + node.Authentication.macaroonPath = common.appConfig.nodes[i].Authentication.macaroonPath; + } + if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.runePath) { + node.Authentication.runePath = common.appConfig.nodes[i].Authentication.runePath; + } + if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.lnApiPassword) { + node.Authentication.lnApiPassword = common.appConfig.nodes[i].Authentication.lnApiPassword; + } + return node; + }); + return config; +}; export const getCurrencyRates = (req, res, next) => { logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting Currency Rates..' }); options.url = 'https://blockchain.info/ticker'; @@ -88,7 +108,7 @@ export const getApplicationSettings = (req, res, next) => { return res.status(err.statusCode).json({ message: err.error, error: err.error }); } else { - const appConfData = removeSensitiveData(JSON.parse(data)); + const appConfData = removeSecureData(JSON.parse(data)); appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate; appConfData.enable2FA = common.appConfig.enable2FA; appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index); @@ -100,7 +120,7 @@ export const getApplicationSettings = (req, res, next) => { appConfData.SSO = new SSO(); appConfData.secret2FA = ''; appConfData.dbDirectoryPath = ''; - appConfData.nodes[selNodeIdx].Authentication = new NodeAuthentication(); + appConfData.nodes[selNodeIdx].Authentication = new Authentication(); delete appConfData.nodes[selNodeIdx].Settings.bitcoindConfigPath; delete appConfData.nodes[selNodeIdx].Settings.lnServerUrl; delete appConfData.nodes[selNodeIdx].Settings.swapServerUrl; @@ -212,10 +232,11 @@ export const updateApplicationSettings = (req, res, next) => { logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Application Settings..' }); const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json'; try { - fs.writeFileSync(RTLConfFile, JSON.stringify(req.body, null, 2), 'utf-8'); - common.appConfig = req.body; + const config = addSecureData(req.body); + fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8'); + common.appConfig = config; logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Application Settings Updated', data: maskPasswords(common.appConfig) }); - res.status(201).json(removeSensitiveData(common.appConfig)); + res.status(201).json(removeSecureData(config)); } catch (errRes) { const errMsg = 'Update Default Node Error'; diff --git a/backend/models/config.model.js b/backend/models/config.model.js index eb1b2319..8a3f8a46 100644 --- a/backend/models/config.model.js +++ b/backend/models/config.model.js @@ -1,4 +1,12 @@ -export class NodeSettings { +export class SSO { + constructor(rtlSso, rtlCookiePath, logoutRedirectLink, cookieValue) { + this.rtlSso = rtlSso; + this.rtlCookiePath = rtlCookiePath; + this.logoutRedirectLink = logoutRedirectLink; + this.cookieValue = cookieValue; + } +} +export class Settings { constructor(lnServerUrl, swapServerUrl, boltzServerUrl, bitcoindConfigPath, channelBackupPath, logLevel, logFile, userPersona, themeMode, themeColor, unannouncedChannels, fiatConversion, currencyUnit, enableOffers, enablePeerswap) { this.lnServerUrl = lnServerUrl; this.swapServerUrl = swapServerUrl; @@ -17,7 +25,7 @@ export class NodeSettings { this.enablePeerswap = enablePeerswap; } } -export class NodeAuthentication { +export class Authentication { constructor(options, configPath, macaroonPath, macaroonValue, runePath, runeValue, lnApiPassword, swapMacaroonPath, boltzMacaroonPath) { this.options = options; this.configPath = configPath; @@ -30,27 +38,6 @@ export class NodeAuthentication { this.boltzMacaroonPath = boltzMacaroonPath; } } -export class SelectedNode { - constructor(logLevel, logFile, index, lnNode, lnImplementation, lnVersion, apiVersion, Settings, Authentication) { - this.logLevel = logLevel; - this.logFile = logFile; - this.index = index; - this.lnNode = lnNode; - this.lnImplementation = lnImplementation; - this.lnVersion = lnVersion; - this.apiVersion = apiVersion; - this.Settings = Settings; - this.Authentication = Authentication; - } -} -export class SSO { - constructor(rtlSso, rtlCookiePath, logoutRedirectLink, cookieValue) { - this.rtlSso = rtlSso; - this.rtlCookiePath = rtlCookiePath; - this.logoutRedirectLink = logoutRedirectLink; - this.cookieValue = cookieValue; - } -} export class ApplicationConfig { constructor(defaultNodeIndex, selectedNodeIndex, dbDirectoryPath, rtlConfFilePath, rtlPass, multiPass, multiPassHashed, allowPasswordUpdate, enable2FA, secret2FA, SSO, nodes) { this.defaultNodeIndex = defaultNodeIndex; @@ -67,6 +54,18 @@ export class ApplicationConfig { this.nodes = nodes; } } +export class SelectedNode { + constructor(logLevel, logFile, index, lnNode, lnImplementation, lnVersion, Settings, Authentication) { + this.logLevel = logLevel; + this.logFile = logFile; + this.index = index; + this.lnNode = lnNode; + this.lnImplementation = lnImplementation; + this.lnVersion = lnVersion; + this.Settings = Settings; + this.Authentication = Authentication; + } +} export class LogJSONObj { constructor(level, msg, data, error, fileName, selectedNode) { this.level = level; diff --git a/server/controllers/shared/RTLConf.ts b/server/controllers/shared/RTLConf.ts index 7d423d78..c000ede9 100644 --- a/server/controllers/shared/RTLConf.ts +++ b/server/controllers/shared/RTLConf.ts @@ -8,7 +8,7 @@ import { Database, DatabaseService } from '../../utils/database.js'; import { Logger, LoggerService } from '../../utils/logger.js'; import { Common, CommonService } from '../../utils/common.js'; import { WSServer } from '../../utils/webSocketServer.js'; -import { ApplicationConfig, NodeAuthentication, SSO } from '../../models/config.model.js'; +import { ApplicationConfig, Authentication, SSO } from '../../models/config.model.js'; const options = { url: '' }; const logger: LoggerService = Logger; @@ -36,7 +36,7 @@ export const maskPasswords = (obj) => { return obj; }; -export const removeSensitiveData = (config: ApplicationConfig) => { +export const removeSecureData = (config: ApplicationConfig) => { delete config.rtlConfFilePath; delete config.rtlPass; delete config.multiPass; @@ -51,6 +51,27 @@ export const removeSensitiveData = (config: ApplicationConfig) => { return config; }; +export const addSecureData = (config: ApplicationConfig) => { + config.SSO.rtlCookiePath = common.appConfig.SSO.rtlCookiePath; + config.rtlPass = common.appConfig.rtlPass; + config.multiPass = common.appConfig.multiPass; + config.multiPassHashed = common.appConfig.multiPassHashed; + config.secret2FA = common.appConfig.secret2FA; + config.nodes.map((node, i) => { + if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.macaroonPath) { + node.Authentication.macaroonPath = common.appConfig.nodes[i].Authentication.macaroonPath; + } + if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.runePath) { + node.Authentication.runePath = common.appConfig.nodes[i].Authentication.runePath; + } + if (common.appConfig && common.appConfig.nodes && common.appConfig.nodes.length > i && common.appConfig.nodes[i].Authentication && common.appConfig.nodes[i].Authentication.lnApiPassword) { + node.Authentication.lnApiPassword = common.appConfig.nodes[i].Authentication.lnApiPassword; + } + return node; + }); + return config; +}; + export const getCurrencyRates = (req, res, next) => { logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Getting Currency Rates..' }); options.url = 'https://blockchain.info/ticker'; @@ -91,7 +112,7 @@ export const getApplicationSettings = (req, res, next) => { const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode); return res.status(err.statusCode).json({ message: err.error, error: err.error }); } else { - const appConfData = removeSensitiveData(JSON.parse(data)); + const appConfData = removeSecureData(JSON.parse(data)); appConfData.allowPasswordUpdate = common.appConfig.allowPasswordUpdate; appConfData.enable2FA = common.appConfig.enable2FA; appConfData.selectedNodeIndex = (req.session.selectedNode && req.session.selectedNode.index ? req.session.selectedNode.index : common.selectedNode.index); @@ -103,7 +124,7 @@ export const getApplicationSettings = (req, res, next) => { appConfData.SSO = new SSO(); appConfData.secret2FA = ''; appConfData.dbDirectoryPath = ''; - appConfData.nodes[selNodeIdx].Authentication = new NodeAuthentication(); + appConfData.nodes[selNodeIdx].Authentication = new Authentication(); delete appConfData.nodes[selNodeIdx].Settings.bitcoindConfigPath; delete appConfData.nodes[selNodeIdx].Settings.lnServerUrl; delete appConfData.nodes[selNodeIdx].Settings.swapServerUrl; @@ -216,10 +237,11 @@ export const updateApplicationSettings = (req, res, next) => { logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Updating Application Settings..' }); const RTLConfFile = common.appConfig.rtlConfFilePath + sep + 'RTL-Config.json'; try { - fs.writeFileSync(RTLConfFile, JSON.stringify(req.body, null, 2), 'utf-8'); - common.appConfig = req.body; + const config = addSecureData(req.body); + fs.writeFileSync(RTLConfFile, JSON.stringify(config, null, 2), 'utf-8'); + common.appConfig = config; logger.log({ selectedNode: req.session.selectedNode, level: 'INFO', fileName: 'RTLConf', msg: 'Application Settings Updated', data: maskPasswords(common.appConfig) }); - res.status(201).json(removeSensitiveData(common.appConfig)); + res.status(201).json(removeSecureData(config)); } catch (errRes) { const errMsg = 'Update Default Node Error'; const err = common.handleError({ statusCode: 500, message: errMsg, error: errRes }, 'RTLConf', errMsg, req.session.selectedNode); diff --git a/server/models/config.model.ts b/server/models/config.model.ts index 501f54e2..2207301c 100644 --- a/server/models/config.model.ts +++ b/server/models/config.model.ts @@ -1,4 +1,15 @@ -export class NodeSettings { +export class SSO { + + constructor( + public rtlSso?: number, + public rtlCookiePath?: string, + public logoutRedirectLink?: string, + public cookieValue?: string + ) { } + +} + +export class Settings { constructor( public lnServerUrl?: string, @@ -20,7 +31,7 @@ export class NodeSettings { } -export class NodeAuthentication { +export class Authentication { constructor( public options?: any, @@ -36,33 +47,6 @@ export class NodeAuthentication { } -export class SelectedNode { - - constructor( - public logLevel?: string, - public logFile?: string, - public index?: number, - public lnNode?: string, - public lnImplementation?: string, - public lnVersion?: string, - public apiVersion?: string, - public Settings?: NodeSettings, - public Authentication?: NodeAuthentication - ) { } - -} - -export class SSO { - - constructor( - public rtlSso?: number, - public rtlCookiePath?: string, - public logoutRedirectLink?: string, - public cookieValue?: string - ) { } - -} - export class ApplicationConfig { constructor( @@ -82,6 +66,21 @@ export class ApplicationConfig { } +export class SelectedNode { + + constructor( + public logLevel?: string, + public logFile?: string, + public index?: number, + public lnNode?: string, + public lnImplementation?: string, + public lnVersion?: string, + public Settings?: Settings, + public Authentication?: Authentication + ) { } + +} + export class LogJSONObj { constructor( diff --git a/src/app/app.component.html b/src/app/app.component.html index 2b857179..ccb645d4 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,4 +1,4 @@ -
+
-
+

Loading RTL...

diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c5bfc3d8..f8636d9c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -14,7 +14,7 @@ import { CommonService } from './shared/services/common.service'; import { SessionService } from './shared/services/session.service'; import { AlertTypeEnum, RTLActions, ScreenSizeEnum } from './shared/services/consts-enums-functions'; import { rootAppConfig, rootNodeData, rootSelectedNode } from './store/rtl.selector'; -import { RTLConfiguration, Settings, GetInfoRoot } from './shared/models/RTLconfig'; +import { RTLConfiguration, GetInfoRoot } from './shared/models/RTLconfig'; import { closeAllDialogs, fetchRTLConfig, login, logout, openAlert } from './store/rtl.actions'; import { routeAnimation } from './shared/animation/route-animation'; @@ -30,11 +30,11 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild('sideNavigation', { static: false }) sideNavigation: any; @ViewChild('sideNavContent', { static: false }) sideNavContent: any; - public settings: Settings; public information: GetInfoRoot = {}; public flgLoading: Array = [true]; // 0: Info public flgSideNavOpened = true; public flgCopied = false; + public selNode: Node | any; public appConfig: RTLConfiguration; public accessKey = ''; public xSmallScreen = false; @@ -78,7 +78,6 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { this.store.dispatch(fetchRTLConfig()); this.accessKey = this.readAccessKey() || ''; this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[1])).subscribe((selNode) => { - this.settings = selNode.settings; if (!this.sessionService.getItem('token')) { this.flgLoggedIn = false; this.flgLoading[0] = false; @@ -86,6 +85,7 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy { this.flgLoggedIn = true; this.userIdle.startWatching(); } + this.selNode = selNode; }); this.store.select(rootAppConfig).pipe(takeUntil(this.unSubs[2])).subscribe((appConfig) => { this.appConfig = appConfig; }); this.store.select(rootNodeData).pipe(takeUntil(this.unSubs[3])).subscribe((nodeData) => { diff --git a/src/app/shared/components/navigation/side-navigation/side-navigation.component.html b/src/app/shared/components/navigation/side-navigation/side-navigation.component.html index 3f59dff6..2ae9250d 100644 --- a/src/app/shared/components/navigation/side-navigation/side-navigation.component.html +++ b/src/app/shared/components/navigation/side-navigation/side-navigation.component.html @@ -8,7 +8,7 @@ - +
diff --git a/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts b/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts index cd09e017..a8b9e351 100644 --- a/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts +++ b/src/app/shared/components/navigation/side-navigation/side-navigation.component.ts @@ -35,7 +35,6 @@ export class SideNavigationComponent implements OnInit, OnDestroy { public appConfig: RTLConfiguration; public selConfigNodeIndex: Number; public selNode: Node | any; - public settings: Settings | null; public version = ''; public information: GetInfoRoot = {}; public informationChain: GetInfoChain = {}; @@ -93,7 +92,6 @@ export class SideNavigationComponent implements OnInit, OnDestroy { this.smallScreen = true; } this.selNode = rootData.selNode; - this.settings = this.selNode?.settings || null; this.selConfigNodeIndex = +(rootData.selNode?.index || 0); if (this.selNode && this.selNode.lnImplementation) { this.filterSideMenuNodes(); @@ -162,12 +160,12 @@ export class SideNavigationComponent implements OnInit, OnDestroy { clonedMenu = JSON.parse(JSON.stringify(MENU_DATA.LNDChildren)); this.navMenus.data = clonedMenu?.filter((navMenuData: any) => { if (navMenuData.children && navMenuData.children.length) { - navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.settings?.userPersona) && navMenuChild.link !== '/services/loop' && navMenuChild.link !== '/services/boltz') || - (navMenuChild.link === '/services/loop' && this.settings?.swapServerUrl && this.settings.swapServerUrl.trim() !== '') || - (navMenuChild.link === '/services/boltz' && this.settings?.boltzServerUrl && this.settings.boltzServerUrl.trim() !== '')); + navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.selNode.Settings.userPersona) && navMenuChild.link !== '/services/loop' && navMenuChild.link !== '/services/boltz') || + (navMenuChild.link === '/services/loop' && this.selNode.Settings.swapServerUrl && this.selNode.Settings.swapServerUrl.trim() !== '') || + (navMenuChild.link === '/services/boltz' && this.selNode.Settings.boltzServerUrl && this.selNode.Settings.boltzServerUrl.trim() !== '')); return navMenuData.children.length > 0; } - return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.settings?.userPersona; + return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.selNode.Settings.userPersona; }); } @@ -176,12 +174,12 @@ export class SideNavigationComponent implements OnInit, OnDestroy { clonedMenu = JSON.parse(JSON.stringify(MENU_DATA.CLNChildren)); this.navMenus.data = clonedMenu?.filter((navMenuData: any) => { if (navMenuData.children && navMenuData.children.length) { - navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.settings?.userPersona) && navMenuChild.link !== '/services/peerswap') || - (navMenuChild.link === '/services/peerswap' && this.settings?.enablePeerswap) || - (navMenuChild.link === '/services/boltz' && this.settings?.boltzServerUrl && this.settings.boltzServerUrl.trim() !== '')); + navMenuData.children = navMenuData.children?.filter((navMenuChild) => ((navMenuChild.userPersona === UserPersonaEnum.ALL || navMenuChild.userPersona === this.selNode.Settings.userPersona) && navMenuChild.link !== '/services/peerswap') || + (navMenuChild.link === '/services/peerswap' && this.selNode.Settings.enablePeerswap) || + (navMenuChild.link === '/services/boltz' && this.selNode.Settings.boltzServerUrl && this.selNode.Settings.boltzServerUrl.trim() !== '')); return navMenuData.children.length > 0; } - return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.settings?.userPersona; + return navMenuData.userPersona === UserPersonaEnum.ALL || navMenuData.userPersona === this.selNode.Settings.userPersona; }); } diff --git a/src/app/shared/components/node-config/node-config.component.ts b/src/app/shared/components/node-config/node-config.component.ts index c676371a..0e0848d8 100644 --- a/src/app/shared/components/node-config/node-config.component.ts +++ b/src/app/shared/components/node-config/node-config.component.ts @@ -59,7 +59,7 @@ export class NodeConfigComponent implements OnInit, OnDestroy { this.lnImplementationStr = 'LND Config'; break; } - if (this.selNode.authentication && this.selNode.authentication.configPath && this.selNode.authentication.configPath.trim() !== '') { + if (this.selNode.Authentication && this.selNode.Authentication.configPath && this.selNode.Authentication.configPath.trim() !== '') { this.links[4].name = this.lnImplementationStr; this.showLnConfig = true; } diff --git a/src/app/shared/components/node-config/node-settings/node-settings.component.ts b/src/app/shared/components/node-config/node-settings/node-settings.component.ts index 67452fc2..e897a4e7 100644 --- a/src/app/shared/components/node-config/node-settings/node-settings.component.ts +++ b/src/app/shared/components/node-config/node-settings/node-settings.component.ts @@ -54,7 +54,7 @@ export class NodeSettingsComponent implements OnInit, OnDestroy { if (!this.selNode.Settings.fiatConversion) { this.selNode.Settings.currencyUnit = ''; } - this.previousSettings = JSON.parse(JSON.stringify(this.selNode.settings)); + this.previousSettings = JSON.parse(JSON.stringify(this.selNode.Settings)); this.logger.info(selNode); }); } @@ -85,7 +85,7 @@ export class NodeSettingsComponent implements OnInit, OnDestroy { } toggleSettings(toggleField: string, event?: any) { - this.selNode.settings[toggleField] = !this.selNode.settings[toggleField]; + this.selNode.Settings[toggleField] = !this.selNode.Settings[toggleField]; } changeThemeColor(newThemeColor: string) { @@ -101,7 +101,7 @@ export class NodeSettingsComponent implements OnInit, OnDestroy { if (this.selNode.Settings.fiatConversion && !this.selNode.Settings.currencyUnit) { return true; } - this.logger.info(this.selNode.settings); + this.logger.info(this.selNode.Settings); this.store.dispatch(setChildNodeSettingsLND({ payload: { userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, @@ -130,7 +130,7 @@ export class NodeSettingsComponent implements OnInit, OnDestroy { onResetSettings() { const prevIndex = this.selNode.index || -1; - this.selNode.settings = this.previousSettings; + this.selNode.Settings = this.previousSettings; this.selectedThemeMode = this.themeModes.find((themeMode) => themeMode.id === this.previousSettings.themeMode) || this.themeModes[0]; this.selectedThemeColor = this.previousSettings.themeColor; this.store.dispatch(setSelectedNode({ payload: { uiMessage: UI_MESSAGES.NO_SPINNER, prevLnNodeIndex: +prevIndex, currentLnNode: this.selNode, isInitialSetup: true } })); diff --git a/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts b/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts index fc44651f..e117a6ff 100644 --- a/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts +++ b/src/app/shared/components/node-config/services-settings/boltz-service-settings/boltz-service-settings.component.ts @@ -39,7 +39,7 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy { this.selNode = selNode; this.enableBoltz = !!(selNode.Settings.boltzServerUrl && selNode.Settings.boltzServerUrl.trim() !== ''); this.serverUrl = this.selNode.Settings.boltzServerUrl || ''; - this.macaroonPath = this.selNode.authentication.boltzMacaroonPath; + this.macaroonPath = this.selNode.Authentication.boltzMacaroonPath; this.previousSelNode = JSON.parse(JSON.stringify(this.selNode)); this.logger.info(selNode); }); @@ -68,7 +68,7 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy { } this.logger.info(this.selNode); this.selNode.Settings.boltzServerUrl = this.serverUrl; - this.selNode.authentication.boltzMacaroonPath = this.macaroonPath; + this.selNode.Authentication.boltzMacaroonPath = this.macaroonPath; // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_BOLTZ_SETTINGS, service: ServicesEnum.BOLTZ, settings: { enable: this.enableBoltz, serverUrl: this.serverUrl, macaroonPath: this.macaroonPath } } })); // this.store.dispatch(setChildNodeSettingsLND({ // payload: { @@ -93,7 +93,7 @@ export class BoltzServiceSettingsComponent implements OnInit, OnDestroy { onReset() { this.selNode = JSON.parse(JSON.stringify(this.previousSelNode)); this.serverUrl = this.selNode.Settings.boltzServerUrl || ''; - this.macaroonPath = this.selNode.authentication.boltzMacaroonPath; + this.macaroonPath = this.selNode.Authentication.boltzMacaroonPath; this.enableBoltz = !!(this.serverUrl && this.serverUrl.trim() !== ''); } diff --git a/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.html b/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.html index 5cb03a55..8440ae1b 100644 --- a/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.html +++ b/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.html @@ -15,9 +15,9 @@ Loop Macaroon Path - + Path for the folder containing service 'loop.macaroon', eg. D:\\xyz\\AppData\\Local\\Loop\\testnet - Loop macaroon path is required. + Loop macaroon path is required.
diff --git a/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts b/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts index e5c187da..03409ac4 100644 --- a/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts +++ b/src/app/shared/components/node-config/services-settings/loop-service-settings/loop-service-settings.component.ts @@ -44,7 +44,7 @@ export class LoopServiceSettingsComponent implements OnInit, OnDestroy { onEnableServiceChanged(event) { this.enableLoop = event.checked; if (!this.enableLoop) { - this.selNode.authentication.swapMacaroonPath = ''; + this.selNode.Authentication.swapMacaroonPath = ''; this.selNode.Settings.swapServerUrl = ''; } } @@ -53,11 +53,11 @@ export class LoopServiceSettingsComponent implements OnInit, OnDestroy { if (this.selNode.Settings.swapServerUrl && this.selNode.Settings.swapServerUrl.trim() !== '' && !this.form.controls.srvrUrl.value.includes('https://')) { this.form.controls.srvrUrl.setErrors({ invalid: true }); } - if (this.enableLoop && (!this.selNode.Settings.swapServerUrl || this.selNode.Settings.swapServerUrl.trim() === '' || !this.selNode.authentication.swapMacaroonPath || this.selNode.authentication.swapMacaroonPath.trim() === '')) { + if (this.enableLoop && (!this.selNode.Settings.swapServerUrl || this.selNode.Settings.swapServerUrl.trim() === '' || !this.selNode.Authentication.swapMacaroonPath || this.selNode.Authentication.swapMacaroonPath.trim() === '')) { return true; } this.logger.info(this.selNode); - // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_LOOP_SETTINGS, service: ServicesEnum.LOOP, settings: { enable: this.enableLoop, serverUrl: this.selNode.Settings.swapServerUrl, macaroonPath: this.selNode.authentication.swapMacaroonPath } } })); + // this.store.dispatch(updateNodeSettings({ payload: { uiMessage: UI_MESSAGES.UPDATE_LOOP_SETTINGS, service: ServicesEnum.LOOP, settings: { enable: this.enableLoop, serverUrl: this.selNode.Settings.swapServerUrl, macaroonPath: this.selNode.Authentication.swapMacaroonPath } } })); // this.store.dispatch(setChildNodeSettingsLND({ // payload: { // userPersona: this.selNode.Settings.userPersona, channelBackupPath: this.selNode.Settings.channelBackupPath, selCurrencyUnit: this.selNode.Settings.currencyUnit, currencyUnits: this.selNode.Settings.currencyUnits, fiatConversion: this.selNode.Settings.fiatConversion, diff --git a/src/app/shared/components/node-config/services-settings/services-settings.component.html b/src/app/shared/components/node-config/services-settings/services-settings.component.html index 3480dabd..0a9b8698 100644 --- a/src/app/shared/components/node-config/services-settings/services-settings.component.html +++ b/src/app/shared/components/node-config/services-settings/services-settings.component.html @@ -8,11 +8,11 @@
diff --git a/src/app/shared/components/node-config/services-settings/services-settings.component.ts b/src/app/shared/components/node-config/services-settings/services-settings.component.ts index ae51f1c2..1cf240ac 100644 --- a/src/app/shared/components/node-config/services-settings/services-settings.component.ts +++ b/src/app/shared/components/node-config/services-settings/services-settings.component.ts @@ -40,7 +40,7 @@ export class ServicesSettingsComponent implements OnInit, OnDestroy { } setActiveLink() { - if (this.selNode && this.selNode.settings) { + if (this.selNode && this.selNode.Settings) { if (this.selNode.Settings.swapServerUrl && this.selNode.Settings.swapServerUrl.trim() !== '') { this.activeLink = this.links[0].link; } else if (this.selNode.Settings.boltzServerUrl && this.selNode.Settings.boltzServerUrl.trim() !== '') { diff --git a/src/app/shared/components/settings/settings.component.ts b/src/app/shared/components/settings/settings.component.ts index a616f36f..1ae7d305 100644 --- a/src/app/shared/components/settings/settings.component.ts +++ b/src/app/shared/components/settings/settings.component.ts @@ -42,7 +42,7 @@ export class SettingsComponent implements OnInit, OnDestroy { this.store.select(rootSelectedNode).pipe(takeUntil(this.unSubs[2])).subscribe((selNode) => { this.showBitcoind = false; this.selNode = selNode; - if (this.selNode.settings && this.selNode.Settings.bitcoindConfigPath && this.selNode.Settings.bitcoindConfigPath.trim() !== '') { + if (this.selNode.Settings && this.selNode.Settings.bitcoindConfigPath && this.selNode.Settings.bitcoindConfigPath.trim() !== '') { this.showBitcoind = true; } }); diff --git a/src/app/shared/models/RTLconfig.ts b/src/app/shared/models/RTLconfig.ts index 8d01f8c9..5b399845 100644 --- a/src/app/shared/models/RTLconfig.ts +++ b/src/app/shared/models/RTLconfig.ts @@ -41,18 +41,6 @@ export class Authentication { } -export class Node { - - constructor( - public Settings: Settings, - public Authentication: Authentication, - public index?: number, - public lnNode?: string, - public lnImplementation?: string - ) { } - -} - export class RTLConfiguration { constructor( @@ -67,6 +55,18 @@ export class RTLConfiguration { } +export class Node { + + constructor( + public Settings: Settings, + public Authentication: Authentication, + public index?: number, + public lnNode?: string, + public lnImplementation?: string + ) { } + +} + export interface GetInfoRoot { identity_pubkey?: string; alias?: string; diff --git a/src/app/store/rtl.effects.ts b/src/app/store/rtl.effects.ts index 5a786e35..eba8ee74 100644 --- a/src/app/store/rtl.effects.ts +++ b/src/app/store/rtl.effects.ts @@ -250,13 +250,13 @@ export class RTLEffects implements OnDestroy { this.store.dispatch(openSpinner({ payload: action.payload.uiMessage })); this.store.dispatch(updateRootAPICallStatus({ payload: { action: 'UpdateNodeSettings', status: APICallStatusEnum.INITIATED } })); const updateSettingReq = new Observable(); - // if (action.payload.settings && action.payload.defaultNodeIndex) { - // const settingsRes = this.httpClient.post(API_END_POINTS.CONF_API, { UpdateNodeSettings: action.payload.settings }); + // if (action.payload.Settings && action.payload.defaultNodeIndex) { + // const settingsRes = this.httpClient.post(API_END_POINTS.CONF_API, { UpdateNodeSettings: action.payload.Settings }); // const defaultNodeRes = this.httpClient.post(API_END_POINTS.CONF_API + '/node', { defaultNodeIndex: action.payload.defaultNodeIndex }); // updateSettingReq = forkJoin([settingsRes, defaultNodeRes]); - // } else if (action.payload.settings && !action.payload.defaultNodeIndex) { - // updateSettingReq = this.httpClient.post(API_END_POINTS.CONF_API, { UpdateNodeSettings: action.payload.settings }); - // } else if (!action.payload.settings && action.payload.defaultNodeIndex) { + // } else if (action.payload.Settings && !action.payload.defaultNodeIndex) { + // updateSettingReq = this.httpClient.post(API_END_POINTS.CONF_API, { UpdateNodeSettings: action.payload.Settings }); + // } else if (!action.payload.Settings && action.payload.defaultNodeIndex) { // updateSettingReq = this.httpClient.post(API_END_POINTS.CONF_API + '/node', { defaultNodeIndex: action.payload.defaultNodeIndex }); // } return updateSettingReq.pipe(map((updateStatus: any) => { diff --git a/src/app/store/rtl.state.ts b/src/app/store/rtl.state.ts index 8addf2be..b95fa5ea 100644 --- a/src/app/store/rtl.state.ts +++ b/src/app/store/rtl.state.ts @@ -20,7 +20,7 @@ const initNodeAuthentication = { configPath: '', swapMacaroonPath: '', boltzMaca export const initRootState: RootState = { apiURL: '', apisCallStatus: { Login: { status: APICallStatusEnum.UN_INITIATED }, IsAuthorized: { status: APICallStatusEnum.UN_INITIATED } }, - selNode: { index: 1, lnNode: 'Node 1', settings: initNodeSettings, authentication: initNodeAuthentication, lnImplementation: 'LND' }, + selNode: { index: 1, lnNode: 'Node 1', Settings: initNodeSettings, Authentication: initNodeAuthentication, lnImplementation: 'LND' }, appConfig: { defaultNodeIndex: -1, selectedNodeIndex: -1,