CLT Show the output lists on the On-chain section #403 (#411)

CLT Show the output lists on the On-chain section #403
pull/412/head
ShahanaFarooqui 4 years ago committed by GitHub
parent d953277d83
commit 541e47b6e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -15,5 +15,5 @@
<link rel="stylesheet" href="styles.7f0a84d9b012559f3600.css"></head>
<body>
<rtl-app></rtl-app>
<script src="runtime.bf05d1e7c7c02adb590a.js" defer></script><script src="polyfills-es5.2ac0d98b22574ae745b1.js" nomodule defer></script><script src="polyfills.5ae721a6ae5ab597a53d.js" defer></script><script src="main.b8f2d68b405ae61b3eda.js" defer></script></body>
<script src="runtime.883b3a6dfe95a55cd677.js" defer></script><script src="polyfills-es5.2ac0d98b22574ae745b1.js" nomodule defer></script><script src="polyfills.5ae721a6ae5ab597a53d.js" defer></script><script src="main.930629deff965c22cb1b.js" defer></script></body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
!function(e){function r(r){for(var n,a,i=r[0],f=r[1],c=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,c||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"9bb271dd8dffd2d994a5",6:"7fdbfcfcbc66f0a2e343",7:"8bea433e66622a5b697f",8:"cb92f279297c13fff1d8"}[e]+".js"}(e);var f=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(c);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;f.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",f.name="ChunkLoadError",f.type=n,f.request=u,t[1](f)}o[e]=void 0}};var c=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],f=i.push.bind(i);i.push=r,i=i.slice();for(var c=0;c<i.length;c++)r(i[c]);var l=f;t()}([]);
!function(e){function r(r){for(var n,a,i=r[0],f=r[1],c=r[2],p=0,s=[];p<i.length;p++)a=i[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(l&&l(r);s.length;)s.shift()();return u.push.apply(u,c||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++)0!==o[t[i]]&&(n=!1);n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={0:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var u,i=document.createElement("script");i.charset="utf-8",i.timeout=120,a.nc&&i.setAttribute("nonce",a.nc),i.src=function(e){return a.p+""+({}[e]||e)+"."+{1:"9bb271dd8dffd2d994a5",6:"f4a00973b8204a828cfd",7:"8bea433e66622a5b697f",8:"cb92f279297c13fff1d8"}[e]+".js"}(e);var f=new Error;u=function(r){i.onerror=i.onload=null,clearTimeout(c);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),u=r&&r.target&&r.target.src;f.message="Loading chunk "+e+" failed.\n("+n+": "+u+")",f.name="ChunkLoadError",f.type=n,f.request=u,t[1](f)}o[e]=void 0}};var c=setTimeout((function(){u({type:"timeout",target:i})}),12e4);i.onerror=i.onload=u,document.head.appendChild(i)}return Promise.all(r)},a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,(function(r){return e[r]}).bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="",a.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],f=i.push.bind(i);i.push=r,i=i.slice();for(var c=0;c<i.length;c++)r(i[c]);var l=f;t()}([]);

@ -57,3 +57,24 @@ exports.onChainWithdraw = (req, res, next) => {
});
});
}
exports.getTransactions = (req, res, next) => {
options = common.getOptions();
options.url = common.getSelLNServerUrl() + '/listFunds';
request(options).then((body) => {
res.status(200).json(body);
}).catch(errRes => {
let err = JSON.parse(JSON.stringify(errRes));
if (err.options && err.options.headers && err.options.headers.macaroon) {
delete err.options.headers.macaroon;
}
if (err.response && err.response.request && err.response.request.headers && err.response.request.headers.macaroon) {
delete err.response.request.headers.macaroon;
}
logger.error({fileName: 'OnChain', lineNum: 19, msg: 'OnChain List Funds Error: ' + JSON.stringify(err)});
return res.status(500).json({
message: "Fetching list funds failed!",
error: err.error
});
});
};

2
package-lock.json generated

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.8.4-beta",
"version": "0.9.0-beta",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

