diff --git a/.editorconfig b/.editorconfig index 21968762..b78bc7b3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,7 @@ root = true [*] charset = utf-8 indent_style = tab -indent_size = 2 +indent_size = 1 insert_final_newline = true trim_trailing_whitespace = true diff --git a/controllers/RTLConf.js b/controllers/RTLConf.js index ae62b8f2..25b45a60 100644 --- a/controllers/RTLConf.js +++ b/controllers/RTLConf.js @@ -7,7 +7,7 @@ exports.updateSelectedNode = (req, res, next) => { const selNodeIndex = req.body.selNodeIndex; common.selectedNode = common.findNode(selNodeIndex); logger.info({fileName: 'RTLConf', msg: 'Selected Node Updated To: ' + JSON.stringify(common.selectedNode.ln_node)}); - res.status(200).json({status: 'Selected Node Updated!'}); + res.status(200).json({status: 'Selected Node Updated To: ' + JSON.stringify(common.selectedNode.ln_node) + '!'}); }; exports.getRTLConfig = (req, res, next) => { diff --git a/src/app/clightning/store/cl.effects.ts b/src/app/clightning/store/cl.effects.ts index 4e8085b1..e154f426 100644 --- a/src/app/clightning/store/cl.effects.ts +++ b/src/app/clightning/store/cl.effects.ts @@ -23,52 +23,77 @@ export class CLEffects implements OnDestroy { private store: Store, private logger: LoggerService) { } - @Effect() - infoFetchCL = this.actions$.pipe( - ofType(RTLActions.FETCH_CL_INFO), - withLatestFrom(this.store.select('root')), - mergeMap(([action, store]) => { - this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLInfo')); - return this.httpClient.get(this.CHILD_API_URL + environment.GETINFO_API) - .pipe( - map((info) => { - this.logger.info(info); - sessionStorage.setItem('clUnlocked', 'true'); - return { - type: RTLActions.SET_CL_INFO, - payload: (undefined !== info) ? info : {} - }; - }), - catchError((err) => { - this.logger.error(err); - this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLInfo', code: err.status, message: err.error.error })); - return of(); - }) - ); - } - )); + @Effect() + infoFetchCL = this.actions$.pipe( + ofType(RTLActions.FETCH_CL_INFO), + withLatestFrom(this.store.select('root')), + mergeMap(([action, store]) => { + this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLInfo')); + return this.httpClient.get(this.CHILD_API_URL + environment.GETINFO_API) + .pipe( + map((info) => { + this.logger.info(info); + let chainObj = {chain: '', network: ''}; + if (info.network === 'testnet') { + chainObj.chain = 'Bitcoin'; + chainObj.network = 'Testnet'; + } else if (info.network === 'bitcoin') { + chainObj.chain = 'Bitcoin'; + chainObj.network = 'Mainnet'; + } else if (info.network === 'litecoin') { + chainObj.chain = 'Litecoin'; + chainObj.network = 'Mainnet'; + } else if (info.network === 'litecoin-testnet') { + chainObj.chain = 'Litecoin'; + chainObj.network = 'Testnet'; + } + sessionStorage.setItem('clUnlocked', 'true'); + const node_data = { + identity_pubkey: info.id, + alias: info.alias, + testnet: (info.network === 'testnet' || info.network === 'litecoin-testnet') ? true : false, + chains: [chainObj], + version: info.version, + currency_unit: 'BTC', + smaller_currency_unit: 'Sats', + numberOfPendingChannels: info.num_pending_channels + }; + this.store.dispatch(new RTLActions.SetNodeData(node_data)); + return { + type: RTLActions.SET_CL_INFO, + payload: (undefined !== info) ? info : {} + }; + }), + catchError((err) => { + this.logger.error(err); + this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLInfo', code: err.status, message: err.error.error })); + return of(); + }) + ); + } + )); - @Effect() - fetchFeesCL = this.actions$.pipe( - ofType(RTLActions.FETCH_CL_FEES), - mergeMap((action: RTLActions.FetchCLFees) => { - this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLFees')); - return this.httpClient.get(this.CHILD_API_URL + environment.FEES_API); - }), - map((fees) => { - this.logger.info(fees); - return { - type: RTLActions.SET_CL_FEES, - payload: (undefined !== fees) ? fees : {} - }; - }), - catchError((err: any) => { + @Effect() + fetchFeesCL = this.actions$.pipe( + ofType(RTLActions.FETCH_CL_FEES), + mergeMap((action: RTLActions.FetchCLFees) => { + this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLFees')); + return this.httpClient.get(this.CHILD_API_URL + environment.FEES_API); + }), + map((fees) => { + this.logger.info(fees); + return { + type: RTLActions.SET_CL_FEES, + payload: (undefined !== fees) ? fees : {} + }; + }), + catchError((err: any) => { this.logger.error(err); this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLFees', code: err.status, message: err.error.error })); return of(); } - )); + )); - ngOnDestroy() {} + ngOnDestroy() { } } diff --git a/src/app/clightning/store/cl.reducers.ts b/src/app/clightning/store/cl.reducers.ts index a90aaebe..86bad282 100644 --- a/src/app/clightning/store/cl.reducers.ts +++ b/src/app/clightning/store/cl.reducers.ts @@ -38,7 +38,8 @@ export function CLReducer(state = initCLState, action: RTLActions.RTLActions) { }; case RTLActions.RESET_CL_STORE: return { - ...initCLState + ...initCLState, + nodeSettings: action.payload, }; case RTLActions.SET_CL_INFO: return { diff --git a/src/app/lnd/lnd-root.component.ts b/src/app/lnd/lnd-root.component.ts index aa4c55fa..3aa6e595 100644 --- a/src/app/lnd/lnd-root.component.ts +++ b/src/app/lnd/lnd-root.component.ts @@ -19,15 +19,15 @@ export class LNDRootComponent implements OnInit, OnDestroy { constructor(private store: Store, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {} ngOnInit() { - this.store.dispatch(new RTLActions.FetchLndInfo()); + this.store.dispatch(new RTLActions.FetchInfo()); this.router.navigate(['./home'], {relativeTo: this.activatedRoute}); - this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_LND_INFO || action.type === RTLActions.INIT_APP_DATA)) - .subscribe((infoData: RTLActions.SetLndInfo | RTLActions.InitAppData) => { - if(infoData.type === RTLActions.SET_LND_INFO && undefined !== infoData.payload.identity_pubkey) { + this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_INFO || action.type === RTLActions.INIT_APP_DATA)) + .subscribe((infoData: RTLActions.SetInfo | RTLActions.InitAppData) => { + if(infoData.type === RTLActions.SET_INFO && undefined !== infoData.payload.identity_pubkey) { this.initializeRemainingData(); } if(infoData.type === RTLActions.INIT_APP_DATA) { - this.store.dispatch(new RTLActions.FetchLndInfo()); + this.store.dispatch(new RTLActions.FetchInfo()); } }); } diff --git a/src/app/lnd/store/lnd.effects.ts b/src/app/lnd/store/lnd.effects.ts index 0dd5a554..bb3c69a5 100644 --- a/src/app/lnd/store/lnd.effects.ts +++ b/src/app/lnd/store/lnd.effects.ts @@ -10,7 +10,7 @@ import { MatDialog } from '@angular/material'; import { environment, API_URL } from '../../../environments/environment'; import { LoggerService } from '../../shared/services/logger.service'; -import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../../shared/models/lndModels'; +import { GetInfo, GetInfoChain, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../../shared/models/lndModels'; import * as RTLActions from '../../store/rtl.actions'; import * as fromRTLReducer from '../../store/rtl.reducers'; @@ -32,7 +32,7 @@ export class LNDEffects implements OnDestroy { @Effect() infoFetch = this.actions$.pipe( - ofType(RTLActions.FETCH_LND_INFO), + ofType(RTLActions.FETCH_INFO), withLatestFrom(this.store.select('root')), mergeMap(([action, store]) => { this.store.dispatch(new RTLActions.ClearEffectErrorLnd('FetchInfo')); @@ -45,13 +45,39 @@ export class LNDEffects implements OnDestroy { this.logger.info('Redirecting to Unlock'); this.router.navigate(['/lnd/unlocklnd']); return { - type: RTLActions.SET_LND_INFO, + type: RTLActions.SET_INFO, payload: {} }; } else { sessionStorage.setItem('lndUnlocked', 'true'); + if (undefined !== info.chains) { + if (typeof info.chains[0] === 'string') { + info.smaller_currency_unit = (info.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats'; + info.currency_unit = (info.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC'; + } else if (typeof info.chains[0] === 'object' && info.chains[0].hasOwnProperty('chain')) { + const getInfoChain = info.chains[0]; + info.smaller_currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats'; + info.currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC'; + } + info.version = (undefined === info.version) ? '' : info.version.split(' ')[0]; + } else { + info.smaller_currency_unit = 'Sats'; + info.currency_unit = 'BTC'; + info.version = (undefined === info.version) ? '' : info.version.split(' ')[0]; + } + const node_data = { + identity_pubkey: info.identity_pubkey, + alias: info.alias, + testnet: info.testnet, + chains: info.chains, + version: info.version, + currency_unit: info.currency_unit, + smaller_currency_unit: info.smaller_currency_unit, + numberOfPendingChannels: info.num_pending_channels + }; + this.store.dispatch(new RTLActions.SetNodeData(node_data)); return { - type: RTLActions.SET_LND_INFO, + type: RTLActions.SET_INFO, payload: (undefined !== info) ? info : {} }; } @@ -480,9 +506,26 @@ export class LNDEffects implements OnDestroy { map((channels: any) => { this.logger.info(channels); if (action.payload.routeParam === 'pending') { + let pendingChannels = -1; + if (channels) { + pendingChannels = 0; + if (channels.pending_closing_channels) { + pendingChannels = pendingChannels + channels.pending_closing_channels.length; + } + if (channels.pending_force_closing_channels) { + pendingChannels = pendingChannels + channels.pending_force_closing_channels.length; + } + if (channels.pending_open_channels) { + pendingChannels = pendingChannels + channels.pending_open_channels.length; + } + if (channels.waiting_close_channels) { + pendingChannels = pendingChannels + channels.waiting_close_channels.length; + } + } + this.store.dispatch(new RTLActions.SetNodePendingChannelsData(pendingChannels)); return { type: RTLActions.SET_PENDING_CHANNELS, - payload: (undefined !== channels) ? channels : {} + payload: (undefined !== channels) ? { channels: channels, pendingChannels: pendingChannels } : {channels: {}, pendingChannels: pendingChannels} }; } else if (action.payload.routeParam === 'closed') { return { diff --git a/src/app/lnd/store/lnd.reducers.ts b/src/app/lnd/store/lnd.reducers.ts index 4d69d428..c7ba695d 100644 --- a/src/app/lnd/store/lnd.reducers.ts +++ b/src/app/lnd/store/lnd.reducers.ts @@ -1,7 +1,7 @@ import { SelNodeChild } from '../../shared/models/RTLconfig'; import { ErrorPayload } from '../../shared/models/errorPayload'; import { - GetInfo, GetInfoChain, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, QueryRoutes + GetInfo, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, QueryRoutes } from '../../shared/models/lndModels'; import * as RTLActions from '../../store/rtl.actions'; @@ -79,24 +79,10 @@ export function LNDReducer(state = initLNDState, action: RTLActions.RTLActions) }; case RTLActions.RESET_LND_STORE: return { - ...initLNDState + ...initLNDState, + nodeSettings: action.payload, }; - case RTLActions.SET_LND_INFO: - if (undefined !== action.payload.chains) { - if (typeof action.payload.chains[0] === 'string') { - action.payload.smaller_currency_unit = (action.payload.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats'; - action.payload.currency_unit = (action.payload.chains[0].toString().toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC'; - } else if (typeof action.payload.chains[0] === 'object' && action.payload.chains[0].hasOwnProperty('chain')) { - const getInfoChain = action.payload.chains[0]; - action.payload.smaller_currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'Litoshis' : 'Sats'; - action.payload.currency_unit = (getInfoChain.chain.toLowerCase().indexOf('bitcoin') < 0) ? 'LTC' : 'BTC'; - } - action.payload.version = (undefined === action.payload.version) ? '' : action.payload.version.split(' ')[0]; - } else { - action.payload.smaller_currency_unit = 'Sats'; - action.payload.currency_unit = 'BTC'; - action.payload.version = (undefined === action.payload.version) ? '' : action.payload.version.split(' ')[0]; - } + case RTLActions.SET_INFO: return { ...state, information: action.payload @@ -141,26 +127,10 @@ export function LNDReducer(state = initLNDState, action: RTLActions.RTLActions) closedChannels: action.payload, }; case RTLActions.SET_PENDING_CHANNELS: - let pendingChannels = -1; - if (action.payload) { - pendingChannels = 0; - if (action.payload.pending_closing_channels) { - pendingChannels = pendingChannels + action.payload.pending_closing_channels.length; - } - if (action.payload.pending_force_closing_channels) { - pendingChannels = pendingChannels + action.payload.pending_force_closing_channels.length; - } - if (action.payload.pending_open_channels) { - pendingChannels = pendingChannels + action.payload.pending_open_channels.length; - } - if (action.payload.waiting_close_channels) { - pendingChannels = pendingChannels + action.payload.waiting_close_channels.length; - } - } return { ...state, - pendingChannels: action.payload, - numberOfPendingChannels: pendingChannels, + pendingChannels: action.payload.channels, + numberOfPendingChannels: action.payload.pendingChannels, }; case RTLActions.SET_CHANNELS: let localBal = 0, remoteBal = 0, activeChannels = 0, inactiveChannels = 0; diff --git a/src/app/store/rtl.actions.ts b/src/app/store/rtl.actions.ts index 93db4b58..0fd35d5c 100644 --- a/src/app/store/rtl.actions.ts +++ b/src/app/store/rtl.actions.ts @@ -3,7 +3,7 @@ import { Action } from '@ngrx/store'; import { GetInfoCL } from '../shared/models/clModels'; -import { RTLConfiguration, Settings, LightningNode } from '../shared/models/RTLconfig'; +import { RTLConfiguration, Settings, LightningNode, GetInfoRoot, SelNodeChild } from '../shared/models/RTLconfig'; import { ErrorPayload } from '../shared/models/errorPayload'; import { GetInfo, Peer, Balance, NetworkInfo, Fees, Channel, Invoice, ListInvoices, Payment, GraphNode, AddressType, @@ -11,14 +11,8 @@ import { } from '../shared/models/lndModels'; export const RESET_ROOT_STORE = 'RESET_ROOT_STORE'; -export const RESET_LND_STORE = 'RESET_LND_STORE'; -export const RESET_CL_STORE = 'RESET_CL_STORE'; export const CLEAR_EFFECT_ERROR_ROOT = 'CLEAR_EFFECT_ERROR_ROOT'; export const EFFECT_ERROR_ROOT = 'EFFECT_ERROR_ROOT'; -export const CLEAR_EFFECT_ERROR_LND = 'CLEAR_EFFECT_ERROR_LND'; -export const EFFECT_ERROR_LND = 'EFFECT_ERROR_LND'; -export const CLEAR_EFFECT_ERROR_CL = 'CLEAR_EFFECT_ERROR_CL'; -export const EFFECT_ERROR_CL = 'EFFECT_ERROR_CL'; export const OPEN_SPINNER = 'OPEN_SPINNER'; export const CLOSE_SPINNER = 'CLOSE_SPINNER'; export const OPEN_ALERT = 'OPEN_ALERT'; @@ -31,8 +25,14 @@ export const FETCH_RTL_CONFIG = 'FETCH_RTL_CONFIG'; export const SET_RTL_CONFIG = 'SET_RTL_CONFIG'; export const SAVE_SETTINGS = 'SAVE_SETTINGS'; export const SET_SELECTED_NODE = 'SET_SELECTED_NODE'; -export const FETCH_LND_INFO = 'FETCH_LND_INFO'; -export const SET_LND_INFO = 'SET_LND_INFO'; +export const SET_NODE_DATA = 'SET_NODE_DATA'; +export const SET_NODE_PENDING_CHANNELS_DATA = 'SET_NODE_PENDING_CHANNELS_DATA'; + +export const RESET_LND_STORE = 'RESET_LND_STORE'; +export const CLEAR_EFFECT_ERROR_LND = 'CLEAR_EFFECT_ERROR_LND'; +export const EFFECT_ERROR_LND = 'EFFECT_ERROR_LND'; +export const FETCH_INFO = 'FETCH_INFO'; +export const SET_INFO = 'SET_INFO'; export const FETCH_PEERS = 'FETCH_PEERS'; export const SET_PEERS = 'SET_PEERS'; export const SAVE_NEW_PEER = 'SAVE_NEW_PEER'; @@ -99,6 +99,9 @@ export const FETCH_CL_INFO = 'FETCH_CL_INFO'; export const SET_CL_INFO = 'SET_CL_INFO'; export const FETCH_CL_FEES = 'FETCH_CL_FEES'; export const SET_CL_FEES = 'SET_CL_FEES'; +export const RESET_CL_STORE = 'RESET_CL_STORE'; +export const CLEAR_EFFECT_ERROR_CL = 'CLEAR_EFFECT_ERROR_CL'; +export const EFFECT_ERROR_CL = 'EFFECT_ERROR_CL'; export class ClearEffectErrorRoot implements Action { readonly type = CLEAR_EFFECT_ERROR_ROOT; @@ -165,10 +168,12 @@ export class ResetRootStore implements Action { export class ResetLNDStore implements Action { readonly type = RESET_LND_STORE; + constructor(public payload: SelNodeChild) {} } export class ResetCLStore implements Action { readonly type = RESET_CL_STORE; + constructor(public payload: SelNodeChild) {} } export class FetchRTLConfig implements Action { @@ -190,12 +195,22 @@ export class SetSelelectedNode implements Action { constructor(public payload: LightningNode) {} } -export class FetchLndInfo implements Action { - readonly type = FETCH_LND_INFO; +export class SetNodeData implements Action { + readonly type = SET_NODE_DATA; + constructor(public payload: GetInfoRoot) {} +} + +export class SetNodePendingChannelsData implements Action { + readonly type = SET_NODE_PENDING_CHANNELS_DATA; + constructor(public payload: number) {} +} + +export class FetchInfo implements Action { + readonly type = FETCH_INFO; } -export class SetLndInfo implements Action { - readonly type = SET_LND_INFO; +export class SetInfo implements Action { + readonly type = SET_INFO; constructor(public payload: GetInfo) {} } @@ -283,7 +298,7 @@ export class UpdateChannels implements Action { export class SetPendingChannels implements Action { readonly type = SET_PENDING_CHANNELS; - constructor(public payload: PendingChannels) {} + constructor(public payload: {channels: PendingChannels, pendingChannels: number}) {} } export class SetClosedChannels implements Action { @@ -521,7 +536,7 @@ export type RTLActions = OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings | OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation | ResetRootStore | ResetLNDStore | ResetCLStore | - SetSelelectedNode | FetchLndInfo | SetLndInfo | + SetSelelectedNode | SetNodeData | SetNodePendingChannelsData | FetchInfo | SetInfo | FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer | AddInvoice | SaveNewInvoice | GetForwardingHistory | SetForwardingHistory | FetchFees | SetFees | diff --git a/src/app/store/rtl.effects.ts b/src/app/store/rtl.effects.ts index b2bedea2..f0aae08b 100644 --- a/src/app/store/rtl.effects.ts +++ b/src/app/store/rtl.effects.ts @@ -10,7 +10,7 @@ import { MatDialog } from '@angular/material'; import { environment, API_URL } from '../../environments/environment'; import { LoggerService } from '../shared/services/logger.service'; -import { Settings } from '../shared/models/RTLconfig'; +import { Settings, RTLConfiguration } from '../shared/models/RTLconfig'; import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../shared/models/lndModels'; import { SpinnerDialogComponent } from '../shared/components/spinner-dialog/spinner-dialog.component'; @@ -92,9 +92,10 @@ export class RTLEffects implements OnDestroy { this.store.dispatch(new RTLActions.ClearEffectErrorRoot('FetchRTLConfig')); return this.httpClient.get(environment.CONF_API + '/rtlconf'); }), - map((rtlConfig: any) => { + map((rtlConfig: RTLConfiguration) => { this.logger.info(rtlConfig); if (+rtlConfig.sso.rtlSSO) { this.store.dispatch(new RTLActions.Signout()); } + this.store.dispatch(new RTLActions.SetSelelectedNode(rtlConfig.nodes.find(node => +node.index === rtlConfig.selectedNodeIndex))) return { type: RTLActions.SET_RTL_CONFIG, payload: rtlConfig @@ -246,18 +247,19 @@ export class RTLEffects implements OnDestroy { this.logger.info(postRes); this.store.dispatch(new RTLActions.CloseSpinner()); if (sessionStorage.getItem('token')) { + let selNode = { channelBackupPath: action.payload.settings.channelBackupPath, satsToBTC: action.payload.settings.satsToBTC }; this.store.dispatch(new RTLActions.ResetRootStore(action.payload)); - this.store.dispatch(new RTLActions.ResetLNDStore()); - this.store.dispatch(new RTLActions.ResetCLStore()); - if(action.payload.lnImplementation.toLowerCase() === 'clightning') { + this.store.dispatch(new RTLActions.ResetLNDStore(selNode)); + this.store.dispatch(new RTLActions.ResetCLStore(selNode)); + if(action.payload.lnImplementation.toLowerCase() === 'clightning') { this.router.navigate(['/cl/home']); this.CHILD_API_URL = API_URL + '/cl'; return { type: RTLActions.FETCH_CL_INFO }; } else { this.router.navigate(['/lnd/home']); this.CHILD_API_URL = API_URL + '/lnd'; - this.store.dispatch(new RTLActions.FetchLndInfo()); - return { type: RTLActions.FETCH_LND_INFO }; + this.store.dispatch(new RTLActions.FetchInfo()); + return { type: RTLActions.FETCH_INFO }; } } else { return { diff --git a/src/app/store/rtl.reducers.ts b/src/app/store/rtl.reducers.ts index 380378be..4cd4c853 100644 --- a/src/app/store/rtl.reducers.ts +++ b/src/app/store/rtl.reducers.ts @@ -13,7 +13,7 @@ export interface RootState { nodeData: GetInfoRoot } -const initNodeSettings = { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false }; +const initNodeSettings = { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false, channelBackupPath: '' }; const initNodeAuthentication = { nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '' }; const initRootState: RootState = { @@ -24,7 +24,7 @@ const initRootState: RootState = { sso: { rtlSSO: 0, logoutRedirectLink: '/login' }, nodes: [{ settings: initNodeSettings, authentication: initNodeAuthentication}] }, - nodeData: { identity_pubkey: 'abc', alias: 'xyz', testnet: true, chains: [{chain: "bitcoin", network: "testnet"}], version: 'v0', currency_unit: 'BTC', smaller_currency_unit: 'SATS', numberOfPendingChannels: -1 } + nodeData: {} }; export function RootReducer(state = initRootState, action: RTLActions.RTLActions) { @@ -57,10 +57,21 @@ export function RootReducer(state = initRootState, action: RTLActions.RTLActions ...state, selNode: action.payload }; + case RTLActions.SET_NODE_DATA: + return { + ...state, + nodeData: action.payload + }; + case RTLActions.SET_NODE_PENDING_CHANNELS_DATA: + const newNodeData = state.nodeData; + newNodeData.numberOfPendingChannels = action.payload; + return { + ...state, + nodeData: newNodeData + }; case RTLActions.SET_RTL_CONFIG: return { ...state, - selNode: action.payload.nodes.find(node => +node.index === action.payload.selectedNodeIndex), appConfig: action.payload }; default: