|
|
|
@ -1,124 +1,40 @@
|
|
|
|
|
import { Injectable, OnDestroy } from '@angular/core';
|
|
|
|
|
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
|
|
|
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import { Store } from '@ngrx/store';
|
|
|
|
|
import { Actions, Effect, ofType } from '@ngrx/effects';
|
|
|
|
|
import { of, Subject } from 'rxjs';
|
|
|
|
|
import { map, mergeMap, catchError, take, withLatestFrom } from 'rxjs/operators';
|
|
|
|
|
import { map, mergeMap, catchError, withLatestFrom } from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
|
import { MatDialog } from '@angular/material';
|
|
|
|
|
|
|
|
|
|
import { environment } from '../../../environments/environment';
|
|
|
|
|
import { LoggerService } from '../services/logger.service';
|
|
|
|
|
import { Settings } from '../models/RTLconfig';
|
|
|
|
|
import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../models/lndModels';
|
|
|
|
|
import { LoggerService } from '../../shared/services/logger.service';
|
|
|
|
|
import { GetInfo, Fees, Balance, NetworkInfo, Payment, GraphNode, Transaction, SwitchReq, ListInvoices } from '../../shared/models/lndModels';
|
|
|
|
|
|
|
|
|
|
import { SpinnerDialogComponent } from '../components/spinner-dialog/spinner-dialog.component';
|
|
|
|
|
import { AlertMessageComponent } from '../components/alert-message/alert-message.component';
|
|
|
|
|
import { ConfirmationMessageComponent } from '../components/confirmation-message/confirmation-message.component';
|
|
|
|
|
|
|
|
|
|
import * as RTLActions from './rtl.actions';
|
|
|
|
|
import * as fromRTLReducer from './rtl.reducers';
|
|
|
|
|
import * as RTLActions from '../../store/rtl.actions';
|
|
|
|
|
import * as fromRTLReducer from '../../store/rtl.reducers';
|
|
|
|
|
import * as LNDActions from './lnd.actions';
|
|
|
|
|
import * as fromLNDReducer from './lnd.reducers';
|
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class RTLEffects implements OnDestroy {
|
|
|
|
|
export class LNDEffects implements OnDestroy {
|
|
|
|
|
dialogRef: any;
|
|
|
|
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private actions$: Actions,
|
|
|
|
|
private httpClient: HttpClient,
|
|
|
|
|
private store: Store<fromRTLReducer.State>,
|
|
|
|
|
private store: Store<fromLNDReducer.LNDState>,
|
|
|
|
|
private logger: LoggerService,
|
|
|
|
|
public dialog: MatDialog,
|
|
|
|
|
private router: Router) { }
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
openSpinner = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.OPEN_SPINNER),
|
|
|
|
|
map((action: RTLActions.OpenSpinner) => {
|
|
|
|
|
this.dialogRef = this.dialog.open(SpinnerDialogComponent, { data: { titleMessage: action.payload}});
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
closeSpinner = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.CLOSE_SPINNER),
|
|
|
|
|
map((action: RTLActions.CloseSpinner) => {
|
|
|
|
|
if (this.dialogRef) { this.dialogRef.close(); }
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
openAlert = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.OPEN_ALERT),
|
|
|
|
|
map((action: RTLActions.OpenAlert) => {
|
|
|
|
|
this.dialogRef = this.dialog.open(AlertMessageComponent, action.payload);
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
closeAlert = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.CLOSE_ALERT),
|
|
|
|
|
map((action: RTLActions.CloseAlert) => {
|
|
|
|
|
if (this.dialogRef) { this.dialogRef.close(); }
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
openConfirm = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.OPEN_CONFIRMATION),
|
|
|
|
|
map((action: RTLActions.OpenConfirmation) => {
|
|
|
|
|
this.dialogRef = this.dialog.open(ConfirmationMessageComponent, action.payload);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
closeConfirm = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.CLOSE_CONFIRMATION),
|
|
|
|
|
take(1),
|
|
|
|
|
map((action: RTLActions.CloseConfirmation) => {
|
|
|
|
|
this.dialogRef.close();
|
|
|
|
|
this.logger.info(action.payload);
|
|
|
|
|
return action.payload;
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
appConfigFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_RTL_CONFIG),
|
|
|
|
|
mergeMap((action: RTLActions.FetchRTLConfig) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchRTLConfig'));
|
|
|
|
|
return this.httpClient.get(environment.CONF_API + '/rtlconf');
|
|
|
|
|
}),
|
|
|
|
|
map((rtlConfig: any) => {
|
|
|
|
|
this.logger.info(rtlConfig);
|
|
|
|
|
if (+rtlConfig.sso.rtlSSO) { this.store.dispatch(new RTLActions.Signout()); }
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_RTL_CONFIG,
|
|
|
|
|
payload: rtlConfig
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
catchError((err) => {
|
|
|
|
|
this.logger.error(err);
|
|
|
|
|
this.store.dispatch(new RTLActions.EffectError({ action: 'FetchRTLConfig', code: err.status, message: err.error.error }));
|
|
|
|
|
return of();
|
|
|
|
|
})
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
settingSave = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SAVE_SETTINGS),
|
|
|
|
|
mergeMap((action: RTLActions.SaveSettings) => {
|
|
|
|
|
return this.httpClient.post<Settings>(environment.CONF_API, { updatedSettings: action.payload });
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
infoFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_INFO),
|
|
|
|
|
ofType(LNDActions.FETCH_INFO),
|
|
|
|
|
withLatestFrom(this.store.select('rtlRoot')),
|
|
|
|
|
mergeMap(([action, store]: [RTLActions.FetchInfo, fromRTLReducer.State]) => {
|
|
|
|
|
mergeMap(([action, store]: [LNDActions.FetchInfo, fromRTLReducer.State]) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchInfo'));
|
|
|
|
|
return this.httpClient.get<GetInfo>(environment.GETINFO_API)
|
|
|
|
|
.pipe(
|
|
|
|
@ -129,13 +45,13 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.logger.info('Redirecting to Unlock');
|
|
|
|
|
this.router.navigate(['/unlocklnd']);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_INFO,
|
|
|
|
|
type: LNDActions.SET_INFO,
|
|
|
|
|
payload: {}
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
sessionStorage.setItem('lndUnlocked', 'true');
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_INFO,
|
|
|
|
|
type: LNDActions.SET_INFO,
|
|
|
|
|
payload: (undefined !== info) ? info : {}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -163,15 +79,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
peersFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_PEERS),
|
|
|
|
|
mergeMap((action: RTLActions.FetchPeers) => {
|
|
|
|
|
ofType(LNDActions.FETCH_PEERS),
|
|
|
|
|
mergeMap((action: LNDActions.FetchPeers) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchPeers'));
|
|
|
|
|
return this.httpClient.get(environment.PEERS_API)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((peers: any) => {
|
|
|
|
|
this.logger.info(peers);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_PEERS,
|
|
|
|
|
type: LNDActions.SET_PEERS,
|
|
|
|
|
payload: (undefined !== peers) ? peers : []
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -186,8 +102,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
saveNewPeer = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SAVE_NEW_PEER),
|
|
|
|
|
mergeMap((action: RTLActions.SaveNewPeer) => {
|
|
|
|
|
ofType(LNDActions.SAVE_NEW_PEER),
|
|
|
|
|
mergeMap((action: LNDActions.SaveNewPeer) => {
|
|
|
|
|
return this.httpClient.post(environment.PEERS_API, {pubkey: action.payload.pubkey, host: action.payload.host, perm: action.payload.perm})
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
@ -195,7 +111,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: { type: 'SUCCESS', titleMessage: 'Peer Added Successfully!'}}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_PEERS,
|
|
|
|
|
type: LNDActions.SET_PEERS,
|
|
|
|
|
payload: (undefined !== postRes && postRes.length > 0) ? postRes : []
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -217,8 +133,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
detachPeer = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.DETACH_PEER),
|
|
|
|
|
mergeMap((action: RTLActions.DetachPeer) => {
|
|
|
|
|
ofType(LNDActions.DETACH_PEER),
|
|
|
|
|
mergeMap((action: LNDActions.DetachPeer) => {
|
|
|
|
|
return this.httpClient.delete(environment.PEERS_API + '/' + action.payload.pubkey)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
@ -226,7 +142,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: {type: 'SUCCESS', titleMessage: 'Peer Detached Successfully!'}}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.REMOVE_PEER,
|
|
|
|
|
type: LNDActions.REMOVE_PEER,
|
|
|
|
|
payload: { pubkey: action.payload.pubkey }
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -248,8 +164,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
saveNewInvoice = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SAVE_NEW_INVOICE),
|
|
|
|
|
mergeMap((action: RTLActions.SaveNewInvoice) => {
|
|
|
|
|
ofType(LNDActions.SAVE_NEW_INVOICE),
|
|
|
|
|
mergeMap((action: LNDActions.SaveNewInvoice) => {
|
|
|
|
|
return this.httpClient.post(environment.INVOICES_API, {
|
|
|
|
|
memo: action.payload.memo, amount: action.payload.invoiceValue, private: action.payload.private, expiry: action.payload.expiry
|
|
|
|
|
})
|
|
|
|
@ -267,7 +183,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%',
|
|
|
|
|
data: { type: 'SUCCESS', titleMessage: 'Invoice Added Successfully!', message: JSON.stringify(msg) }}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.FETCH_INVOICES,
|
|
|
|
|
type: LNDActions.FETCH_INVOICES,
|
|
|
|
|
payload: {num_max_invoices: action.payload.pageSize, reversed: true}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -289,8 +205,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
openNewChannel = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SAVE_NEW_CHANNEL),
|
|
|
|
|
mergeMap((action: RTLActions.SaveNewChannel) => {
|
|
|
|
|
ofType(LNDActions.SAVE_NEW_CHANNEL),
|
|
|
|
|
mergeMap((action: LNDActions.SaveNewChannel) => {
|
|
|
|
|
return this.httpClient.post(environment.CHANNELS_API, {
|
|
|
|
|
node_pubkey: action.payload.selectedPeerPubkey, local_funding_amount: action.payload.fundingAmount, private: action.payload.private,
|
|
|
|
|
trans_type: action.payload.transType, trans_type_value: action.payload.transTypeValue, spend_unconfirmed: action.payload.spendUnconfirmed
|
|
|
|
@ -299,11 +215,11 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchBalance('blockchain'));
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'all'}));
|
|
|
|
|
this.store.dispatch(new RTLActions.BackupChannels({channelPoint: 'ALL', showMessage: 'Channel Added Successfully!'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchBalance('blockchain'));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchChannels({routeParam: 'all'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.BackupChannels({channelPoint: 'ALL', showMessage: 'Channel Added Successfully!'}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.FETCH_CHANNELS,
|
|
|
|
|
type: LNDActions.FETCH_CHANNELS,
|
|
|
|
|
payload: {routeParam: 'pending', channelStatus: ''}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -325,8 +241,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
updateChannel = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.UPDATE_CHANNELS),
|
|
|
|
|
mergeMap((action: RTLActions.UpdateChannels) => {
|
|
|
|
|
ofType(LNDActions.UPDATE_CHANNELS),
|
|
|
|
|
mergeMap((action: LNDActions.UpdateChannels) => {
|
|
|
|
|
return this.httpClient.post(environment.CHANNELS_API + '/chanPolicy',
|
|
|
|
|
{ baseFeeMsat: action.payload.baseFeeMsat, feeRate: action.payload.feeRate, timeLockDelta: action.payload.timeLockDelta, chanPoint: action.payload.chanPoint })
|
|
|
|
|
.pipe(
|
|
|
|
@ -335,7 +251,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: {type: 'SUCCESS', titleMessage: 'Channel Updated Successfully!'}}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.FETCH_CHANNELS,
|
|
|
|
|
type: LNDActions.FETCH_CHANNELS,
|
|
|
|
|
payload: {routeParam: 'all', channelStatus: ''}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -357,24 +273,24 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
closeChannel = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.CLOSE_CHANNEL),
|
|
|
|
|
mergeMap((action: RTLActions.CloseChannel) => {
|
|
|
|
|
ofType(LNDActions.CLOSE_CHANNEL),
|
|
|
|
|
mergeMap((action: LNDActions.CloseChannel) => {
|
|
|
|
|
return this.httpClient.delete(environment.CHANNELS_API + '/' + action.payload.channelPoint + '?force=' + action.payload.forcibly)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchBalance('channels'));
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchBalance('blockchain'));
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'all'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchBalance('channels'));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchBalance('blockchain'));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchChannels({routeParam: 'all'}));
|
|
|
|
|
if (action.payload.forcibly) {
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'pending'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchChannels({routeParam: 'pending'}));
|
|
|
|
|
} else {
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'closed'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchChannels({routeParam: 'closed'}));
|
|
|
|
|
}
|
|
|
|
|
this.store.dispatch(new RTLActions.BackupChannels({channelPoint: 'ALL', showMessage: 'Channel Closed Successfully!'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.BackupChannels({channelPoint: 'ALL', showMessage: 'Channel Closed Successfully!'}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.REMOVE_CHANNEL,
|
|
|
|
|
type: LNDActions.REMOVE_CHANNEL,
|
|
|
|
|
payload: { channelPoint: action.payload.channelPoint }
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -395,8 +311,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
backupChannels = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.BACKUP_CHANNELS),
|
|
|
|
|
mergeMap((action: RTLActions.BackupChannels) => {
|
|
|
|
|
ofType(LNDActions.BACKUP_CHANNELS),
|
|
|
|
|
mergeMap((action: LNDActions.BackupChannels) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('BackupChannels'));
|
|
|
|
|
return this.httpClient.get(environment.CHANNELS_BACKUP_API + '/' + action.payload.channelPoint)
|
|
|
|
|
.pipe(
|
|
|
|
@ -405,7 +321,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: {type: 'SUCCESS', titleMessage: action.payload.showMessage + ' ' + postRes.message}}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.BACKUP_CHANNELS_RES,
|
|
|
|
|
type: LNDActions.BACKUP_CHANNELS_RES,
|
|
|
|
|
payload: postRes.message
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -427,8 +343,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
verifyChannels = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.VERIFY_CHANNELS),
|
|
|
|
|
mergeMap((action: RTLActions.VerifyChannels) => {
|
|
|
|
|
ofType(LNDActions.VERIFY_CHANNELS),
|
|
|
|
|
mergeMap((action: LNDActions.VerifyChannels) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('VerifyChannels'));
|
|
|
|
|
return this.httpClient.post(environment.CHANNELS_BACKUP_API + '/verify/' + action.payload.channelPoint, {})
|
|
|
|
|
.pipe(
|
|
|
|
@ -437,7 +353,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: {type: 'SUCCESS', titleMessage: postRes.message}}));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.VERIFY_CHANNELS_RES,
|
|
|
|
|
type: LNDActions.VERIFY_CHANNELS_RES,
|
|
|
|
|
payload: postRes.message
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -459,15 +375,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
fetchFees = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_FEES),
|
|
|
|
|
mergeMap((action: RTLActions.FetchFees) => {
|
|
|
|
|
ofType(LNDActions.FETCH_FEES),
|
|
|
|
|
mergeMap((action: LNDActions.FetchFees) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchFees'));
|
|
|
|
|
return this.httpClient.get<Fees>(environment.FEES_API);
|
|
|
|
|
}),
|
|
|
|
|
map((fees) => {
|
|
|
|
|
this.logger.info(fees);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_FEES,
|
|
|
|
|
type: LNDActions.SET_FEES,
|
|
|
|
|
payload: (undefined !== fees) ? fees : {}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -480,19 +396,19 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
balanceFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_BALANCE),
|
|
|
|
|
mergeMap((action: RTLActions.FetchBalance) => {
|
|
|
|
|
ofType(LNDActions.FETCH_BALANCE),
|
|
|
|
|
mergeMap((action: LNDActions.FetchBalance) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchBalance/' + action.payload));
|
|
|
|
|
return this.httpClient.get<Balance>(environment.BALANCE_API + '/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((res: any) => {
|
|
|
|
|
if (action.payload === 'channels') {
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchBalance('blockchain'));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchBalance('blockchain'));
|
|
|
|
|
}
|
|
|
|
|
this.logger.info(res);
|
|
|
|
|
const emptyRes = (action.payload === 'channels') ? {balance: '', btc_balance: ''} : {total_balance: '', btc_total_balance: ''};
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_BALANCE,
|
|
|
|
|
type: LNDActions.SET_BALANCE,
|
|
|
|
|
payload: (undefined !== res) ? { target: action.payload, balance: res } : { target: action.payload, balance: emptyRes }
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -507,15 +423,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
networkInfoFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_NETWORK),
|
|
|
|
|
mergeMap((action: RTLActions.FetchNetwork) => {
|
|
|
|
|
ofType(LNDActions.FETCH_NETWORK),
|
|
|
|
|
mergeMap((action: LNDActions.FetchNetwork) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchNetwork'));
|
|
|
|
|
return this.httpClient.get<NetworkInfo>(environment.NETWORK_API + '/info');
|
|
|
|
|
}),
|
|
|
|
|
map((networkInfo) => {
|
|
|
|
|
this.logger.info(networkInfo);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_NETWORK,
|
|
|
|
|
type: LNDActions.SET_NETWORK,
|
|
|
|
|
payload: (undefined !== networkInfo) ? networkInfo : {}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -528,25 +444,25 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
channelsFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_CHANNELS),
|
|
|
|
|
mergeMap((action: RTLActions.FetchChannels) => {
|
|
|
|
|
ofType(LNDActions.FETCH_CHANNELS),
|
|
|
|
|
mergeMap((action: LNDActions.FetchChannels) => {
|
|
|
|
|
return this.httpClient.get(environment.CHANNELS_API + '/' + action.payload.routeParam)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((channels: any) => {
|
|
|
|
|
this.logger.info(channels);
|
|
|
|
|
if (action.payload.routeParam === 'pending') {
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_PENDING_CHANNELS,
|
|
|
|
|
type: LNDActions.SET_PENDING_CHANNELS,
|
|
|
|
|
payload: (undefined !== channels) ? channels : {}
|
|
|
|
|
};
|
|
|
|
|
} else if (action.payload.routeParam === 'closed') {
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_CLOSED_CHANNELS,
|
|
|
|
|
type: LNDActions.SET_CLOSED_CHANNELS,
|
|
|
|
|
payload: (undefined !== channels && undefined !== channels.channels && channels.channels.length > 0) ? channels.channels : []
|
|
|
|
|
};
|
|
|
|
|
} else if (action.payload.routeParam === 'all') {
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_CHANNELS,
|
|
|
|
|
type: LNDActions.SET_CHANNELS,
|
|
|
|
|
payload: (undefined !== channels && undefined !== channels.channels && channels.channels.length > 0) ? channels.channels : []
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -562,8 +478,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
invoicesFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_INVOICES),
|
|
|
|
|
mergeMap((action: RTLActions.FetchInvoices) => {
|
|
|
|
|
ofType(LNDActions.FETCH_INVOICES),
|
|
|
|
|
mergeMap((action: LNDActions.FetchInvoices) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchInvoices'));
|
|
|
|
|
const num_max_invoices = (action.payload.num_max_invoices) ? action.payload.num_max_invoices : 100;
|
|
|
|
|
const index_offset = (action.payload.index_offset) ? action.payload.index_offset : 0;
|
|
|
|
@ -572,10 +488,10 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
.pipe(map((res: ListInvoices) => {
|
|
|
|
|
this.logger.info(res);
|
|
|
|
|
if (action.payload.reversed && !action.payload.index_offset) {
|
|
|
|
|
this.store.dispatch(new RTLActions.SetTotalInvoices(+res.last_index_offset));
|
|
|
|
|
this.store.dispatch(new LNDActions.SetTotalInvoices(+res.last_index_offset));
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_INVOICES,
|
|
|
|
|
type: LNDActions.SET_INVOICES,
|
|
|
|
|
payload: res
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -589,15 +505,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
transactionsFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_TRANSACTIONS),
|
|
|
|
|
mergeMap((action: RTLActions.FetchTransactions) => {
|
|
|
|
|
ofType(LNDActions.FETCH_TRANSACTIONS),
|
|
|
|
|
mergeMap((action: LNDActions.FetchTransactions) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchTransactions'));
|
|
|
|
|
return this.httpClient.get<Transaction[]>(environment.TRANSACTIONS_API);
|
|
|
|
|
}),
|
|
|
|
|
map((transactions) => {
|
|
|
|
|
this.logger.info(transactions);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_TRANSACTIONS,
|
|
|
|
|
type: LNDActions.SET_TRANSACTIONS,
|
|
|
|
|
payload: (undefined !== transactions && transactions.length > 0) ? transactions : []
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -610,15 +526,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
paymentsFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_PAYMENTS),
|
|
|
|
|
mergeMap((action: RTLActions.FetchPayments) => {
|
|
|
|
|
ofType(LNDActions.FETCH_PAYMENTS),
|
|
|
|
|
mergeMap((action: LNDActions.FetchPayments) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('FetchPayments'));
|
|
|
|
|
return this.httpClient.get<Payment[]>(environment.PAYMENTS_API);
|
|
|
|
|
}),
|
|
|
|
|
map((payments) => {
|
|
|
|
|
this.logger.info(payments);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_PAYMENTS,
|
|
|
|
|
type: LNDActions.SET_PAYMENTS,
|
|
|
|
|
payload: (undefined !== payments && null != payments) ? payments : []
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -631,15 +547,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
decodePayment = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.DECODE_PAYMENT),
|
|
|
|
|
mergeMap((action: RTLActions.DecodePayment) => {
|
|
|
|
|
ofType(LNDActions.DECODE_PAYMENT),
|
|
|
|
|
mergeMap((action: LNDActions.DecodePayment) => {
|
|
|
|
|
return this.httpClient.get(environment.PAYREQUEST_API + '/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((decodedPayment) => {
|
|
|
|
|
this.logger.info(decodedPayment);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_DECODED_PAYMENT,
|
|
|
|
|
type: LNDActions.SET_DECODED_PAYMENT,
|
|
|
|
|
payload: (undefined !== decodedPayment) ? decodedPayment : {}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -660,8 +576,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
setDecodedPayment = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_DECODED_PAYMENT),
|
|
|
|
|
map((action: RTLActions.SetDecodedPayment) => {
|
|
|
|
|
ofType(LNDActions.SET_DECODED_PAYMENT),
|
|
|
|
|
map((action: LNDActions.SetDecodedPayment) => {
|
|
|
|
|
this.logger.info(action.payload);
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
@ -669,9 +585,9 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
sendPayment = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SEND_PAYMENT),
|
|
|
|
|
ofType(LNDActions.SEND_PAYMENT),
|
|
|
|
|
withLatestFrom(this.store.select('rtlRoot')),
|
|
|
|
|
mergeMap(([action, store]: [RTLActions.SendPayment, fromRTLReducer.State]) => {
|
|
|
|
|
mergeMap(([action, store]: [LNDActions.SendPayment, fromLNDReducer.LNDState]) => {
|
|
|
|
|
let queryHeaders = {};
|
|
|
|
|
if (action.payload[2]) {
|
|
|
|
|
queryHeaders = {paymentDecoded: action.payload[1]};
|
|
|
|
@ -703,11 +619,11 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
Object.assign(msg, confirmationMsg);
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%',
|
|
|
|
|
data: { type: 'SUCCESS', titleMessage: 'Payment Sent Successfully!', message: JSON.stringify(msg) }}));
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchChannels({routeParam: 'all'}));
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchBalance('channels'));
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchPayments());
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchChannels({routeParam: 'all'}));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchBalance('channels'));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchPayments());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_DECODED_PAYMENT,
|
|
|
|
|
type: LNDActions.SET_DECODED_PAYMENT,
|
|
|
|
|
payload: {}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -729,14 +645,14 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
graphNodeFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_GRAPH_NODE),
|
|
|
|
|
mergeMap((action: RTLActions.FetchGraphNode) => {
|
|
|
|
|
ofType(LNDActions.FETCH_GRAPH_NODE),
|
|
|
|
|
mergeMap((action: LNDActions.FetchGraphNode) => {
|
|
|
|
|
return this.httpClient.get<GraphNode>(environment.NETWORK_API + '/node/' + action.payload)
|
|
|
|
|
.pipe(map((graphNode: any) => {
|
|
|
|
|
this.logger.info(graphNode);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_GRAPH_NODE,
|
|
|
|
|
type: LNDActions.SET_GRAPH_NODE,
|
|
|
|
|
payload: (undefined !== graphNode) ? graphNode : {}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -756,8 +672,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
setGraphNode = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_GRAPH_NODE),
|
|
|
|
|
map((action: RTLActions.SetGraphNode) => {
|
|
|
|
|
ofType(LNDActions.SET_GRAPH_NODE),
|
|
|
|
|
map((action: LNDActions.SetGraphNode) => {
|
|
|
|
|
this.logger.info(action.payload);
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
@ -765,14 +681,14 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
getNewAddress = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.GET_NEW_ADDRESS),
|
|
|
|
|
mergeMap((action: RTLActions.GetNewAddress) => {
|
|
|
|
|
ofType(LNDActions.GET_NEW_ADDRESS),
|
|
|
|
|
mergeMap((action: LNDActions.GetNewAddress) => {
|
|
|
|
|
return this.httpClient.get(environment.NEW_ADDRESS_API + '?type=' + action.payload.addressId)
|
|
|
|
|
.pipe(map((newAddress: any) => {
|
|
|
|
|
this.logger.info(newAddress);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_NEW_ADDRESS,
|
|
|
|
|
type: LNDActions.SET_NEW_ADDRESS,
|
|
|
|
|
payload: (undefined !== newAddress && undefined !== newAddress.address) ? newAddress.address : {}
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -792,8 +708,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
setNewAddress = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_NEW_ADDRESS),
|
|
|
|
|
map((action: RTLActions.SetNewAddress) => {
|
|
|
|
|
ofType(LNDActions.SET_NEW_ADDRESS),
|
|
|
|
|
map((action: LNDActions.SetNewAddress) => {
|
|
|
|
|
this.logger.info(action.payload);
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
@ -801,15 +717,15 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
configFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.FETCH_CONFIG),
|
|
|
|
|
mergeMap((action: RTLActions.FetchConfig) => {
|
|
|
|
|
ofType(LNDActions.FETCH_CONFIG),
|
|
|
|
|
mergeMap((action: LNDActions.FetchConfig) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('fetchConfig'));
|
|
|
|
|
return this.httpClient.get(environment.CONF_API + '/config/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((configFile: any) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SHOW_CONFIG,
|
|
|
|
|
type: LNDActions.SHOW_CONFIG,
|
|
|
|
|
payload: configFile
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -831,16 +747,16 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
showLNDConfig = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SHOW_CONFIG),
|
|
|
|
|
map((action: RTLActions.ShowConfig) => {
|
|
|
|
|
ofType(LNDActions.SHOW_CONFIG),
|
|
|
|
|
map((action: LNDActions.ShowConfig) => {
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
SetChannelTransaction = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_CHANNEL_TRANSACTION),
|
|
|
|
|
mergeMap((action: RTLActions.SetChannelTransaction) => {
|
|
|
|
|
ofType(LNDActions.SET_CHANNEL_TRANSACTION),
|
|
|
|
|
mergeMap((action: LNDActions.SetChannelTransaction) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('SetChannelTransaction'));
|
|
|
|
|
return this.httpClient.post(environment.TRANSACTIONS_API,
|
|
|
|
|
{ amount: action.payload.amount, address: action.payload.address, sendAll: action.payload.sendAll, fees: action.payload.fees, blocks: action.payload.blocks }
|
|
|
|
@ -849,7 +765,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.FetchBalance('blockchain'));
|
|
|
|
|
this.store.dispatch(new LNDActions.FetchBalance('blockchain'));
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.OPEN_ALERT,
|
|
|
|
|
payload: { data: {type: 'SUCCESS', titleMessage: 'Fund Sent Successfully!'} }
|
|
|
|
@ -872,8 +788,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
fetchForwardingHistory = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.GET_FORWARDING_HISTORY),
|
|
|
|
|
mergeMap((action: RTLActions.GetForwardingHistory) => {
|
|
|
|
|
ofType(LNDActions.GET_FORWARDING_HISTORY),
|
|
|
|
|
mergeMap((action: LNDActions.GetForwardingHistory) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('GetForwardingHistory'));
|
|
|
|
|
const queryHeaders: SwitchReq = {
|
|
|
|
|
num_max_events: action.payload.num_max_events, index_offset: action.payload.index_offset, end_time: action.payload.end_time , start_time: action.payload.start_time
|
|
|
|
@ -883,7 +799,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
map((fhRes: any) => {
|
|
|
|
|
this.logger.info(fhRes);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_FORWARDING_HISTORY,
|
|
|
|
|
type: LNDActions.SET_FORWARDING_HISTORY,
|
|
|
|
|
payload: fhRes
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -904,19 +820,19 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
queryRoutesFetch = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.GET_QUERY_ROUTES),
|
|
|
|
|
mergeMap((action: RTLActions.GetQueryRoutes) => {
|
|
|
|
|
ofType(LNDActions.GET_QUERY_ROUTES),
|
|
|
|
|
mergeMap((action: LNDActions.GetQueryRoutes) => {
|
|
|
|
|
return this.httpClient.get(environment.NETWORK_API + '/routes/' + action.payload.destPubkey + '/' + action.payload.amount)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((qrRes: any) => {
|
|
|
|
|
this.logger.info(qrRes);
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_QUERY_ROUTES,
|
|
|
|
|
type: LNDActions.SET_QUERY_ROUTES,
|
|
|
|
|
payload: qrRes
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
catchError((err: any) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.SetQueryRoutes({}));
|
|
|
|
|
this.store.dispatch(new LNDActions.SetQueryRoutes({}));
|
|
|
|
|
this.logger.error(err);
|
|
|
|
|
return of(
|
|
|
|
|
{
|
|
|
|
@ -932,16 +848,16 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
setQueryRoutes = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_QUERY_ROUTES),
|
|
|
|
|
map((action: RTLActions.SetQueryRoutes) => {
|
|
|
|
|
ofType(LNDActions.SET_QUERY_ROUTES),
|
|
|
|
|
map((action: LNDActions.SetQueryRoutes) => {
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
genSeed = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.GEN_SEED),
|
|
|
|
|
mergeMap((action: RTLActions.GenSeed) => {
|
|
|
|
|
ofType(LNDActions.GEN_SEED),
|
|
|
|
|
mergeMap((action: LNDActions.GenSeed) => {
|
|
|
|
|
return this.httpClient.get(environment.WALLET_API + '/genseed/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
@ -949,7 +865,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.GEN_SEED_RESPONSE,
|
|
|
|
|
type: LNDActions.GEN_SEED_RESPONSE,
|
|
|
|
|
payload: postRes.cipher_seed_mnemonic
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -965,24 +881,24 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
genSeedResponse = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.GEN_SEED_RESPONSE),
|
|
|
|
|
map((action: RTLActions.GenSeedResponse) => {
|
|
|
|
|
ofType(LNDActions.GEN_SEED_RESPONSE),
|
|
|
|
|
map((action: LNDActions.GenSeedResponse) => {
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
initWalletRes = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.INIT_WALLET_RESPONSE),
|
|
|
|
|
map((action: RTLActions.InitWalletResponse) => {
|
|
|
|
|
ofType(LNDActions.INIT_WALLET_RESPONSE),
|
|
|
|
|
map((action: LNDActions.InitWalletResponse) => {
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
initWallet = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.INIT_WALLET),
|
|
|
|
|
mergeMap((action: RTLActions.InitWallet) => {
|
|
|
|
|
ofType(LNDActions.INIT_WALLET),
|
|
|
|
|
mergeMap((action: LNDActions.InitWallet) => {
|
|
|
|
|
return this.httpClient.post(environment.WALLET_API + '/initwallet',
|
|
|
|
|
{ wallet_password: action.payload.pwd,
|
|
|
|
|
cipher_seed_mnemonic: action.payload.cipher ? action.payload.cipher : '',
|
|
|
|
@ -992,7 +908,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.INIT_WALLET_RESPONSE,
|
|
|
|
|
type: LNDActions.INIT_WALLET_RESPONSE,
|
|
|
|
|
payload: postRes
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -1008,8 +924,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch : false })
|
|
|
|
|
unlockWallet = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.UNLOCK_WALLET),
|
|
|
|
|
mergeMap((action: RTLActions.UnlockWallet) => {
|
|
|
|
|
ofType(LNDActions.UNLOCK_WALLET),
|
|
|
|
|
mergeMap((action: LNDActions.UnlockWallet) => {
|
|
|
|
|
return this.httpClient.post(environment.WALLET_API + '/unlockwallet', { wallet_password: action.payload.pwd })
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes) => {
|
|
|
|
@ -1036,92 +952,10 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
isAuthorized = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.IS_AUTHORIZED),
|
|
|
|
|
withLatestFrom(this.store.select('rtlRoot')),
|
|
|
|
|
mergeMap(([action, store]: [RTLActions.IsAuthorized, fromRTLReducer.State]) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('IsAuthorized'));
|
|
|
|
|
return this.httpClient.post(environment.AUTHENTICATE_API, { password: action.payload })
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.logger.info('Successfully Authorized!');
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.IS_AUTHORIZED_RES,
|
|
|
|
|
payload: postRes
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
|
catchError((err) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: {type: 'ERROR', titleMessage: 'Authorization Failed',
|
|
|
|
|
message: JSON.stringify({Code: err.status, Message: err.error.error})}}));
|
|
|
|
|
this.store.dispatch(new RTLActions.EffectError({ action: 'IsAuthorized', code: err.status, message: err.error.message }));
|
|
|
|
|
this.logger.error(err.error);
|
|
|
|
|
return of({
|
|
|
|
|
type: RTLActions.IS_AUTHORIZED_RES,
|
|
|
|
|
payload: 'ERROR'
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
isAuthorizedRes = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.IS_AUTHORIZED_RES),
|
|
|
|
|
map((action: RTLActions.IsAuthorizedRes) => {
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
authSignin = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SIGNIN),
|
|
|
|
|
withLatestFrom(this.store.select('rtlRoot')),
|
|
|
|
|
mergeMap(([action, store]: [RTLActions.Signin, fromRTLReducer.State]) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('Signin'));
|
|
|
|
|
return this.httpClient.post(environment.AUTHENTICATE_API, { password: action.payload })
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.logger.info('Successfully Authorized!');
|
|
|
|
|
this.SetToken(postRes.token);
|
|
|
|
|
this.router.navigate(['/']);
|
|
|
|
|
}),
|
|
|
|
|
catchError((err) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.OpenAlert({ width: '70%', data: {type: 'ERROR', message: JSON.stringify(err.error)}}));
|
|
|
|
|
this.store.dispatch(new RTLActions.EffectError({ action: 'Signin', code: err.status, message: err.error.message }));
|
|
|
|
|
this.logger.error(err.error);
|
|
|
|
|
this.logger.info('Redirecting to Signin Error Page');
|
|
|
|
|
if (+store.appConfig.sso.rtlSSO) {
|
|
|
|
|
this.router.navigate(['/ssoerror']);
|
|
|
|
|
} else {
|
|
|
|
|
this.router.navigate([store.appConfig.sso.logoutRedirectLink]);
|
|
|
|
|
}
|
|
|
|
|
return of();
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
signOut = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SIGNOUT),
|
|
|
|
|
withLatestFrom(this.store.select('rtlRoot')),
|
|
|
|
|
mergeMap(([action, store]: [RTLActions.Signout, fromRTLReducer.State]) => {
|
|
|
|
|
if (+store.appConfig.sso.rtlSSO) {
|
|
|
|
|
window.location.href = store.appConfig.sso.logoutRedirectLink;
|
|
|
|
|
} else {
|
|
|
|
|
this.router.navigate([store.appConfig.sso.logoutRedirectLink]);
|
|
|
|
|
}
|
|
|
|
|
sessionStorage.removeItem('lndUnlocked');
|
|
|
|
|
sessionStorage.removeItem('token');
|
|
|
|
|
this.logger.warn('LOGGED OUT');
|
|
|
|
|
return of();
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
peerLookup = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.PEER_LOOKUP),
|
|
|
|
|
mergeMap((action: RTLActions.PeerLookup) => {
|
|
|
|
|
ofType(LNDActions.PEER_LOOKUP),
|
|
|
|
|
mergeMap((action: LNDActions.PeerLookup) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('Lookup'));
|
|
|
|
|
return this.httpClient.get(environment.NETWORK_API + '/node/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
@ -1129,7 +963,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.logger.info(resPeer);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_LOOKUP,
|
|
|
|
|
type: LNDActions.SET_LOOKUP,
|
|
|
|
|
payload: resPeer
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -1151,8 +985,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
channelLookup = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.CHANNEL_LOOKUP),
|
|
|
|
|
mergeMap((action: RTLActions.ChannelLookup) => {
|
|
|
|
|
ofType(LNDActions.CHANNEL_LOOKUP),
|
|
|
|
|
mergeMap((action: LNDActions.ChannelLookup) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('Lookup'));
|
|
|
|
|
return this.httpClient.get(environment.NETWORK_API + '/edge/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
@ -1160,7 +994,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.logger.info(resChannel);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_LOOKUP,
|
|
|
|
|
type: LNDActions.SET_LOOKUP,
|
|
|
|
|
payload: resChannel
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -1182,8 +1016,8 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
invoiceLookup = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.INVOICE_LOOKUP),
|
|
|
|
|
mergeMap((action: RTLActions.InvoiceLookup) => {
|
|
|
|
|
ofType(LNDActions.INVOICE_LOOKUP),
|
|
|
|
|
mergeMap((action: LNDActions.InvoiceLookup) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('Lookup'));
|
|
|
|
|
return this.httpClient.get(environment.INVOICES_API + '/' + action.payload)
|
|
|
|
|
.pipe(
|
|
|
|
@ -1191,7 +1025,7 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
this.logger.info(resInvoice);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.SET_LOOKUP,
|
|
|
|
|
type: LNDActions.SET_LOOKUP,
|
|
|
|
|
payload: resInvoice
|
|
|
|
|
};
|
|
|
|
|
}),
|
|
|
|
@ -1213,61 +1047,13 @@ export class RTLEffects implements OnDestroy {
|
|
|
|
|
|
|
|
|
|
@Effect({ dispatch: false })
|
|
|
|
|
setLookup = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_LOOKUP),
|
|
|
|
|
map((action: RTLActions.SetLookup) => {
|
|
|
|
|
ofType(LNDActions.SET_LOOKUP),
|
|
|
|
|
map((action: LNDActions.SetLookup) => {
|
|
|
|
|
this.logger.info(action.payload);
|
|
|
|
|
return action.payload;
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@Effect()
|
|
|
|
|
setSelectedNode = this.actions$.pipe(
|
|
|
|
|
ofType(RTLActions.SET_SELECTED_NODE),
|
|
|
|
|
mergeMap((action: RTLActions.SetSelelectedNode) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.ClearEffectError('UpdateSelNode'));
|
|
|
|
|
return this.httpClient.post(environment.CONF_API + '/updateSelNode', { selNodeIndex: action.payload.index })
|
|
|
|
|
.pipe(
|
|
|
|
|
map((postRes: any) => {
|
|
|
|
|
this.logger.info(postRes);
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
if (sessionStorage.getItem('token')) {
|
|
|
|
|
this.store.dispatch(new RTLActions.ResetStore(action.payload));
|
|
|
|
|
return { type: RTLActions.FETCH_INFO };
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
type: RTLActions.OPEN_ALERT,
|
|
|
|
|
payload: { width: '70%', data: {type: 'WARN', titleMessage: 'Authorization required to get the data from the node!' }}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
catchError((err: any) => {
|
|
|
|
|
this.store.dispatch(new RTLActions.CloseSpinner());
|
|
|
|
|
this.store.dispatch(new RTLActions.EffectError({ action: 'UpdateSelNode', code: err.status, message: err.error.message }));
|
|
|
|
|
this.logger.error(err);
|
|
|
|
|
return of(
|
|
|
|
|
{
|
|
|
|
|
type: RTLActions.OPEN_ALERT,
|
|
|
|
|
payload: { width: '70%', data: {type: 'ERROR', titleMessage: 'Update Selected Node Failed!',
|
|
|
|
|
message: JSON.stringify({code: err.status, Message: err.error.error})
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
SetToken(token: string) {
|
|
|
|
|
if (token) {
|
|
|
|
|
sessionStorage.setItem('lndUnlocked', 'true');
|
|
|
|
|
sessionStorage.setItem('token', token);
|
|
|
|
|
this.store.dispatch(new RTLActions.InitAppData());
|
|
|
|
|
} else {
|
|
|
|
|
sessionStorage.removeItem('lndUnlocked');
|
|
|
|
|
sessionStorage.removeItem('token');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.unSubs.forEach(completeSub => {
|
|
|
|
|
completeSub.next();
|