@ -1,6 +1,6 @@
{
"name": "rtl",
"version": "0.8.4-beta",
"version": "0.9.0-beta",
"license": "MIT",
"scripts": {
"ng": "ng",

@ -5,5 +5,6 @@ const authCheck = require("../authCheck");
router.get("/", authCheck, OnChainController.getNewAddress);
router.post("/", authCheck, OnChainController.onChainWithdraw);
router.get("/transactions/", authCheck, OnChainController.getTransactions);
module.exports = router;

@ -11,6 +11,7 @@ import { CLChannelsTablesComponent } from './peers-channels/channels/channels-ta
import { CLPeersComponent } from './peers-channels/peers/peers.component';
import { CLLightningInvoicesComponent } from './transactions/invoices/lightning-invoices.component';
import { CLOnChainReceiveComponent } from './on-chain/on-chain-receive/on-chain-receive.component';
import { CLOnChainTransactionHistoryComponent } from './on-chain/on-chain-transaction-history/on-chain-transaction-history.component';
import { CLOnChainComponent } from './on-chain/on-chain.component';
import { CLLightningPaymentsComponent } from './transactions/payments/lightning-payments.component';
import { CLTransactionsComponent } from './transactions/transactions.component';
@ -59,6 +60,7 @@ import { CLUnlockedGuard } from '../shared/services/auth.guard';
CLNodeLookupComponent,
CLQueryRoutesComponent,
CLOnChainReceiveComponent,
CLOnChainTransactionHistoryComponent,
CLOnChainComponent,
CLChannelsTablesComponent,
CLChannelOpenTableComponent,

@ -0,0 +1,68 @@
<div fxLayout="row wrap" fxLayoutAlign="start start" fxLayout.gt-sm="column" fxFlex="100" fxLayoutAlign.gt-sm="start stretch" class="padding-gap-x-large">
<div fxLayout="column" fxLayout.gt-xs="row wrap" fxLayoutAlign.gt-xs="start center" fxLayoutAlign="start stretch" class="page-sub-title-container">
<div fxFlex="70">
<fa-icon [icon]="faHistory" class="page-title-img mr-1"></fa-icon>
<span class="page-title">UTXOs</span>
</div>
<mat-form-field fxFlex="30">
<input matInput (keyup)="applyFilter($event.target.value)" placeholder="Filter">
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutAlign="start start">
<div perfectScrollbar class="table-container" fxFlex="100">
<mat-progress-bar *ngIf="flgLoading[0]===true" mode="indeterminate"></mat-progress-bar>
<table mat-table #table [dataSource]="listTransactions" matSort
[ngClass]="{'overflow-auto error-border': flgLoading[0]==='error','overflow-auto': true}">
<ng-container matColumnDef="txid">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Transaction ID </th>
<td mat-cell *matCellDef="let transaction">
<div class="ellipsis-parent" [ngStyle]="{'max-width': (screenSize === screenSizeEnum.XS) ? '10rem' : '50rem'}">
<span *ngIf="transaction.status === 'confirmed'" class="dot green" matTooltip="Confirmed" matTooltipPosition="right"></span>
<span *ngIf="transaction.status !== 'confirmed'" class="dot yellow" matTooltip="{{transaction.status | titlecase}}" matTooltipPosition="right"></span>
<span class="ellipsis-child">{{transaction.txid}}</span>
</div>
</td>
</ng-container>
<ng-container matColumnDef="output">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Output </th>
<td mat-cell *matCellDef="let transaction"><span fxLayoutAlign="end center">
{{transaction?.output | number}} </span></td>
</ng-container>
<ng-container matColumnDef="value">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Value (Sats) </th>
<td mat-cell *matCellDef="let transaction">
<span fxLayoutAlign="end center" *ngIf="transaction.value > 0 || transaction.value === 0">{{transaction.value | number}}</span>
<span fxLayoutAlign="end center" class="red" *ngIf="transaction.value < 0">({{transaction.value * -1 | number}})</span>
</td>
</ng-container>
<ng-container matColumnDef="blockheight">
<th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Blockheight </th>
<td mat-cell *matCellDef="let transaction"><span fxLayoutAlign="end center">
{{transaction?.blockheight | number}} </span></td>
</ng-container>
<ng-container matColumnDef="actions">
<th mat-header-cell *matHeaderCellDef class="px-3">
<div class="bordered-box table-actions-select">
<mat-select placeholder="Actions" tabindex="1" class="mr-0">
<mat-select-trigger></mat-select-trigger>
<mat-option (click)="onDownloadCSV()">Download CSV</mat-option>
</mat-select>
</div>
</th>
<td mat-cell *matCellDef="let transaction" class="pl-3" fxLayoutAlign="end center">
<button mat-stroked-button color="primary" type="button" tabindex="4" (click)="onTransactionClick(transaction, $event)">View Info</button>
</td>
</ng-container>
<ng-container matColumnDef="no_transaction">
<td mat-footer-cell *matFooterCellDef colspan="4">
<p *ngIf="!listTransactions.data || listTransactions.data.length<1">No transactions available.</p>
</td>
</ng-container>
<tr mat-footer-row *matFooterRowDef="['no_transaction']" [ngClass]="{'display-none': listTransactions.data && listTransactions.data.length>0}"></tr>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>
<mat-paginator [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions" [showFirstLastButtons]="screenSize === screenSizeEnum.XS ? false : true" class="mb-4"></mat-paginator>
</div>
</div>
</div>

@ -0,0 +1,11 @@
.mat-column-txid {
flex: 0 0 15%;
width: 15%;
& .ellipsis-parent {
display: flex;
}
}
.mat-column-actions {
min-height: 4.8rem;
}

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CLOnChainTransactionHistoryComponent } from './on-chain-transaction-history.component';
describe('CLOnChainTransactionHistoryComponent', () => {
let component: CLOnChainTransactionHistoryComponent;
let fixture: ComponentFixture<CLOnChainTransactionHistoryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CLOnChainTransactionHistoryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CLOnChainTransactionHistoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,121 @@
import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { Actions } from '@ngrx/effects';
import { faHistory } from '@fortawesome/free-solid-svg-icons';
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { Transaction } from '../../../shared/models/clModels';
import { PAGE_SIZE, PAGE_SIZE_OPTIONS, getPaginatorLabel, AlertTypeEnum, DataTypeEnum, ScreenSizeEnum } from '../../../shared/services/consts-enums-functions';
import { LoggerService } from '../../../shared/services/logger.service';
import { CommonService } from '../../../shared/services/common.service';
import * as CLActions from '../../store/cl.actions';
import * as RTLActions from '../../../store/rtl.actions';
import * as fromRTLReducer from '../../../store/rtl.reducers';
@Component({
selector: 'rtl-cl-on-chain-transaction-history',
templateUrl: './on-chain-transaction-history.component.html',
styleUrls: ['./on-chain-transaction-history.component.scss'],
providers: [
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Transactions') }
]
})
export class CLOnChainTransactionHistoryComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: true }) sort: MatSort;
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
faHistory = faHistory;
public displayedColumns = [];
public listTransactions: any;
public flgLoading: Array<Boolean | 'error'> = [true];
public flgSticky = false;
public pageSize = PAGE_SIZE;
public pageSizeOptions = PAGE_SIZE_OPTIONS;
public screenSize = '';
public screenSizeEnum = ScreenSizeEnum;
private unsub: Array<Subject<void>> = [new Subject(), new Subject(), new Subject()];
constructor(private logger: LoggerService, private commonService: CommonService, private store: Store<fromRTLReducer.RTLState>, private actions$: Actions) {
this.screenSize = this.commonService.getScreenSize();
if(this.screenSize === ScreenSizeEnum.XS) {
this.flgSticky = false;
this.displayedColumns = ['txid', 'value', 'actions'];
} else if(this.screenSize === ScreenSizeEnum.SM) {
this.flgSticky = false;
this.displayedColumns = ['txid', 'output', 'value', 'blockheight', 'actions'];
} else if(this.screenSize === ScreenSizeEnum.MD) {
this.flgSticky = false;
this.displayedColumns = ['txid', 'output', 'value', 'blockheight', 'actions'];
} else {
this.flgSticky = true;
this.displayedColumns = ['txid', 'output', 'value', 'blockheight', 'actions'];
}
}
ngOnInit() {
this.store.dispatch(new CLActions.FetchTransactions());
this.store.select('cl')
.pipe(takeUntil(this.unsub[0]))
.subscribe((rtlStore) => {
rtlStore.effectErrors.forEach(effectsErr => {
if (effectsErr.action === 'FetchTransactions') {
this.flgLoading[0] = 'error';
}
});
if (rtlStore.transactions) {
this.loadTransactionsTable(rtlStore.transactions);
}
if (this.flgLoading[0] !== 'error') {
this.flgLoading[0] = (rtlStore.transactions) ? false : true;
}
this.logger.info(rtlStore);
});
}
applyFilter(selFilter: string) {
this.listTransactions.filter = selFilter;
}
onTransactionClick(selTransaction: Transaction, event: any) {
const reorderedTransactions = [
[{key: 'txid', value: selTransaction.txid, title: 'Transaction ID', width: 100}],
[{key: 'output', value: selTransaction.output, title: 'Output', width: 50, type: DataTypeEnum.NUMBER},
{key: 'value', value: selTransaction.value, title: 'Value (Sats)', width: 50, type: DataTypeEnum.NUMBER}],
[{key: 'status', value: this.commonService.titleCase(selTransaction.status), title: 'Status', width: 50, type: DataTypeEnum.STRING},
{key: 'blockheight', value: selTransaction.blockheight, title: 'Blockheight', width: 50, type: DataTypeEnum.NUMBER}],
[{key: 'address', value: selTransaction.address, title: 'Address', width: 100}],
];
this.store.dispatch(new RTLActions.OpenAlert({ data: {
type: AlertTypeEnum.INFORMATION,
alertTitle: 'Transaction Information',
message: reorderedTransactions
}}));
}
loadTransactionsTable(transactions) {
this.listTransactions = new MatTableDataSource<Transaction>([...transactions]);
this.listTransactions.sort = this.sort;
this.listTransactions.sortingDataAccessor = (data, sortHeaderId) => (data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : +data[sortHeaderId];
this.listTransactions.paginator = this.paginator;
this.logger.info(this.listTransactions);
}
onDownloadCSV() {
if(this.listTransactions.data && this.listTransactions.data.length > 0) {
this.commonService.downloadFile(this.listTransactions.data, 'Transactions');
}
}
ngOnDestroy() {
this.unsub.forEach(completeSub => {
completeSub.next();
completeSub.complete();
});
}
}

@ -28,6 +28,11 @@
</div>
</mat-tab>
</mat-tab-group>
<div fxLayout="column" fxFlex="100" fxLayoutAlign="space-between stretch" class="padding-gap-x-large">
<div fxLayout="row">
<rtl-cl-on-chain-transaction-history fxLayout="row" fxFlex="100"></rtl-cl-on-chain-transaction-history>
</div>
</div>
</mat-card-content>
</mat-card>
</div>

@ -2,7 +2,9 @@ import { Action } from '@ngrx/store';
import { ErrorPayload } from '../../shared/models/errorPayload';
import { SelNodeChild } from '../../shared/models/RTLconfig';
import { GetInfo, Fees, Peer, Payment, PayRequest, QueryRoutes, Channel, FeeRates, ForwardingHistoryRes, Invoice, ListInvoices, OnChain } from '../../shared/models/clModels';
import { GetInfo, Fees, Peer, Payment, PayRequest, QueryRoutes, Channel, FeeRates,
ForwardingHistoryRes, Invoice, ListInvoices, OnChain, Transaction
} from '../../shared/models/clModels';
export const RESET_CL_STORE = 'RESET_CL_STORE';
export const CLEAR_EFFECT_ERROR_CL = 'CLEAR_EFFECT_ERROR_CL';
@ -20,6 +22,8 @@ export const FETCH_LOCAL_REMOTE_BALANCE_CL = 'FETCH_LOCAL_REMOTE_BALANCE_CL';
export const SET_LOCAL_REMOTE_BALANCE_CL = 'SET_LOCAL_REMOTE_BALANCE_CL';
export const GET_NEW_ADDRESS_CL = 'GET_NEW_ADDRESS_CL';
export const SET_NEW_ADDRESS_CL = 'SET_NEW_ADDRESS_CL';
export const FETCH_TRANSACTIONS_CL = 'FETCH_TRANSACTIONS_CL';
export const SET_TRANSACTIONS_CL = 'SET_TRANSACTIONS_CL';
export const FETCH_PEERS_CL = 'FETCH_PEERS_CL';
export const SET_PEERS_CL = 'SET_PEERS_CL';
export const SAVE_NEW_PEER_CL = 'SAVE_NEW_PEER_CL';
@ -305,10 +309,19 @@ export class SetChannelTransactionRes implements Action {
constructor(public payload: any) {}
}
export class FetchTransactions implements Action {
readonly type = FETCH_TRANSACTIONS_CL;
}
export class SetTransactions implements Action {
readonly type = SET_TRANSACTIONS_CL;
constructor(public payload: Transaction[]) {}
}
export type CLActions = ClearEffectError | EffectError | ResetCLStore |
SetChildNodeSettings | FetchInfo | SetInfo | FetchFees | SetFees | FetchFeeRates | SetFeeRates |
FetchBalance | SetBalance | FetchLocalRemoteBalance | SetLocalRemoteBalance |
GetNewAddress | SetNewAddress |
GetNewAddress | SetNewAddress | FetchTransactions | SetTransactions |
FetchPeers | SetPeers | AddPeer | DetachPeer | SaveNewPeer | RemovePeer | NewlyAddedPeer |
FetchChannels | SetChannels | UpdateChannels | SaveNewChannel | CloseChannel | RemoveChannel |
FetchPayments | SetPayments | SendPayment | SendPaymentStatus | DecodePayment | SetDecodedPayment |

@ -13,7 +13,7 @@ import { SessionService } from '../../shared/services/session.service';
import { CommonService } from '../../shared/services/common.service';
import { ErrorMessageComponent } from '../../shared/components/data-modal/error-message/error-message.component';
import { CLInvoiceInformationComponent } from '../transactions/invoice-information-modal/invoice-information.component';
import { GetInfo, Fees, Balance, LocalRemoteBalance, Payment, FeeRates, ListInvoices, Invoice, Peer } from '../../shared/models/clModels';
import { GetInfo, Fees, Balance, LocalRemoteBalance, Payment, FeeRates, ListInvoices, Invoice, Peer, Transaction } from '../../shared/models/clModels';
import * as fromRTLReducer from '../../store/rtl.reducers';
import * as RTLActions from '../../store/rtl.actions';
@ -655,50 +655,70 @@ export class CLEffects implements OnDestroy {
@Effect()
invoicesFetchCL = this.actions$.pipe(
ofType(CLActions.FETCH_INVOICES_CL),
mergeMap((action: CLActions.FetchInvoices) => {
this.store.dispatch(new CLActions.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;
const reversed = (action.payload.reversed) ? action.payload.reversed : false;
return this.httpClient.get<ListInvoices>(this.CHILD_API_URL + environment.INVOICES_API + '?num_max_invoices=' + num_max_invoices + '&index_offset=' + index_offset + '&reversed=' + reversed)
.pipe(map((res: ListInvoices) => {
this.logger.info(res);
this.store.dispatch(new CLActions.SetTotalInvoices(res.invoices ? res.invoices.length : 0));
return {
type: CLActions.SET_INVOICES_CL,
payload: res
};
}),
catchError((err: any) => {
this.handleErrorWithoutAlert('FetchInvoices', 'Fetching Invoices Failed.', err);
return of({type: RTLActions.VOID});
}
));
}));
@Effect()
SetChannelTransactionCL = this.actions$.pipe(
ofType(CLActions.SET_CHANNEL_TRANSACTION_CL),
mergeMap((action: CLActions.SetChannelTransaction) => {
this.store.dispatch(new CLActions.ClearEffectError('SetChannelTransaction'));
return this.httpClient.post(this.CHILD_API_URL + environment.ON_CHAIN_API, action.payload)
.pipe(
map((postRes: any) => {
this.logger.info(postRes);
this.store.dispatch(new RTLActions.CloseSpinner());
this.store.dispatch(new CLActions.FetchBalance());
return {
type: CLActions.SET_CHANNEL_TRANSACTION_RES_CL,
payload: postRes
};
}),
ofType(CLActions.FETCH_INVOICES_CL),
mergeMap((action: CLActions.FetchInvoices) => {
this.store.dispatch(new CLActions.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;
const reversed = (action.payload.reversed) ? action.payload.reversed : false;
return this.httpClient.get<ListInvoices>(this.CHILD_API_URL + environment.INVOICES_API + '?num_max_invoices=' + num_max_invoices + '&index_offset=' + index_offset + '&reversed=' + reversed)
.pipe(map((res: ListInvoices) => {
this.logger.info(res);
this.store.dispatch(new CLActions.SetTotalInvoices(res.invoices ? res.invoices.length : 0));
return {
type: CLActions.SET_INVOICES_CL,
payload: res
};
}),
catchError((err: any) => {
this.handleErrorWithoutAlert('SetChannelTransaction', 'Sending Fund Failed.', err);
this.handleErrorWithoutAlert('FetchInvoices', 'Fetching Invoices Failed.', err);
return of({type: RTLActions.VOID});
}));
})
);
}
));
}));
@Effect()
SetChannelTransactionCL = this.actions$.pipe(
ofType(CLActions.SET_CHANNEL_TRANSACTION_CL),
mergeMap((action: CLActions.SetChannelTransaction) => {
this.store.dispatch(new CLActions.ClearEffectError('SetChannelTransaction'));
return this.httpClient.post(this.CHILD_API_URL + environment.ON_CHAIN_API, action.payload)
.pipe(
map((postRes: any) => {
this.logger.info(postRes);
this.store.dispatch(new RTLActions.CloseSpinner());
this.store.dispatch(new CLActions.FetchBalance());
return {
type: CLActions.SET_CHANNEL_TRANSACTION_RES_CL,
payload: postRes
};
}),
catchError((err: any) => {
this.handleErrorWithoutAlert('SetChannelTransaction', 'Sending Fund Failed.', err);
return of({type: RTLActions.VOID});
}));
})
);
@Effect()
transactionsFetch = this.actions$.pipe(
ofType(CLActions.FETCH_TRANSACTIONS_CL),
mergeMap((action: CLActions.FetchTransactions) => {
this.store.dispatch(new CLActions.ClearEffectError('FetchTransactions'));
return this.httpClient.get(this.CHILD_API_URL + environment.ON_CHAIN_API + '/transactions');
}),
map((transactions: any) => {
this.logger.info(transactions);
return {
type: CLActions.SET_TRANSACTIONS_CL,
payload: (transactions && transactions.outputs && transactions.outputs.length > 0) ? transactions.outputs : []
};
}),
catchError((err: any) => {
this.handleErrorWithoutAlert('FetchTransactions', 'Fetching Transactions Failed.', err);
return of({type: RTLActions.VOID});
}
));
initializeRemainingData(info: any, landingPage: string) {
this.sessionService.setItem('clUnlocked', 'true');

@ -1,6 +1,6 @@
import { SelNodeChild } from '../../shared/models/RTLconfig';
import { UserPersonaEnum } from '../../shared/services/consts-enums-functions';
import { GetInfo, Fees, Balance, LocalRemoteBalance, Peer, Payment, Channel, FeeRates, ForwardingHistoryRes, ListInvoices } from '../../shared/models/clModels';
import { GetInfo, Fees, Balance, LocalRemoteBalance, Peer, Payment, Channel, FeeRates, ForwardingHistoryRes, ListInvoices, Transaction } from '../../shared/models/clModels';
import { ErrorPayload } from '../../shared/models/errorPayload';
import * as CLActions from '../store/cl.actions';
import * as RTLActions from '../../store/rtl.actions';
@ -21,6 +21,7 @@ export interface CLState {
forwardingHistory: ForwardingHistoryRes;
invoices: ListInvoices;
totalInvoices: number;
transactions: Transaction[];
}
export const initCLState: CLState = {
@ -38,7 +39,8 @@ export const initCLState: CLState = {
payments: [],
forwardingHistory: {},
invoices: { invoices: [] },
totalInvoices: -1
totalInvoices: -1,
transactions: []
}
export function CLReducer(state = initCLState, action: CLActions.CLActions) {
@ -211,6 +213,11 @@ export function CLReducer(state = initCLState, action: CLActions.CLActions) {
...state,
totalInvoices: action.payload
};
case CLActions.SET_TRANSACTIONS_CL:
return {
...state,
transactions: action.payload
};
default:
return state;
}

@ -254,4 +254,14 @@ export interface FeeRatePerObj {
slow?: number;
min_acceptable?: number;
max_acceptable?: number;
}
}
export interface Transaction {
txid?: string;
output?: number;
value?: number;
status?: string;
blockheight?: string;
address?: string;
amount_msat?: string;
}

@ -1 +1 @@
export const VERSION = '0.8.4-beta';
export const VERSION = '0.9.0-beta';
Loading…
Cancel
Save