diff --git a/src/app/cln/cln.module.ts b/src/app/cln/cln.module.ts
index 5dd7f064..ab75b077 100644
--- a/src/app/cln/cln.module.ts
+++ b/src/app/cln/cln.module.ts
@@ -56,7 +56,8 @@ import { CLNCreateOfferComponent } from './transactions/offers/create-offer-moda
import { CLNOfferInformationComponent } from './transactions/offers/offer-information-modal/offer-information.component';
import { CLNOffersTableComponent } from './transactions/offers/offers-table/offers-table.component';
import { CLNOfferBookmarksTableComponent } from './transactions/offers/offer-bookmarks-table/offer-bookmarks-table.component';
-import { CLNLiquidityAdsComponent } from './liquidity-ads/liquidity-ads.component';
+import { CLNLiquidityAdsListComponent } from './liquidity-ads/liquidity-ads-list/liquidity-ads-list.component';
+import { CLNOpenLiquidityChannelComponent } from './liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component';
import { CLNUnlockedGuard } from '../shared/services/auth.guard';
@@ -119,7 +120,8 @@ import { CLNUnlockedGuard } from '../shared/services/auth.guard';
CLNOfferInformationComponent,
CLNOffersTableComponent,
CLNOfferBookmarksTableComponent,
- CLNLiquidityAdsComponent
+ CLNLiquidityAdsListComponent,
+ CLNOpenLiquidityChannelComponent
],
providers: [
CLNUnlockedGuard
diff --git a/src/app/cln/cln.routing.ts b/src/app/cln/cln.routing.ts
index bb27e400..f0bd6f73 100644
--- a/src/app/cln/cln.routing.ts
+++ b/src/app/cln/cln.routing.ts
@@ -34,7 +34,7 @@ import { CLNGraphComponent } from './graph/graph.component';
import { CLNOffersTableComponent } from './transactions/offers/offers-table/offers-table.component';
import { CLNOfferBookmarksTableComponent } from './transactions/offers/offer-bookmarks-table/offer-bookmarks-table.component';
import { CLNLocalFailedTransactionsComponent } from './routing/local-failed-transactions/local-failed-transactions.component';
-import { CLNLiquidityAdsComponent } from './liquidity-ads/liquidity-ads.component';
+import { CLNLiquidityAdsListComponent } from './liquidity-ads/liquidity-ads-list/liquidity-ads-list.component';
export const ClnRoutes: Routes = [
{
@@ -63,7 +63,7 @@ export const ClnRoutes: Routes = [
{ path: 'peers', component: CLNPeersComponent, data: { sweepAll: false }, canActivate: [CLNUnlockedGuard] }
]
},
- { path: 'liquidityads', component: CLNLiquidityAdsComponent, canActivate: [CLNUnlockedGuard] },
+ { path: 'liquidityads', component: CLNLiquidityAdsListComponent, canActivate: [CLNUnlockedGuard] },
{
path: 'transactions', component: CLNTransactionsComponent, canActivate: [CLNUnlockedGuard], children: [
{ path: '', pathMatch: 'full', redirectTo: 'payments' },
diff --git a/src/app/cln/liquidity-ads/liquidity-ads.component.html b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.html
similarity index 93%
rename from src/app/cln/liquidity-ads/liquidity-ads.component.html
rename to src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.html
index 569431dd..a1453c11 100644
--- a/src/app/cln/liquidity-ads/liquidity-ads.component.html
+++ b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.html
@@ -42,18 +42,13 @@
-
+
Node capacity is required.
-
- Channel count is required.
+
-
-
-
-
diff --git a/src/app/cln/liquidity-ads/liquidity-ads.component.scss b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.scss
similarity index 100%
rename from src/app/cln/liquidity-ads/liquidity-ads.component.scss
rename to src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.scss
diff --git a/src/app/cln/liquidity-ads/liquidity-ads.component.spec.ts b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.spec.ts
similarity index 50%
rename from src/app/cln/liquidity-ads/liquidity-ads.component.spec.ts
rename to src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.spec.ts
index 8afdeb54..ac72961a 100644
--- a/src/app/cln/liquidity-ads/liquidity-ads.component.spec.ts
+++ b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.spec.ts
@@ -1,20 +1,20 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
-import { SharedModule } from '../../shared/shared.module';
+import { SharedModule } from '../../../shared/shared.module';
-import { DataService } from '../../shared/services/data.service';
-import { CommonService } from '../../shared/services/common.service';
-import { mockDataService } from '../../shared/test-helpers/mock-services';
+import { DataService } from '../../../shared/services/data.service';
+import { CommonService } from '../../../shared/services/common.service';
+import { mockDataService } from '../../../shared/test-helpers/mock-services';
-import { CLNLiquidityAdsComponent } from './liquidity-ads.component';
+import { CLNLiquidityAdsListComponent } from './liquidity-ads-list.component';
-describe('CLNLiquidityAdsComponent', () => {
- let component: CLNLiquidityAdsComponent;
- let fixture: ComponentFixture
;
+describe('CLNLiquidityAdsListComponent', () => {
+ let component: CLNLiquidityAdsListComponent;
+ let fixture: ComponentFixture;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
- declarations: [CLNLiquidityAdsComponent],
+ declarations: [CLNLiquidityAdsListComponent],
imports: [
BrowserAnimationsModule,
SharedModule
@@ -28,7 +28,7 @@ describe('CLNLiquidityAdsComponent', () => {
}));
beforeEach(() => {
- fixture = TestBed.createComponent(CLNLiquidityAdsComponent);
+ fixture = TestBed.createComponent(CLNLiquidityAdsListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
diff --git a/src/app/cln/liquidity-ads/liquidity-ads.component.ts b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts
similarity index 76%
rename from src/app/cln/liquidity-ads/liquidity-ads.component.ts
rename to src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts
index cf0e089f..15ee753f 100644
--- a/src/app/cln/liquidity-ads/liquidity-ads.component.ts
+++ b/src/app/cln/liquidity-ads/liquidity-ads-list/liquidity-ads-list.component.ts
@@ -7,25 +7,28 @@ import { MatSort } from '@angular/material/sort';
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
import { faBullhorn, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
-import { DataService } from '../../shared/services/data.service';
-import { LoggerService } from '../../shared/services/logger.service';
-import { CommonService } from '../../shared/services/common.service';
-import { AlertTypeEnum, APICallStatusEnum, DataTypeEnum, getPaginatorLabel, PAGE_SIZE, PAGE_SIZE_OPTIONS, ScreenSizeEnum } from '../../shared/services/consts-enums-functions';
-import { LookupNode } from '../../shared/models/clnModels';
-import { ApiCallStatusPayload } from '../../shared/models/apiCallsPayload';
-import { openConfirmation } from '../../store/rtl.actions';
-import { RTLState } from '../../store/rtl.state';
-import { RTLEffects } from '../../store/rtl.effects';
+import { DataService } from '../../../shared/services/data.service';
+import { LoggerService } from '../../../shared/services/logger.service';
+import { CommonService } from '../../../shared/services/common.service';
+import { AlertTypeEnum, APICallStatusEnum, DataTypeEnum, getPaginatorLabel, PAGE_SIZE, PAGE_SIZE_OPTIONS, ScreenSizeEnum } from '../../../shared/services/consts-enums-functions';
+import { Balance, GetInfo, LookupNode } from '../../../shared/models/clnModels';
+import { ApiCallStatusPayload } from '../../../shared/models/apiCallsPayload';
+import { openAlert, openConfirmation } from '../../../store/rtl.actions';
+import { RTLState } from '../../../store/rtl.state';
+import { RTLEffects } from '../../../store/rtl.effects';
+import { CLNOpenLiquidityChannelComponent } from '../open-liquidity-channel-modal/open-liquidity-channel-modal.component';
+import { nodeInfoAndNodeSettingsAndBalance } from '../../store/cln.selector';
+import { SelNodeChild } from '../../../shared/models/RTLconfig';
@Component({
- selector: 'rtl-cln-liquidity-ads',
- templateUrl: './liquidity-ads.component.html',
- styleUrls: ['./liquidity-ads.component.scss'],
+ selector: 'rtl-cln-liquidity-ads-list',
+ templateUrl: './liquidity-ads-list.component.html',
+ styleUrls: ['./liquidity-ads-list.component.scss'],
providers: [
{ provide: MatPaginatorIntl, useValue: getPaginatorLabel('Liquidity Ads') }
]
})
-export class CLNLiquidityAdsComponent implements OnInit, OnDestroy {
+export class CLNLiquidityAdsListComponent implements OnInit, OnDestroy {
@ViewChild(MatSort, { static: false }) sort: MatSort | undefined;
@ViewChild(MatPaginator, { static: false }) paginator: MatPaginator | undefined;
@@ -34,8 +37,10 @@ export class CLNLiquidityAdsComponent implements OnInit, OnDestroy {
public displayedColumns: any[] = [];
public faBullhorn = faBullhorn;
public faExclamationTriangle = faExclamationTriangle;
- public channelAmount = 0;
- public channelOpeningFeeRate = 0;
+ public totalBalance = 0;
+ public information: GetInfo;
+ public channelAmount = 100000;
+ public channelOpeningFeeRate = 2;
public nodeCapacity = 500000;
public channelCount = 5;
public liquidityNodesData: LookupNode[] = [];
@@ -83,6 +88,12 @@ export class CLNLiquidityAdsComponent implements OnInit, OnDestroy {
this.errorMessage = JSON.stringify(err);
}
});
+ this.store.select(nodeInfoAndNodeSettingsAndBalance).pipe(takeUntil(this.unSubs[1])).
+ subscribe((infoSettingsBalSelector: { information: GetInfo, nodeSettings: SelNodeChild, balance: Balance }) => {
+ this.information = infoSettingsBalSelector.information;
+ this.totalBalance = infoSettingsBalSelector.balance.totalBalance;
+ this.logger.info(infoSettingsBalSelector);
+ });
}
onRecalculate() {
@@ -90,27 +101,35 @@ export class CLNLiquidityAdsComponent implements OnInit, OnDestroy {
}
onFilter() {
- this.logger.info(this.nodeCapacity);
- this.logger.info(this.channelCount);
- this.liquidityNodes.filter = this.nodeCapacity + ' ' + this.channelCount;
+ this.liquidityNodes.filter = 'Changed';
}
loadLiqNodesTable(liqNodes: LookupNode[]) {
this.liquidityNodes = new MatTableDataSource([...liqNodes]);
this.liquidityNodes.sortingDataAccessor = (data: any, sortHeaderId: string) => ((data[sortHeaderId] && isNaN(data[sortHeaderId])) ? data[sortHeaderId].toLocaleLowerCase() : data[sortHeaderId] ? +data[sortHeaderId] : null);
this.liquidityNodes.sort = this.sort;
- this.liquidityNodes.filterPredicate = (node: LookupNode, fltr: string) => {
- console.warn(node.channelCount);
- console.warn(node.nodeCapacity);
- console.warn(node.channelCount >= this.channelCount && node.nodeCapacity >= this.nodeCapacity);
- return node.channelCount >= this.channelCount && node.nodeCapacity >= this.nodeCapacity;
- }
+ this.liquidityNodes.filterPredicate = (node: LookupNode, fltr: string) => node.channelCount >= this.channelCount && node.nodeCapacity >= this.nodeCapacity;
this.liquidityNodes.paginator = this.paginator;
this.onFilter();
}
onOpenChannel(lqNode: LookupNode) {
-
+ const peerToAddChannelMessage = {
+ node: lqNode,
+ balance: this.totalBalance,
+ requestedAmount: this.channelAmount,
+ feeRate: this.channelOpeningFeeRate,
+ localAmount: 20000
+ };
+ this.store.dispatch(openAlert({
+ payload: {
+ data: {
+ alertTitle: 'Open Channel',
+ message: peerToAddChannelMessage,
+ component: CLNOpenLiquidityChannelComponent
+ }
+ }
+ }));
}
onViewLeaseInfo(lqNode: LookupNode) {
@@ -141,9 +160,9 @@ export class CLNLiquidityAdsComponent implements OnInit, OnDestroy {
}
}
}));
- this.rtlEffects.closeConfirm.pipe(takeUntil(this.unSubs[1])).subscribe((confirmRes) => {
+ this.rtlEffects.closeConfirm.pipe(takeUntil(this.unSubs[2])).subscribe((confirmRes) => {
if (confirmRes) {
- console.warn('Open Channel Modal');
+ this.onOpenChannel(lqNode);
}
});
}
diff --git a/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.html b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.html
new file mode 100644
index 00000000..05a21727
--- /dev/null
+++ b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.html
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+ Node: {{node?.alias || node?.nodeid}}
+
+
+
+
+
+
Pubkey
+ {{node.nodeid}}
+
+
+
+
+
+
Last Timestamp
+ {{node.last_timestamp}}
+
+
+
+
+
Addresses
+
+
+
+ Type |
+ {{address?.type}} |
+
+
+ Address |
+ {{address?.address }} |
+
+
+ Port |
+ {{address?.port}} |
+
+
+
+
+
+
+
+
+
diff --git a/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.scss b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.scss
new file mode 100644
index 00000000..c41458b2
--- /dev/null
+++ b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.scss
@@ -0,0 +1,3 @@
+.open-inputs-box {
+ padding: 1.2rem 2.4rem 0.8rem 2.4rem !important;
+}
\ No newline at end of file
diff --git a/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.spec.ts b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.spec.ts
new file mode 100644
index 00000000..07120b86
--- /dev/null
+++ b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.spec.ts
@@ -0,0 +1,53 @@
+import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';
+import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { StoreModule } from '@ngrx/store';
+import { EffectsModule } from '@ngrx/effects';
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+
+import { CommonService } from '../../../shared/services/common.service';
+import { DataService } from '../../../shared/services/data.service';
+import { RootReducer } from '../../../store/rtl.reducers';
+import { LNDReducer } from '../../../lnd/store/lnd.reducers';
+import { CLNReducer } from '../../../cln/store/cln.reducers';
+import { ECLReducer } from '../../../eclair/store/ecl.reducers';
+import { CLNOpenLiquidityChannelComponent } from './open-liquidity-channel-modal.component';
+import { mockCLEffects, mockDataService, mockECLEffects, mockLNDEffects, mockMatDialogRef, mockRTLEffects } from '../../../shared/test-helpers/mock-services';
+import { SharedModule } from '../../../shared/shared.module';
+
+describe('CLNOpenLiquidityChannelComponent', () => {
+ let component: CLNOpenLiquidityChannelComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(waitForAsync(() => {
+ TestBed.configureTestingModule({
+ declarations: [CLNOpenLiquidityChannelComponent],
+ imports: [
+ BrowserAnimationsModule,
+ SharedModule,
+ StoreModule.forRoot({ root: RootReducer, lnd: LNDReducer, cln: CLNReducer, ecl: ECLReducer }),
+ EffectsModule.forRoot([mockRTLEffects, mockLNDEffects, mockCLEffects, mockECLEffects])
+ ],
+ providers: [
+ CommonService,
+ { provide: DataService, useClass: mockDataService },
+ { provide: MatDialogRef, useClass: mockMatDialogRef },
+ { provide: MAT_DIALOG_DATA, useValue: { message: {} } }
+ ]
+ }).
+ compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(CLNOpenLiquidityChannelComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+
+ afterEach(() => {
+ TestBed.resetTestingModule();
+ });
+});
diff --git a/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.ts b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.ts
new file mode 100644
index 00000000..6472a3a0
--- /dev/null
+++ b/src/app/cln/liquidity-ads/open-liquidity-channel-modal/open-liquidity-channel-modal.component.ts
@@ -0,0 +1,84 @@
+import { Component, OnInit, Inject, OnDestroy, ViewChild } from '@angular/core';
+import { Store } from '@ngrx/store';
+import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
+import { Subject } from 'rxjs';
+import { takeUntil, filter } from 'rxjs/operators';
+import { Actions } from '@ngrx/effects';
+import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons';
+
+import { LookupNode } from '../../../shared/models/clnModels';
+import { CLNOpenLiquidityChannelAlert } from '../../../shared/models/alertData';
+import { APICallStatusEnum, CLNActions } from '../../../shared/services/consts-enums-functions';
+
+import { RTLState } from '../../../store/rtl.state';
+import { saveNewChannel } from '../../store/cln.actions';
+
+@Component({
+ selector: 'rtl-cln-open-liquidity-channel',
+ templateUrl: './open-liquidity-channel-modal.component.html',
+ styleUrls: ['./open-liquidity-channel-modal.component.scss']
+})
+export class CLNOpenLiquidityChannelComponent implements OnInit, OnDestroy {
+
+ public faExclamationTriangle = faExclamationTriangle;
+ @ViewChild('form', { static: true }) form: any;
+ public alertTitle: string;
+ public totalBalance = 0;
+ public node: LookupNode;
+ public requestedAmount = 0;
+ public feeRate = 0;
+ public localAmount = 0;
+ public channelConnectionError = '';
+ public displayedColumns = ['type', 'address', 'port'];
+ private unSubs: Array> = [new Subject(), new Subject()];
+
+ constructor(public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: CLNOpenLiquidityChannelAlert, private actions: Actions, private store: Store) { }
+
+ ngOnInit() {
+ this.alertTitle = this.data.alertTitle;
+ this.totalBalance = this.data.message.balance;
+ this.node = this.data.message.node;
+ this.requestedAmount = this.data.message.requestedAmount;
+ this.feeRate = this.data.message.feeRate;
+ this.localAmount = this.data.message.localAmount;
+ this.actions.pipe(
+ takeUntil(this.unSubs[0]),
+ filter((action) => action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN || action.type === CLNActions.FETCH_CHANNELS_CLN)).
+ subscribe((action: any) => {
+ if (action.type === CLNActions.UPDATE_API_CALL_STATUS_CLN && action.payload.status === APICallStatusEnum.ERROR && action.payload.action === 'SaveNewChannel') {
+ this.channelConnectionError = action.payload.message;
+ }
+ if (action.type === CLNActions.FETCH_CHANNELS_CLN) {
+ this.dialogRef.close();
+ }
+ });
+ }
+
+ onClose() {
+ this.dialogRef.close(false);
+ }
+
+ resetData() {
+ this.form.resetForm();
+ this.form.controls.ramount.setValue(this.data.message.requestedAmount);
+ this.form.controls.feerate.setValue(this.data.message.feeRate);
+ this.form.controls.lamount.setValue(this.data.message.localAmount);
+ this.channelConnectionError = '';
+ }
+
+ onOpenChannel(): boolean | void {
+ if (!this.node || !this.requestedAmount || !this.feeRate || !this.localAmount) {
+ return true;
+ }
+ const newChannel = { peerId: this.node.nodeid, satoshis: this.requestedAmount.toString(), announce: false, feeRate: this.feeRate + 'perkb' };
+ this.store.dispatch(saveNewChannel({ payload: newChannel }));
+ }
+
+ ngOnDestroy() {
+ this.unSubs.forEach((completeSub) => {
+ completeSub.next(null);
+ completeSub.complete();
+ });
+ }
+
+}
diff --git a/src/app/shared/components/data-modal/confirmation-message/confirmation-message.component.html b/src/app/shared/components/data-modal/confirmation-message/confirmation-message.component.html
index 64a22e57..bf343630 100644
--- a/src/app/shared/components/data-modal/confirmation-message/confirmation-message.component.html
+++ b/src/app/shared/components/data-modal/confirmation-message/confirmation-message.component.html
@@ -24,7 +24,9 @@
{{obj.title}}
- {{arrayObj}}
+
+
+
{{(obj.value * 1000) | date:'dd/MMM/y HH:mm'}}
{{obj.value | number:'1.0-3'}}
{{obj.value === true ? 'True' : 'False'}}
diff --git a/src/app/shared/models/alertData.ts b/src/app/shared/models/alertData.ts
index 3ad56dce..10ce6cb1 100644
--- a/src/app/shared/models/alertData.ts
+++ b/src/app/shared/models/alertData.ts
@@ -1,7 +1,7 @@
import { DataTypeEnum, LoopTypeEnum, PaymentTypes, SwapTypeEnum } from '../services/consts-enums-functions';
import { GetInfoRoot, RTLConfiguration } from './RTLconfig';
import { GetInfo, Invoice, Channel, Peer, PendingOpenChannel, UTXO } from './lndModels';
-import { Invoice as InvoiceCLN, GetInfo as GetInfoCLN, Peer as PeerCLN, Channel as ChannelCLN, UTXO as UTXOCLN, Offer as OfferCLN } from './clnModels';
+import { Invoice as InvoiceCLN, GetInfo as GetInfoCLN, Peer as PeerCLN, Channel as ChannelCLN, UTXO as UTXOCLN, Offer as OfferCLN, LookupNode as LookupNodeCLN } from './clnModels';
import { GetInfo as GetInfoECL, Peer as PeerECL, Channel as ChannelECL, Invoice as InvoiceECL, PaymentSent as PaymentSentECL } from './eclModels';
import { LoopQuote } from './loopModels';
import { ServiceInfo } from './boltzModels';
@@ -69,6 +69,14 @@ export interface CLNOpenChannelAlert {
component?: any;
}
+export interface CLNOpenLiquidityChannelAlert {
+ alertTitle?: string;
+ titleMessage?: string;
+ message?: { node: LookupNodeCLN, balance: number, requestedAmount: number, feeRate: number, localAmount: number };
+ newlyAdded?: boolean;
+ component?: any;
+}
+
export interface ECLOpenChannelAlert {
alertTitle?: string;
titleMessage?: string;