Incomplete lazy load 9

Incomplete lazy load 9
pull/209/head
Shahana Farooqui 5 years ago
parent ab54c44b73
commit b413992708

@ -8,8 +8,7 @@ import { UserIdleService } from 'angular-user-idle';
import * as sha256 from 'sha256';
import { LoggerService } from './shared/services/logger.service';
import { RTLConfiguration, Settings, LightningNode } from './shared/models/RTLconfig';
import { GetInfoRoot } from './shared/models/lndModels';
import { RTLConfiguration, Settings, LightningNode, GetInfoRoot } from './shared/models/RTLconfig';
import * as RTLActions from './store/rtl.actions';
import * as fromRTLReducer from './store/rtl.reducers';

@ -30,6 +30,7 @@ import { AuthInterceptor } from './shared/services/auth.interceptor';
import { RTLReducer } from './store/rtl.reducers';
import { RTLEffects } from './store/rtl.effects';
import { LNDEffects } from './lnd/store/lnd.effects';
import { CLEffects } from './clightning/store/cl.effects';
@NgModule({
@ -41,7 +42,7 @@ import { CLEffects } from './clightning/store/cl.effects';
routing,
UserIdleModule.forRoot({idle: 60 * 60, timeout: 1, ping: null}),
StoreModule.forRoot(RTLReducer),
EffectsModule.forRoot([RTLEffects, CLEffects]),
EffectsModule.forRoot([RTLEffects, LNDEffects, CLEffects]),
!environment.production ? StoreDevtoolsModule.instrument() : []
],
declarations: [

@ -19,7 +19,6 @@ export class CLRootComponent implements OnInit, OnDestroy {
constructor(private store: Store<fromRTLReducer.RTLState>, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {}
ngOnInit() {
console.warn('CL ROOT')
this.router.navigate(['./home'], {relativeTo: this.activatedRoute});
this.actions$.pipe(takeUntil(this.unsubs[0]), filter((action) => action.type === RTLActions.SET_CL_INFO))
.subscribe((infoData: RTLActions.SetCLInfo) => {

@ -16,7 +16,6 @@ import * as fromCLReducer from '../store/cl.reducers';
styleUrls: ['./home.component.scss']
})
export class CLHomeComponent implements OnInit, OnDestroy {
public selNode: LightningNode;
public fees: FeesCL;
public information: GetInfoCL = {};
public flgLoading: Array<Boolean | 'error'> = [true, true, true, true, true, true, true, true]; // 0: Info, 1: Fee, 2: Wallet, 3: Channel, 4: Network
@ -25,10 +24,10 @@ export class CLHomeComponent implements OnInit, OnDestroy {
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>) {}
ngOnInit() {
this.store.select('root')
this.store.select('cl')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rootStore: fromRTLReducer.RootState) => {
rootStore.effectErrors.forEach(effectsErr => {
.subscribe((clStore: fromCLReducer.CLState) => {
clStore.effectErrorsCl.forEach(effectsErr => {
if (effectsErr.action === 'FetchCLInfo') {
this.flgLoading[0] = 'error';
}
@ -36,13 +35,6 @@ export class CLHomeComponent implements OnInit, OnDestroy {
this.flgLoading[1] = 'error';
}
});
this.selNode = rootStore.selNode;
this.logger.warn(rootStore);
});
this.store.select('cl')
.pipe(takeUntil(this.unsub[1]))
.subscribe((clStore: fromCLReducer.CLState) => {
this.information = clStore.information;
if (this.flgLoading[0] !== 'error') {
this.flgLoading[0] = (undefined !== this.information.id) ? false : true;
@ -51,7 +43,7 @@ export class CLHomeComponent implements OnInit, OnDestroy {
if (this.flgLoading[1] !== 'error') {
this.flgLoading[1] = (undefined !== this.fees.feeCollected) ? false : true;
}
this.logger.warn(clStore);
this.logger.info(clStore);
});
}

@ -28,7 +28,7 @@ export class CLEffects implements OnDestroy {
ofType(RTLActions.FETCH_CL_INFO),
withLatestFrom(this.store.select('root')),
mergeMap(([action, store]) => {
this.store.dispatch(new RTLActions.ClearEffectError('FetchCLInfo'));
this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLInfo'));
return this.httpClient.get<GetInfoCL>(this.CHILD_API_URL + environment.GETINFO_API)
.pipe(
map((info) => {
@ -41,7 +41,7 @@ export class CLEffects implements OnDestroy {
}),
catchError((err) => {
this.logger.error(err);
this.store.dispatch(new RTLActions.EffectError({ action: 'FetchCLInfo', code: err.status, message: err.error.error }));
this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLInfo', code: err.status, message: err.error.error }));
return of();
})
);
@ -52,8 +52,7 @@ export class CLEffects implements OnDestroy {
fetchFeesCL = this.actions$.pipe(
ofType(RTLActions.FETCH_CL_FEES),
mergeMap((action: RTLActions.FetchCLFees) => {
this.logger.warn('I AM HERE');
this.store.dispatch(new RTLActions.ClearEffectError('FetchCLFees'));
this.store.dispatch(new RTLActions.ClearEffectErrorCl('FetchCLFees'));
return this.httpClient.get<FeesCL>(this.CHILD_API_URL + environment.FEES_API);
}),
map((fees) => {
@ -65,7 +64,7 @@ export class CLEffects implements OnDestroy {
}),
catchError((err: any) => {
this.logger.error(err);
this.store.dispatch(new RTLActions.EffectError({ action: 'FetchCLFees', code: err.status, message: err.error.error }));
this.store.dispatch(new RTLActions.EffectErrorCl({ action: 'FetchCLFees', code: err.status, message: err.error.error }));
return of();
}
));

@ -1,18 +1,45 @@
import { SelNodeChild } from '../../shared/models/RTLconfig';
import { GetInfoCL, FeesCL } from '../../shared/models/clModels';
import { ErrorPayload } from '../../shared/models/errorPayload';
import * as RTLActions from '../../store/rtl.actions';
export interface CLState {
effectErrorsCl: ErrorPayload[];
nodeSettings: SelNodeChild;
information: GetInfoCL;
fees: FeesCL;
}
export const initCLState: CLState = {
effectErrorsCl: [],
nodeSettings: { channelBackupPath: 'my dummy path', satsToBTC: false },
information: {},
fees: {}
}
export function CLReducer(state = initCLState, action: RTLActions.RTLActions) {
switch (action.type) {
case RTLActions.CLEAR_EFFECT_ERROR_CL:
const clearedEffectErrors = [...state.effectErrorsCl];
const removeEffectIdx = state.effectErrorsCl.findIndex(err => {
return err.action === action.payload;
});
if (removeEffectIdx > -1) {
clearedEffectErrors.splice(removeEffectIdx, 1);
}
return {
...state,
effectErrors: clearedEffectErrors
};
case RTLActions.EFFECT_ERROR_CL:
return {
...state,
effectErrors: [...state.effectErrorsCl, action.payload]
};
case RTLActions.RESET_CL_STORE:
return {
...initCLState
};
case RTLActions.SET_CL_INFO:
return {
...state,

@ -8,7 +8,7 @@
</mat-card-header>
<mat-card-content>
<div fxLayout="column" fxLayout.gt-sm="row wrap" fxFlex="100" fxLayoutAlign="space-between start">
<h4 fxFlex="100">Backup folder location: {{this.selNode.settings.channelBackupPath}}</h4>
<h4 fxFlex="100">Backup folder location: {{selNode.channelBackupPath}}</h4>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="primary" tabindex="1" (click)="onBackupChannels({})">Backup</button>
<button fxFlex="49" fxLayoutAlign="center center" mat-raised-button color="accent" tabindex="2" (click)="onVerifyChannels({})">Verify Backup</button>
</div>

@ -7,7 +7,7 @@ import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { MatTableDataSource, MatSort } from '@angular/material';
import { LightningNode } from '../../../shared/models/RTLconfig';
import { SelNodeChild } from '../../../shared/models/RTLconfig';
import { Channel } from '../../../shared/models/lndModels';
import { LoggerService } from '../../../shared/services/logger.service';
@ -22,7 +22,7 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
})
export class ChannelBackupComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: true }) sort: MatSort;
public selNode: LightningNode;
public selNode: SelNodeChild = {};
public displayedColumns = ['chan_id', 'backup', 'verify'];
public selChannel: Channel;
public channels: any;
@ -33,11 +33,11 @@ export class ChannelBackupComponent implements OnInit, OnDestroy {
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private actions$: Actions, private router: Router) {}
ngOnInit() {
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore) => {
this.selNode = rtlStore.selNode;
rtlStore.effectErrors.forEach(effectsErr => {
this.selNode = rtlStore.nodeSettings;
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'Fetchchannels') {
this.flgLoading[0] = 'error';
}

@ -52,13 +52,13 @@ export class ChannelClosedComponent implements OnInit, OnDestroy {
ngOnInit() {
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'closed'}));
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => {
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_LND_STORE)).subscribe((resetLndStore: RTLActions.ResetLNDStore) => {
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'closed'}));
});
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchChannels/closed') {
this.flgLoading[0] = 'error';
}

@ -10,6 +10,7 @@ import { MatTableDataSource, MatSort } from '@angular/material';
import { Channel, Peer, GetInfo } from '../../../shared/models/lndModels';
import { LoggerService } from '../../../shared/services/logger.service';
import { LNDEffects } from '../../store/lnd.effects';
import { RTLEffects } from '../../../store/rtl.effects';
import * as RTLActions from '../../../store/rtl.actions';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@ -42,7 +43,7 @@ export class ChannelManageComponent implements OnInit, OnDestroy {
public redirectedWithPeer = false;
private unsub: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private activatedRoute: ActivatedRoute) {
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private lndEffects: LNDEffects, private activatedRoute: ActivatedRoute) {
switch (true) {
case (window.innerWidth <= 415):
this.displayedColumns = ['close', 'update', 'active', 'chan_id', 'remote_alias'];
@ -67,10 +68,10 @@ export class ChannelManageComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchChannels/all') {
this.flgLoading[0] = 'error';
}
@ -138,7 +139,7 @@ export class ChannelManageComponent implements OnInit, OnDestroy {
this.myChanPolicy = {fee_base_msat: 0, fee_rate_milli_msat: 0, time_lock_delta: 0};
this.store.dispatch(new RTLActions.OpenSpinner('Fetching Channel Policy...'));
this.store.dispatch(new RTLActions.ChannelLookup(channelToUpdate.chan_id.toString()));
this.rtlEffects.setLookup
this.lndEffects.setLookup
.pipe(takeUntil(this.unsub[3]))
.subscribe(resLookup => {
this.logger.info(resLookup);

@ -9,7 +9,7 @@
</mat-card-header>
<mat-card-content>
<div class="padding-gap">
<h3 *ngIf="selNode?.settings?.satsToBTC; else smallerUnit">Total Limbo Balance:
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit">Total Limbo Balance:
{{pendingChannels.btc_total_limbo_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit>
<h3>Total Limbo Balance: {{pendingChannels.total_limbo_balance | number}}

@ -5,7 +5,7 @@ import { Store } from '@ngrx/store';
import { MatTableDataSource, MatSort } from '@angular/material';
import { Channel, GetInfo, PendingChannels } from '../../../shared/models/lndModels';
import { LightningNode } from '../../../shared/models/RTLconfig';
import { SelNodeChild } from '../../../shared/models/RTLconfig';
import { LoggerService } from '../../../shared/services/logger.service';
import { RTLEffects } from '../../../store/rtl.effects';
@ -19,7 +19,7 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
})
export class ChannelPendingComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: true }) sort: MatSort;
public selNode: LightningNode;
public selNode: SelNodeChild = {};
public selectedFilter = 0;
public information: GetInfo = {};
public pendingChannels: PendingChannels = {};
@ -96,16 +96,16 @@ export class ChannelPendingComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchChannels/pending') {
this.flgLoading[0] = 'error';
}
});
this.selNode = rtlStore.selNode;
this.selNode = rtlStore.nodeSettings;
this.information = rtlStore.information;
this.pendingChannels = rtlStore.pendingChannels;
if (undefined !== this.pendingChannels.total_limbo_balance) {

@ -11,7 +11,7 @@
<mat-icon class="icon-large">account_balance_wallet</mat-icon>
</mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="selNode?.settings?.satsToBTC; else smallerUnit1">{{BTCtotalBalance | number}} {{information?.currency_unit}}</h3>
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit1">{{BTCtotalBalance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit1><h3>{{totalBalance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span>
</mat-card-content>
@ -51,7 +51,7 @@
<mat-icon class="icon-large">linear_scale</mat-icon>
</mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="selNode?.settings?.satsToBTC; else smallerUnit2">{{BTCchannelBalance | number}} {{information?.currency_unit}}</h3>
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit2">{{BTCchannelBalance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit2><h3>{{channelBalance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span>
</mat-card-content>
@ -180,8 +180,8 @@
<mat-card-content>
<div fxLayout="column" class="pl-4 network-info-list">
<mat-list fxLayoutAlign="start start">
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.settings?.satsToBTC; else smallerUnit6">Network Capacity ({{information?.currency_unit}})</mat-list-item>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.settings?.satsToBTC; else smallerData6">{{networkInfo?.btc_total_network_capacity | number}}</mat-list-item>
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.satsToBTC; else smallerUnit6">Network Capacity ({{information?.currency_unit}})</mat-list-item>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.satsToBTC; else smallerData6">{{networkInfo?.btc_total_network_capacity | number}}</mat-list-item>
<ng-template #smallerUnit6><mat-list-item fxFlex="65" fxLayoutAlign="start start">Network Capacity ({{information?.smaller_currency_unit}})</mat-list-item></ng-template>
<ng-template #smallerData6><mat-list-item fxFlex="25" fxLayoutAlign="end start">{{networkInfo?.total_network_capacity | number}}</mat-list-item></ng-template>
<mat-divider></mat-divider>
@ -207,23 +207,23 @@
<mat-divider></mat-divider>
</mat-list>
<mat-list fxLayoutAlign="start start">
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.settings?.satsToBTC; else smallerUnit7">Max Channel Size ({{information?.currency_unit}})</mat-list-item>
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.satsToBTC; else smallerUnit7">Max Channel Size ({{information?.currency_unit}})</mat-list-item>
<ng-template #smallerUnit7><mat-list-item fxFlex="65" fxLayoutAlign="start start">Max Channel Size ({{information?.smaller_currency_unit}})</mat-list-item></ng-template>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.settings?.satsToBTC; else smallerData7">{{networkInfo?.btc_max_channel_size | number}}</mat-list-item>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.satsToBTC; else smallerData7">{{networkInfo?.btc_max_channel_size | number}}</mat-list-item>
<ng-template #smallerData7><mat-list-item fxFlex="25" fxLayoutAlign="end start">{{networkInfo?.max_channel_size | number}}</mat-list-item></ng-template>
<mat-divider></mat-divider>
</mat-list>
<mat-list fxLayoutAlign="start start">
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.settings?.satsToBTC; else smallerUnit8">Avg Channel Size ({{information?.currency_unit}})</mat-list-item>
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.satsToBTC; else smallerUnit8">Avg Channel Size ({{information?.currency_unit}})</mat-list-item>
<ng-template #smallerUnit8><mat-list-item fxFlex="65" fxLayoutAlign="start start">Avg Channel Size ({{information?.smaller_currency_unit}})</mat-list-item></ng-template>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.settings?.satsToBTC; else smallerData8">{{networkInfo?.btc_avg_channel_size | number}}</mat-list-item>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.satsToBTC; else smallerData8">{{networkInfo?.btc_avg_channel_size | number}}</mat-list-item>
<ng-template #smallerData8><mat-list-item fxFlex="25" fxLayoutAlign="end start">{{networkInfo?.avg_channel_size | number:'1.0-2'}}</mat-list-item></ng-template>
<mat-divider></mat-divider>
</mat-list>
<mat-list fxLayoutAlign="start start">
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.settings?.satsToBTC; else smallerUnit9">Min Channel Size ({{information?.currency_unit}})</mat-list-item>
<mat-list-item fxFlex="65" fxLayoutAlign="start start" *ngIf="selNode?.satsToBTC; else smallerUnit9">Min Channel Size ({{information?.currency_unit}})</mat-list-item>
<ng-template #smallerUnit9><mat-list-item fxFlex="65" fxLayoutAlign="start start">Min Channel Size ({{information?.smaller_currency_unit}})</mat-list-item></ng-template>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.settings?.satsToBTC; else smallerData9">{{networkInfo?.btc_min_channel_size | number}}</mat-list-item>
<mat-list-item fxFlex="25" fxLayoutAlign="end start" *ngIf="selNode?.satsToBTC; else smallerData9">{{networkInfo?.btc_min_channel_size | number}}</mat-list-item>
<ng-template #smallerData9><mat-list-item fxFlex="25" fxLayoutAlign="end start">{{networkInfo?.min_channel_size | number}}</mat-list-item></ng-template>
<mat-divider></mat-divider>
</mat-list>

@ -5,7 +5,7 @@ import { Store } from '@ngrx/store';
import { LoggerService } from '../../shared/services/logger.service';
import { GetInfo, NetworkInfo, Fees, Peer } from '../../shared/models/lndModels';
import { LightningNode } from '../../shared/models/RTLconfig';
import { SelNodeChild } from '../../shared/models/RTLconfig';
import * as fromRTLReducer from '../../store/rtl.reducers';
@ -15,7 +15,7 @@ import * as fromRTLReducer from '../../store/rtl.reducers';
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit, OnDestroy {
public selNode: LightningNode;
public selNode: SelNodeChild = {};
public fees: Fees;
public information: GetInfo = {};
public remainder = 0;
@ -64,10 +64,10 @@ export class HomeComponent implements OnInit, OnDestroy {
ngOnInit() {
this.flgTotalCalculated = false;
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchInfo') {
this.flgLoading[0] = 'error';
}
@ -88,7 +88,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.flgLoading[6] = 'error';
}
});
this.selNode = rtlStore.selNode;
this.selNode = rtlStore.nodeSettings;
this.information = rtlStore.information;
if (this.flgLoading[0] !== 'error') {
this.flgLoading[0] = (undefined !== this.information.identity_pubkey) ? false : true;

@ -57,8 +57,8 @@
<td mat-cell *matCellDef="let invoice">{{invoice.memo}}</td>
</ng-container>
<ng-container matColumnDef="value">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Value ({{(selNode?.settings?.satsToBTC) ? information?.currency_unit : information?.smaller_currency_unit}}) </th>
<td mat-cell *matCellDef="let invoice"><span fxLayoutAlign="end center"> {{(selNode?.settings?.satsToBTC) ? (invoice?.btc_value | number:'1.0-3') : (invoice?.value | number)}} </span></td>
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Value ({{(selNode?.satsToBTC) ? information?.currency_unit : information?.smaller_currency_unit}}) </th>
<td mat-cell *matCellDef="let invoice"><span fxLayoutAlign="end center"> {{(selNode?.satsToBTC) ? (invoice?.btc_value | number:'1.0-3') : (invoice?.value | number)}} </span></td>
</ng-container>
<ng-container matColumnDef="expiry">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Expiry (Sec)</th>
@ -69,8 +69,8 @@
<td mat-cell *matCellDef="let invoice"><span fxLayoutAlign="end center"> {{invoice.cltv_expiry | number}} </span></td>
</ng-container>
<ng-container matColumnDef="amt_paid_sat">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Amount Paid ({{(selNode?.settings?.satsToBTC) ? information?.currency_unit : information?.smaller_currency_unit}})</th>
<td mat-cell *matCellDef="let invoice"><span fxLayoutAlign="end center"> {{(selNode?.settings?.satsToBTC) ? (invoice?.btc_amt_paid_sat | number:'1.0-3') : (invoice?.amt_paid_sat | number)}} </span></td>
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Amount Paid ({{(selNode?.satsToBTC) ? information?.currency_unit : information?.smaller_currency_unit}})</th>
<td mat-cell *matCellDef="let invoice"><span fxLayoutAlign="end center"> {{(selNode?.satsToBTC) ? (invoice?.btc_amt_paid_sat | number:'1.0-3') : (invoice?.amt_paid_sat | number)}} </span></td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;" [@newlyAddedRowAnimation]="(row.memo == newlyAddedInvoiceMemo && row.value == newlyAddedInvoiceValue && flgAnimate) ? 'added' : 'notAdded'" (click)="onInvoiceClick(row, $event)" class="row-invoices"

@ -1,12 +1,12 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { formatDate } from '@angular/common';
import { Subject } from 'rxjs';
import { takeUntil, filter } from 'rxjs/operators';
import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { MatTableDataSource, MatSort } from '@angular/material';
import { LightningNode } from '../../shared/models/RTLconfig';
import { SelNodeChild } from '../../shared/models/RTLconfig';
import { GetInfo, Invoice } from '../../shared/models/lndModels';
import { LoggerService } from '../../shared/services/logger.service';
@ -22,7 +22,7 @@ import * as fromRTLReducer from '../../store/rtl.reducers';
})
export class InvoicesComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: true }) sort: MatSort;
public selNode: LightningNode;
public selNode: SelNodeChild = {};
public newlyAddedInvoiceMemo = '';
public newlyAddedInvoiceValue = 0;
public flgAnimate = true;
@ -66,15 +66,15 @@ export class InvoicesComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchInvoices') {
this.flgLoading[0] = 'error';
}
});
this.selNode = rtlStore.selNode;
this.selNode = rtlStore.nodeSettings;
this.information = rtlStore.information;
this.totalInvoices = rtlStore.totalInvoices;
this.firstOffset = +rtlStore.invoices.first_index_offset;

@ -19,16 +19,15 @@ export class LNDRootComponent implements OnInit, OnDestroy {
constructor(private store: Store<fromRTLReducer.RTLState>, private actions$: Actions, private router: Router, private activatedRoute: ActivatedRoute) {}
ngOnInit() {
console.warn('LND ROOT')
this.store.dispatch(new RTLActions.FetchInfo());
this.store.dispatch(new RTLActions.FetchLndInfo());
this.router.navigate(['./home'], {relativeTo: this.activatedRoute});
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.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.initializeRemainingData();
}
if(infoData.type === RTLActions.INIT_APP_DATA) {
this.store.dispatch(new RTLActions.FetchInfo());
this.store.dispatch(new RTLActions.FetchLndInfo());
}
});
}

@ -25,7 +25,7 @@ export class ChannelLookupComponent implements OnInit {
this.lookupResult.last_update_str = (this.lookupResult.last_update_str === '') ?
'' : formatDate(this.lookupResult.last_update_str, 'MMM/dd/yy HH:mm:ss', 'en-US');
}
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore) => {
if (this.lookupResult.node1_pub === rtlStore.information.identity_pubkey) {

@ -34,7 +34,7 @@ export class LookupsComponent implements OnInit, OnDestroy {
this.actions$
.pipe(
takeUntil(this.unSubs[0]),
filter((action) => (action.type === RTLActions.SET_LOOKUP || action.type === RTLActions.EFFECT_ERROR))
filter((action) => (action.type === RTLActions.SET_LOOKUP || action.type === RTLActions.EFFECT_ERROR_LND))
).subscribe((resLookup: RTLActions.SetLookup) => {
if (resLookup.payload.action === 'Lookup') {
this.flgLoading[0] = 'error';

@ -9,7 +9,7 @@ import { MatTableDataSource, MatSort } from '@angular/material';
import { Hop } from '../../../shared/models/lndModels';
import { LoggerService } from '../../../shared/services/logger.service';
import { RTLEffects } from '../../../store/rtl.effects';
import { LNDEffects } from '../../store/lnd.effects';
import * as RTLActions from '../../../store/rtl.actions';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@ -28,7 +28,7 @@ export class QueryRoutesComponent implements OnInit, OnDestroy {
public flgLoading: Array<Boolean | 'error'> = [false]; // 0: peers
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private actions$: Actions) {
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private lndEffects: LNDEffects, private actions$: Actions) {
switch (true) {
case (window.innerWidth <= 415):
this.displayedColumns = ['hop_sequence', 'pubkey_alias', 'fee_msat'];
@ -51,7 +51,7 @@ export class QueryRoutesComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.rtlEffects.setQueryRoutes
this.lndEffects.setQueryRoutes
.pipe(takeUntil(this.unSubs[1]))
.subscribe(queryRoute => {
this.qrHops = new MatTableDataSource([]);

@ -5,11 +5,11 @@ import { takeUntil, take } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { MatTableDataSource, MatSort } from '@angular/material';
import { LightningNode } from '../../../shared/models/RTLconfig';
import { GetInfo, Payment, PayRequest } from '../../../shared/models/lndModels';
import { LoggerService } from '../../../shared/services/logger.service';
import { newlyAddedRowAnimation } from '../../../shared/animation/row-animation';
import { LNDEffects } from '../../store/lnd.effects';
import { RTLEffects } from '../../../store/rtl.effects';
import * as RTLActions from '../../../store/rtl.actions';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@ -23,7 +23,6 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
export class PaymentsComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: true }) sort: MatSort;
@ViewChild('sendPaymentForm', { static: true }) form;
public selNode: LightningNode;
public newlyAddedPayment = '';
public flgAnimate = true;
public flgLoading: Array<Boolean | 'error'> = [true];
@ -36,7 +35,7 @@ export class PaymentsComponent implements OnInit, OnDestroy {
public flgSticky = false;
private unsub: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects) {
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private lndEffects: LNDEffects) {
switch (true) {
case (window.innerWidth <= 415):
this.displayedColumns = ['creation_date', 'fee', 'value'];
@ -59,15 +58,14 @@ export class PaymentsComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchPayments') {
this.flgLoading[0] = 'error';
}
});
this.selNode = rtlStore.selNode;
this.information = rtlStore.information;
this.paymentJSONArr = (null !== rtlStore.payments && rtlStore.payments.length > 0) ? rtlStore.payments : [];
this.payments = (undefined === rtlStore.payments || null == rtlStore.payments) ? new MatTableDataSource([]) : new MatTableDataSource<Payment>([...this.paymentJSONArr]);
@ -91,7 +89,7 @@ export class PaymentsComponent implements OnInit, OnDestroy {
} else {
this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
this.store.dispatch(new RTLActions.DecodePayment(this.paymentRequest));
this.rtlEffects.setDecodedPayment
this.lndEffects.setDecodedPayment
.pipe(take(1))
.subscribe(decodedPayment => {
this.paymentDecoded = decodedPayment;
@ -149,7 +147,7 @@ export class PaymentsComponent implements OnInit, OnDestroy {
onVerifyPayment() {
this.store.dispatch(new RTLActions.OpenSpinner('Decoding Payment...'));
this.store.dispatch(new RTLActions.DecodePayment(this.paymentRequest));
this.rtlEffects.setDecodedPayment.subscribe(decodedPayment => {
this.lndEffects.setDecodedPayment.subscribe(decodedPayment => {
this.paymentDecoded = decodedPayment;
if (undefined !== this.paymentDecoded.timestamp_str) {
this.paymentDecoded.timestamp_str = (this.paymentDecoded.timestamp_str === '') ? '' :

@ -11,6 +11,7 @@ import { Peer, GetInfo } from '../../shared/models/lndModels';
import { LoggerService } from '../../shared/services/logger.service';
import { newlyAddedRowAnimation } from '../../shared/animation/row-animation';
import { LNDEffects } from '../store/lnd.effects';
import { RTLEffects } from '../../store/rtl.effects';
import * as RTLActions from '../../store/rtl.actions';
import * as fromRTLReducer from '../../store/rtl.reducers';
@ -33,7 +34,7 @@ export class PeersComponent implements OnInit, OnDestroy {
public flgSticky = false;
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private actions$: Actions, private router: Router) {
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private lndEffects: LNDEffects, private actions$: Actions, private router: Router) {
switch (true) {
case (window.innerWidth <= 415):
this.displayedColumns = ['detach', 'pub_key', 'alias'];
@ -56,10 +57,10 @@ export class PeersComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unSubs[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchPeers') {
this.flgLoading[0] = 'error';
}
@ -102,7 +103,7 @@ export class PeersComponent implements OnInit, OnDestroy {
pubkey = (deviderIndex > -1) ? this.peerAddress.substring(0, deviderIndex) : this.peerAddress;
this.store.dispatch(new RTLActions.OpenSpinner('Getting Node Address...'));
this.store.dispatch(new RTLActions.FetchGraphNode(pubkey));
this.rtlEffects.setGraphNode
this.lndEffects.setGraphNode
.pipe(take(1))
.subscribe(graphNode => {
host = (undefined === graphNode.node.addresses || undefined === graphNode.node.addresses[0].addr) ? '' : graphNode.node.addresses[0].addr;

@ -59,13 +59,13 @@ export class RoutingPeersComponent implements OnInit, OnDestroy {
ngOnInit() {
this.onRoutingPeersFetch();
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => {
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_LND_STORE)).subscribe((resetLndStore: RTLActions.ResetLNDStore) => {
this.onRoutingPeersFetch();
});
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'GetForwardingHistory') {
this.flgLoading[0] = 'error';
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,267 @@
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
} from '../../shared/models/lndModels';
import * as RTLActions from '../../store/rtl.actions';
export interface LNDState {
effectErrorsLnd: ErrorPayload[];
nodeSettings: SelNodeChild;
information: GetInfo;
peers: Peer[];
fees: Fees;
networkInfo: NetworkInfo;
channelBalance: Balance;
blockchainBalance: Balance;
allChannels: Channel[];
closedChannels: ClosedChannel[];
pendingChannels: PendingChannels;
numberOfActiveChannels: number;
numberOfInactiveChannels: number;
numberOfPendingChannels: number;
totalLocalBalance: number;
totalRemoteBalance: number;
totalInvoices: number;
transactions: Transaction[];
payments: Payment[];
invoices: ListInvoices;
forwardingHistory: SwitchRes;
addressTypes: AddressType[];
}
export const initLNDState: LNDState = {
effectErrorsLnd: [],
nodeSettings: { channelBackupPath: 'my dummy path', satsToBTC: false },
information: {},
peers: [],
fees: {},
networkInfo: {},
channelBalance: {balance: '', btc_balance: ''},
blockchainBalance: { total_balance: '', btc_total_balance: ''},
allChannels: [],
closedChannels: [],
pendingChannels: {},
numberOfActiveChannels: 0,
numberOfInactiveChannels: 0,
numberOfPendingChannels: -1,
totalLocalBalance: -1,
totalRemoteBalance: -1,
totalInvoices: -1,
transactions: [],
payments: [],
invoices: {invoices: []},
forwardingHistory: {},
addressTypes: [
{ addressId: '0', addressTp: 'p2wkh', addressDetails: 'Pay to witness key hash'},
{ addressId: '1', addressTp: 'np2wkh', addressDetails: 'Pay to nested witness key hash (default)'}
]
}
export function LNDReducer(state = initLNDState, action: RTLActions.RTLActions) {
switch (action.type) {
case RTLActions.CLEAR_EFFECT_ERROR_LND:
const clearedEffectErrors = [...state.effectErrorsLnd];
const removeEffectIdx = state.effectErrorsLnd.findIndex(err => {
return err.action === action.payload;
});
if (removeEffectIdx > -1) {
clearedEffectErrors.splice(removeEffectIdx, 1);
}
return {
...state,
effectErrors: clearedEffectErrors
};
case RTLActions.EFFECT_ERROR_LND:
return {
...state,
effectErrors: [...state.effectErrorsLnd, action.payload]
};
case RTLActions.RESET_LND_STORE:
return {
...initLNDState
};
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 = <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];
}
return {
...state,
information: action.payload
};
case RTLActions.SET_PEERS:
return {
...state,
peers: action.payload
};
case RTLActions.ADD_PEER:
return {
...state,
peers: [...state.peers, action.payload]
};
case RTLActions.REMOVE_PEER:
const modifiedPeers = [...state.peers];
const removePeerIdx = state.peers.findIndex(peer => {
return peer.pub_key === action.payload.pubkey;
});
if (removePeerIdx > -1) {
modifiedPeers.splice(removePeerIdx, 1);
}
return {
...state,
peers: modifiedPeers
};
case RTLActions.ADD_INVOICE:
const newInvoices = state.invoices;
newInvoices.invoices.unshift(action.payload);
return {
...state,
invoices: newInvoices
};
case RTLActions.SET_FEES:
return {
...state,
fees: action.payload
};
case RTLActions.SET_CLOSED_CHANNELS:
return {
...state,
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,
};
case RTLActions.SET_CHANNELS:
let localBal = 0, remoteBal = 0, activeChannels = 0, inactiveChannels = 0;
if (action.payload) {
action.payload.filter(channel => {
if (undefined !== channel.local_balance) {
localBal = +localBal + +channel.local_balance;
}
if (undefined !== channel.remote_balance) {
remoteBal = +remoteBal + +channel.remote_balance;
}
if (channel.active === true) {
activeChannels = activeChannels + 1;
} else {
inactiveChannels = inactiveChannels + 1;
}
});
}
return {
...state,
allChannels: action.payload,
numberOfActiveChannels: activeChannels,
numberOfInactiveChannels: inactiveChannels,
totalLocalBalance: localBal,
totalRemoteBalance: remoteBal
};
case RTLActions.REMOVE_CHANNEL:
const modifiedChannels = [...state.allChannels];
const removeChannelIdx = state.allChannels.findIndex(channel => {
return channel.channel_point === action.payload.channelPoint;
});
if (removeChannelIdx > -1) {
modifiedChannels.splice(removeChannelIdx, 1);
}
return {
...state,
allChannels: modifiedChannels
};
case RTLActions.SET_BALANCE:
if (action.payload.target === 'channels') {
return {
...state,
channelBalance: action.payload.balance
};
} else {
return {
...state,
blockchainBalance: action.payload.balance
};
}
case RTLActions.SET_NETWORK:
return {
...state,
networkInfo: action.payload
};
case RTLActions.SET_INVOICES:
return {
...state,
invoices: action.payload
};
case RTLActions.SET_TOTAL_INVOICES:
return {
...state,
totalInvoices: action.payload
};
case RTLActions.SET_TRANSACTIONS:
return {
...state,
transactions: action.payload
};
case RTLActions.SET_PAYMENTS:
return {
...state,
payments: action.payload
};
case RTLActions.SET_FORWARDING_HISTORY:
if (action.payload.forwarding_events) {
const storedChannels = [...state.allChannels];
action.payload.forwarding_events.forEach(event => {
if (storedChannels) {
for (let idx = 0; idx < storedChannels.length; idx++) {
if (storedChannels[idx].chan_id.toString() === event.chan_id_in) {
event.alias_in = storedChannels[idx].remote_alias;
if (event.alias_out) { return; }
}
if (storedChannels[idx].chan_id.toString() === event.chan_id_out) {
event.alias_out = storedChannels[idx].remote_alias;
if (event.alias_in) { return; }
}
}
}
});
} else {
action.payload = {};
}
return {
...state,
forwardingHistory: action.payload
};
default:
return state;
}
}

@ -54,14 +54,14 @@ export class ForwardingHistoryComponent implements OnInit, OnDestroy {
ngOnInit() {
this.onForwardingHistoryFetch();
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => {
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_LND_STORE)).subscribe((resetLndStore: RTLActions.ResetLNDStore) => {
this.onForwardingHistoryFetch();
});
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'GetForwardingHistory') {
this.flgLoading[0] = 'error';
}
@ -86,7 +86,6 @@ export class ForwardingHistoryComponent implements OnInit, OnDestroy {
const selFEvent = this.forwardingHistoryEvents.data.filter(fhEvent => {
return (fhEvent.chan_id_in === selRow.chan_id_in && fhEvent.timestamp === selRow.timestamp);
})[0];
console.warn(selFEvent);
const reorderedFHEvent = JSON.parse(JSON.stringify(selFEvent, ['timestamp_str', 'chan_id_in', 'alias_in', 'chan_id_out', 'alias_out', 'amt_out', 'amt_in', 'fee'] , 2));
this.store.dispatch(new RTLActions.OpenAlert({ width: '75%', data: {
type: 'INFO',

@ -50,14 +50,14 @@ export class ListTransactionsComponent implements OnInit, OnDestroy {
ngOnInit() {
this.store.dispatch(new RTLActions.FetchTransactions());
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_STORE)).subscribe((resetStore: RTLActions.ResetStore) => {
this.actions$.pipe(takeUntil(this.unsub[2]), filter((action) => action.type === RTLActions.RESET_LND_STORE)).subscribe((resetLndStore: RTLActions.ResetLNDStore) => {
this.store.dispatch(new RTLActions.FetchTransactions());
});
this.store.select('rtl')
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchTransactions') {
this.flgLoading[0] = 'error';
}

@ -17,7 +17,7 @@
</svg>
</mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="selNode?.settings?.satsToBTC; else smallerUnit1">{{blockchainBalance?.btc_total_balance | number}} {{information?.currency_unit}}</h3>
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit1">{{blockchainBalance?.btc_total_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit1><h3>{{blockchainBalance?.total_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span>
</mat-card-content>
@ -40,7 +40,7 @@
</svg>
</mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="selNode?.settings?.satsToBTC; else smallerUnit2">{{blockchainBalance?.btc_confirmed_balance | number}} {{information?.currency_unit}}</h3>
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit2">{{blockchainBalance?.btc_confirmed_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit2><h3>{{blockchainBalance?.confirmed_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span>
</mat-card-content>
@ -63,7 +63,7 @@
</svg>
</mat-card-content>
<span *ngIf="information?.currency_unit; else withoutData">
<h3 *ngIf="selNode?.settings?.satsToBTC; else smallerUnit3">{{blockchainBalance?.btc_unconfirmed_balance | number}} {{information?.currency_unit}}</h3>
<h3 *ngIf="selNode?.satsToBTC; else smallerUnit3">{{blockchainBalance?.btc_unconfirmed_balance | number}} {{information?.currency_unit}}</h3>
<ng-template #smallerUnit3><h3>{{blockchainBalance?.unconfirmed_balance | number}} {{information?.smaller_currency_unit}}</h3></ng-template>
</span>
</mat-card-content>

@ -3,12 +3,13 @@ import { Subject } from 'rxjs';
import { takeUntil, take } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { LightningNode } from '../../../shared/models/RTLconfig';
import { SelNodeChild } from '../../../shared/models/RTLconfig';
import { GetInfo, Balance, ChannelsTransaction, AddressType } from '../../../shared/models/lndModels';
import { RTLConfiguration } from '../../../shared/models/RTLconfig';
import { LoggerService } from '../../../shared/services/logger.service';
import * as sha256 from 'sha256';
import { LNDEffects } from '../../store/lnd.effects';
import { RTLEffects } from '../../../store/rtl.effects';
import * as RTLActions from '../../../store/rtl.actions';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@ -19,7 +20,7 @@ import * as fromRTLReducer from '../../../store/rtl.reducers';
styleUrls: ['./send-receive-trans.component.scss']
})
export class SendReceiveTransComponent implements OnInit, OnDestroy {
public selNode: LightningNode;
public selNode: SelNodeChild = {};
public appConfig: RTLConfiguration;
public addressTypes = [];
public flgLoadingWallet: Boolean | 'error' = true;
@ -33,19 +34,25 @@ export class SendReceiveTransComponent implements OnInit, OnDestroy {
public flgCustomAmount = '1';
private unsub: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects) {}
constructor(private logger: LoggerService, private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects, private lndEffects: LNDEffects) {}
ngOnInit() {
this.store.select('rtl')
this.store.select('root')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rootStore) => {
this.appConfig = rootStore.appConfig;
this.logger.info(rootStore);
});
this.store.select('lnd')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsLnd.forEach(effectsErr => {
if (effectsErr.action === 'FetchBalance/blockchain') {
this.flgLoadingWallet = 'error';
}
});
this.selNode = rtlStore.selNode;
this.appConfig = rtlStore.appConfig;
this.selNode = rtlStore.nodeSettings;
this.information = rtlStore.information;
this.addressTypes = rtlStore.addressTypes;
@ -71,7 +78,7 @@ export class SendReceiveTransComponent implements OnInit, OnDestroy {
onGenerateAddress() {
this.store.dispatch(new RTLActions.OpenSpinner('Getting New Address...'));
this.store.dispatch(new RTLActions.GetNewAddress(this.selectedAddress));
this.rtlEffects.setNewAddress
this.lndEffects.setNewAddress
.pipe(takeUntil(this.unsub[1]))
.subscribe(newAddress => {
this.newAddress = newAddress;

@ -7,7 +7,7 @@ import { FormBuilder, FormGroup, Validators, ValidatorFn, AbstractControl, Valid
import { STEPPER_GLOBAL_OPTIONS } from '@angular/cdk/stepper';
import { MatStepper } from '@angular/material';
import { RTLEffects } from '../../store/rtl.effects';
import { LNDEffects } from '../store/lnd.effects';
import * as RTLActions from '../../store/rtl.actions';
import * as fromRTLReducer from '../../store/rtl.reducers';
@ -46,7 +46,7 @@ export class UnlockLNDComponent implements OnInit, OnDestroy {
warnRes = true;
private unsubs = [new Subject(), new Subject(), new Subject(), new Subject(), new Subject()];
constructor(private store: Store<fromRTLReducer.RTLState>, private formBuilder: FormBuilder, private rtlEffects: RTLEffects, private router: Router) {}
constructor(private store: Store<fromRTLReducer.RTLState>, private formBuilder: FormBuilder, private lndEffects: LNDEffects, private router: Router) {}
ngOnInit() {
this.walletPassword = '';
@ -85,13 +85,13 @@ export class UnlockLNDComponent implements OnInit, OnDestroy {
this.insecureLND = !window.location.protocol.includes('https://');
this.rtlEffects.initWalletRes
this.lndEffects.initWalletRes
.pipe(takeUntil(this.unsubs[2]))
.subscribe(initWalletResponse => {
this.initWalletResponse = initWalletResponse;
});
this.rtlEffects.genSeedResponse
this.lndEffects.genSeedResponse
.pipe(takeUntil(this.unsubs[3]))
.subscribe(genSeedRes => {
this.genSeedResponse = genSeedRes;

@ -42,7 +42,6 @@ export class HorizontalNavigationComponent implements OnInit {
takeUntil(this.unSubs[2]),
filter((action) => action.type === RTLActions.SIGNOUT || action.type === RTLActions.SIGNIN)
).subscribe((action) => {
this.logger.warn(action);
if (action.type === RTLActions.SIGNIN) {
this.menuNodes.push({id: 200, parentId: 0, name: 'Logout', icon: 'eject'});
}

@ -9,9 +9,9 @@ import { environment } from '../../../../../environments/environment';
import { FlatTreeControl } from '@angular/cdk/tree';
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
import { LightningNode, Settings } from '../../../models/RTLconfig';
import { LightningNode, Settings, GetInfoRoot } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { GetInfoRoot, GetInfoChain } from '../../../models/lndModels';
import { GetInfoChain } from '../../../models/lndModels';
import { MenuChildNode, FlatMenuNode, MENU_DATA } from '../../../models/navMenu';
import { RTLEffects } from '../../../../store/rtl.effects';

@ -4,9 +4,9 @@ import { takeUntil, filter } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { LightningNode } from '../../../models/RTLconfig';
import { GetInfoRoot, LightningNode } from '../../../models/RTLconfig';
import { LoggerService } from '../../../services/logger.service';
import { GetInfoRoot, GetInfoChain } from '../../../models/lndModels';
import { GetInfoChain } from '../../../models/lndModels';
import { environment } from '../../../../../environments/environment';
import { RTLEffects } from '../../../../store/rtl.effects';

@ -25,10 +25,10 @@ export class ServerConfigComponent implements OnInit, OnDestroy {
constructor(private store: Store<fromRTLReducer.RTLState>, private rtlEffects: RTLEffects) {}
ngOnInit() {
this.store.select('rtl')
this.store.select('root')
.pipe(takeUntil(this.unsubs[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsRoot.forEach(effectsErr => {
if (effectsErr.action === 'fetchConfig') {
this.resetData();
}

@ -3,8 +3,7 @@ import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { LightningNode, RTLConfiguration } from '../../models/RTLconfig';
import { GetInfoRoot } from '../../models/lndModels';
import { LightningNode, RTLConfiguration, GetInfoRoot } from '../../models/RTLconfig';
import { LoggerService } from '../../services/logger.service';
import * as RTLActions from '../../../store/rtl.actions';

@ -31,7 +31,7 @@ export class SigninComponent implements OnInit, OnDestroy {
this.store.select('root')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
rtlStore.effectErrorsRoot.forEach(effectsErr => {
this.logger.error(effectsErr);
});
this.selNode = rtlStore.selNode;

@ -1,3 +1,5 @@
import { GetInfoChain } from './lndModels';
export class SSO {
constructor(
public rtlSSO: number,
@ -45,3 +47,19 @@ export class RTLConfiguration {
public nodes: LightningNode[]
) { }
}
export interface GetInfoRoot {
identity_pubkey?: string;
alias?: string;
testnet?: boolean;
chains?: GetInfoChain[] | string[];
version?: string;
currency_unit?: string;
smaller_currency_unit?: string;
numberOfPendingChannels?: number;
}
export interface SelNodeChild {
channelBackupPath?: string;
satsToBTC?: boolean;
}

@ -1,14 +1,3 @@
export interface GetInfoRoot {
identity_pubkey?: string;
alias?: string;
testnet?: boolean;
chains?: GetInfoChain[] | string[];
version?: string;
currency_unit?: string;
smaller_currency_unit?: string;
numberOfPendingChannels?: number;
}
export interface AddressType {
addressId?: string;
addressTp?: string;

@ -10,9 +10,15 @@ import {
PayRequest, ChannelsTransaction, PendingChannels, ClosedChannel, Transaction, SwitchReq, SwitchRes, QueryRoutes
} from '../shared/models/lndModels';
export const RESET_STORE = 'RESET_STORE';
export const CLEAR_EFFECT_ERROR = 'CLEAR_EFFECT_ERROR';
export const EFFECT_ERROR = 'EFFECT_ERROR';
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';
@ -25,8 +31,8 @@ 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_INFO = 'FETCH_INFO';
export const SET_INFO = 'SET_INFO';
export const FETCH_LND_INFO = 'FETCH_LND_INFO';
export const SET_LND_INFO = 'SET_LND_INFO';
export const FETCH_PEERS = 'FETCH_PEERS';
export const SET_PEERS = 'SET_PEERS';
export const SAVE_NEW_PEER = 'SAVE_NEW_PEER';
@ -94,13 +100,33 @@ 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 class ClearEffectError implements Action {
readonly type = CLEAR_EFFECT_ERROR;
export class ClearEffectErrorRoot implements Action {
readonly type = CLEAR_EFFECT_ERROR_ROOT;
constructor(public payload: string) {} // payload = errorAction
}
export class EffectError implements Action {
readonly type = EFFECT_ERROR;
export class EffectErrorRoot implements Action {
readonly type = EFFECT_ERROR_ROOT;
constructor(public payload: ErrorPayload) {}
}
export class ClearEffectErrorLnd implements Action {
readonly type = CLEAR_EFFECT_ERROR_LND;
constructor(public payload: string) {} // payload = errorAction
}
export class EffectErrorLnd implements Action {
readonly type = EFFECT_ERROR_LND;
constructor(public payload: ErrorPayload) {}
}
export class ClearEffectErrorCl implements Action {
readonly type = CLEAR_EFFECT_ERROR_CL;
constructor(public payload: string) {} // payload = errorAction
}
export class EffectErrorCl implements Action {
readonly type = EFFECT_ERROR_CL;
constructor(public payload: ErrorPayload) {}
}
@ -132,11 +158,19 @@ export class CloseConfirmation implements Action {
constructor(public payload: boolean) {}
}
export class ResetStore implements Action {
readonly type = RESET_STORE;
export class ResetRootStore implements Action {
readonly type = RESET_ROOT_STORE;
constructor(public payload: LightningNode) {}
}
export class ResetLNDStore implements Action {
readonly type = RESET_LND_STORE;
}
export class ResetCLStore implements Action {
readonly type = RESET_CL_STORE;
}
export class FetchRTLConfig implements Action {
readonly type = FETCH_RTL_CONFIG;
}
@ -156,12 +190,12 @@ export class SetSelelectedNode implements Action {
constructor(public payload: LightningNode) {}
}
export class FetchInfo implements Action {
readonly type = FETCH_INFO;
export class FetchLndInfo implements Action {
readonly type = FETCH_LND_INFO;
}
export class SetInfo implements Action {
readonly type = SET_INFO;
export class SetLndInfo implements Action {
readonly type = SET_LND_INFO;
constructor(public payload: GetInfo) {}
}
@ -483,10 +517,11 @@ export class SetCLFees implements Action {
}
export type RTLActions =
ClearEffectError | EffectError | OpenSpinner | CloseSpinner |
FetchRTLConfig | SetRTLConfig | SaveSettings |
ClearEffectErrorRoot | EffectErrorRoot | ClearEffectErrorLnd | EffectErrorLnd | ClearEffectErrorCl | EffectErrorCl |
OpenSpinner | CloseSpinner | FetchRTLConfig | SetRTLConfig | SaveSettings |
OpenAlert | CloseAlert | OpenConfirmation | CloseConfirmation |
ResetStore | SetSelelectedNode | FetchInfo | SetInfo |
ResetRootStore | ResetLNDStore | ResetCLStore |
SetSelelectedNode | FetchLndInfo | SetLndInfo |
FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer |
AddInvoice | SaveNewInvoice | GetForwardingHistory | SetForwardingHistory |
FetchFees | SetFees |

File diff suppressed because it is too large Load Diff

@ -1,74 +1,23 @@
import { ActionReducerMap } from '@ngrx/store';
import { ErrorPayload } from '../shared/models/errorPayload';
import { RTLConfiguration, LightningNode } from '../shared/models/RTLconfig';
import {
GetInfoRoot, GetInfo, GetInfoChain, Peer, AddressType, Fees, NetworkInfo, Balance, Channel, Payment, ListInvoices, PendingChannels, ClosedChannel, Transaction, SwitchRes, QueryRoutes
} from '../shared/models/lndModels';
import { RTLConfiguration, LightningNode, GetInfoRoot } from '../shared/models/RTLconfig';
import * as fromCL from '../clightning/store/cl.reducers';
import * as fromLND from '../lnd/store/lnd.reducers';
import * as RTLActions from './rtl.actions';
export interface LNDState {
information: GetInfo;
peers: Peer[];
fees: Fees;
networkInfo: NetworkInfo;
channelBalance: Balance;
blockchainBalance: Balance;
allChannels: Channel[];
closedChannels: ClosedChannel[];
pendingChannels: PendingChannels;
numberOfActiveChannels: number;
numberOfInactiveChannels: number;
numberOfPendingChannels: number;
totalLocalBalance: number;
totalRemoteBalance: number;
totalInvoices: number;
transactions: Transaction[];
payments: Payment[];
invoices: ListInvoices;
forwardingHistory: SwitchRes;
addressTypes: AddressType[];
}
export interface RootState {
effectErrors: ErrorPayload[];
effectErrorsRoot: ErrorPayload[];
selNode: LightningNode;
appConfig: RTLConfiguration;
nodeData: GetInfoRoot
}
const initLNDState: LNDState = {
information: {},
peers: [],
fees: {},
networkInfo: {},
channelBalance: {balance: '', btc_balance: ''},
blockchainBalance: { total_balance: '', btc_total_balance: ''},
allChannels: [],
closedChannels: [],
pendingChannels: {},
numberOfActiveChannels: 0,
numberOfInactiveChannels: 0,
numberOfPendingChannels: -1,
totalLocalBalance: -1,
totalRemoteBalance: -1,
totalInvoices: -1,
transactions: [],
payments: [],
invoices: {invoices: []},
forwardingHistory: {},
addressTypes: [
{ addressId: '0', addressTp: 'p2wkh', addressDetails: 'Pay to witness key hash'},
{ addressId: '1', addressTp: 'np2wkh', addressDetails: 'Pay to nested witness key hash (default)'}
]
}
const initNodeSettings = { flgSidenavOpened: true, flgSidenavPinned: true, menu: 'Vertical', menuType: 'Regular', theme: 'dark-blue', satsToBTC: false };
const initNodeAuthentication = { nodeAuthType: 'CUSTOM', lndConfigPath: '', bitcoindConfigPath: '' };
const initRootState: RootState = {
effectErrors: [],
effectErrorsRoot: [],
selNode: {settings: initNodeSettings, authentication: initNodeAuthentication},
appConfig: {
selectedNodeIndex: -1,
@ -80,9 +29,9 @@ const initRootState: RootState = {
export function RootReducer(state = initRootState, action: RTLActions.RTLActions) {
switch (action.type) {
case RTLActions.CLEAR_EFFECT_ERROR:
const clearedEffectErrors = [...state.effectErrors];
const removeEffectIdx = state.effectErrors.findIndex(err => {
case RTLActions.CLEAR_EFFECT_ERROR_ROOT:
const clearedEffectErrors = [...state.effectErrorsRoot];
const removeEffectIdx = state.effectErrorsRoot.findIndex(err => {
return err.action === action.payload;
});
if (removeEffectIdx > -1) {
@ -92,17 +41,16 @@ export function RootReducer(state = initRootState, action: RTLActions.RTLActions
...state,
effectErrors: clearedEffectErrors
};
case RTLActions.EFFECT_ERROR:
case RTLActions.EFFECT_ERROR_ROOT:
return {
...state,
effectErrors: [...state.effectErrors, action.payload]
effectErrors: [...state.effectErrorsRoot, action.payload]
};
case RTLActions.RESET_STORE:
case RTLActions.RESET_ROOT_STORE:
return {
...initRootState,
appConfig: state.appConfig,
selNode: action.payload,
// cl: initCLState
};
case RTLActions.SET_SELECTED_NODE:
return {
@ -121,201 +69,14 @@ export function RootReducer(state = initRootState, action: RTLActions.RTLActions
}
export function LNDReducer(state = initLNDState, action: RTLActions.RTLActions) {
switch (action.type) {
case RTLActions.SET_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 = <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];
}
return {
...state,
information: action.payload
};
case RTLActions.SET_PEERS:
return {
...state,
peers: action.payload
};
case RTLActions.ADD_PEER:
return {
...state,
peers: [...state.peers, action.payload]
};
case RTLActions.REMOVE_PEER:
const modifiedPeers = [...state.peers];
const removePeerIdx = state.peers.findIndex(peer => {
return peer.pub_key === action.payload.pubkey;
});
if (removePeerIdx > -1) {
modifiedPeers.splice(removePeerIdx, 1);
}
return {
...state,
peers: modifiedPeers
};
case RTLActions.ADD_INVOICE:
const newInvoices = state.invoices;
newInvoices.invoices.unshift(action.payload);
return {
...state,
invoices: newInvoices
};
case RTLActions.SET_FEES:
return {
...state,
fees: action.payload
};
case RTLActions.SET_CLOSED_CHANNELS:
return {
...state,
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,
};
case RTLActions.SET_CHANNELS:
let localBal = 0, remoteBal = 0, activeChannels = 0, inactiveChannels = 0;
if (action.payload) {
action.payload.filter(channel => {
if (undefined !== channel.local_balance) {
localBal = +localBal + +channel.local_balance;
}
if (undefined !== channel.remote_balance) {
remoteBal = +remoteBal + +channel.remote_balance;
}
if (channel.active === true) {
activeChannels = activeChannels + 1;
} else {
inactiveChannels = inactiveChannels + 1;
}
});
}
return {
...state,
allChannels: action.payload,
numberOfActiveChannels: activeChannels,
numberOfInactiveChannels: inactiveChannels,
totalLocalBalance: localBal,
totalRemoteBalance: remoteBal
};
case RTLActions.REMOVE_CHANNEL:
const modifiedChannels = [...state.allChannels];
const removeChannelIdx = state.allChannels.findIndex(channel => {
return channel.channel_point === action.payload.channelPoint;
});
if (removeChannelIdx > -1) {
modifiedChannels.splice(removeChannelIdx, 1);
}
return {
...state,
allChannels: modifiedChannels
};
case RTLActions.SET_BALANCE:
if (action.payload.target === 'channels') {
return {
...state,
channelBalance: action.payload.balance
};
} else {
return {
...state,
blockchainBalance: action.payload.balance
};
}
case RTLActions.SET_NETWORK:
return {
...state,
networkInfo: action.payload
};
case RTLActions.SET_INVOICES:
return {
...state,
invoices: action.payload
};
case RTLActions.SET_TOTAL_INVOICES:
return {
...state,
totalInvoices: action.payload
};
case RTLActions.SET_TRANSACTIONS:
return {
...state,
transactions: action.payload
};
case RTLActions.SET_PAYMENTS:
return {
...state,
payments: action.payload
};
case RTLActions.SET_FORWARDING_HISTORY:
if (action.payload.forwarding_events) {
const storedChannels = [...state.allChannels];
action.payload.forwarding_events.forEach(event => {
if (storedChannels) {
for (let idx = 0; idx < storedChannels.length; idx++) {
if (storedChannels[idx].chan_id.toString() === event.chan_id_in) {
event.alias_in = storedChannels[idx].remote_alias;
if (event.alias_out) { return; }
}
if (storedChannels[idx].chan_id.toString() === event.chan_id_out) {
event.alias_out = storedChannels[idx].remote_alias;
if (event.alias_in) { return; }
}
}
}
});
} else {
action.payload = {};
}
return {
...state,
forwardingHistory: action.payload
};
default:
return state;
}
}
export interface RTLState {
root: RootState;
lnd: LNDState;
lnd: fromLND.LNDState;
cl: fromCL.CLState;
}
export const RTLReducer: ActionReducerMap<RTLState> = {
root: RootReducer,
lnd: LNDReducer,
lnd: fromLND.LNDReducer,
cl: fromCL.CLReducer
};

Loading…
Cancel
Save