lnd: Open channel model block if min fee is higher

pull/1388/head
ShahanaFarooqui 2 months ago
parent d3d1adb460
commit 93434d92c2

@ -27,8 +27,8 @@
<input #amt="ngModel" matInput type="number" tabindex="1" required name="amnt" [step]="1000" [min]="1" [max]="totalBalance" [(ngModel)]="fundingAmount">
<mat-hint>(Remaining: {{totalBalance - ((fundingAmount) ? fundingAmount : 0) | number}})</mat-hint>
<span matSuffix> Sats </span>
<mat-error *ngIf="amount.errors?.required">Amount is required.</mat-error>
<mat-error *ngIf="amount.errors?.max">Amount must be less than or equal to {{totalBalance}}.</mat-error>
<mat-error *ngIf="amt.errors?.required">Amount is required.</mat-error>
<mat-error *ngIf="amt.errors?.max">Amount must be less than or equal to {{totalBalance}}.</mat-error>
</mat-form-field>
<div fxFlex="35" fxLayoutAlign="start center">
<mat-slide-toggle tabindex="2" color="primary" name="isPrivate" [(ngModel)]="isPrivate">Private Channel</mat-slide-toggle>
@ -43,7 +43,7 @@
<div fxLayout="column" fxFlex="100" fxLayoutAlign="start stretch">
<div fxLayout="row" fxFlex="100" fxLayoutAlign="space-between center">
<mat-form-field fxLayout="column" fxFlex="49">
<mat-select tabindex="3" [(value)]="selTransType">
<mat-select tabindex="3" [(value)]="selTransType" (selectionChange)="onSelTransTypeChanged($event)">
<mat-option *ngFor="let transType of transTypes" [value]="transType.id">
{{transType.name}}
</mat-option>
@ -51,11 +51,14 @@
</mat-form-field>
<mat-form-field fxLayout="column" fxFlex="49">
<mat-label>{{selTransType==='0' ? 'Default' : selTransType==='1' ? 'Target Confirmation Blocks' : 'Fee (Sats/vByte)'}}</mat-label>
<input #transTypeVal="ngModel" matInput type="number" tabindex="4" name="transTpValue" [required]="selTransType!=='0'" [disabled]="selTransType==='0'" [step]="1" [min]="0" [(ngModel)]="transTypeValue">
<mat-error *ngIf="selTransType!=='0' && !transTypeValue">{{selTransType === '1' ? 'Target Confirmation Blocks' : 'Fee'}} is required.</mat-error>
<input #transTypeVal="ngModel" matInput type="number" tabindex="4" name="transTpValue" [required]="selTransType!=='0'" [disabled]="selTransType==='0'" [step]="1" [min]="selTransType === '2' ? recommendedFee.minimumFee : 0" [(ngModel)]="transTypeValue">
<mat-hint *ngIf="selTransType === '2'">Mempool Min: {{recommendedFee.minimumFee}} (Sats/vByte)</mat-hint>
<mat-error *ngIf="selTransType === '1' && !transTypeValue">Target Confirmation Blocks is required.</mat-error>
<mat-error *ngIf="selTransType === '2' && !transTypeValue">Fee is required.</mat-error>
<mat-error *ngIf="selTransType === '2' && transTypeValue && +transTypeValue < recommendedFee.minimumFee">Lower than min feerate {{recommendedFee.minimumFee}} in the mempool.</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" fxFlex="100" fxLayoutAlign="space-between center">
<div fxLayout="row" fxFlex="100" fxLayoutAlign="space-between center" class="mt-2">
<div *ngIf="isTaprootAvailable" fxFlex="50" fxLayoutAlign="start center">
<mat-slide-toggle tabindex="6" color="primary" name="taprootChannel" [(ngModel)]="taprootChannel">Taproot Channel</mat-slide-toggle>
</div>

@ -11,11 +11,14 @@ import { Peer, GetInfo } from '../../../../shared/models/lndModels';
import { OpenChannelAlert } from '../../../../shared/models/alertData';
import { APICallStatusEnum, LNDActions, TRANS_TYPES } from '../../../../shared/services/consts-enums-functions';
import { RecommendedFeeRates } from '../../../../shared/models/rtlModels';
import { RTLState } from '../../../../store/rtl.state';
import { rootSelectedNode } from '../../../../store/rtl.selector';
import { saveNewChannel } from '../../../store/lnd.actions';
import { Node } from '../../../../shared/models/RTLconfig';
import { CommonService } from '../../../../shared/services/common.service';
import { DataService } from '../../../../shared/services/data.service';
import { LoggerService } from '../../../../shared/services/logger.service';
@Component({
selector: 'rtl-open-channel',
@ -47,9 +50,12 @@ export class OpenChannelComponent implements OnInit, OnDestroy {
public spendUnconfirmed = false;
public transTypeValue = '';
public transTypes = TRANS_TYPES;
public recommendedFee: RecommendedFeeRates = { fastestFee: 0, halfHourFee: 0, hourFee: 0 };
private unSubs: Array<Subject<void>> = [new Subject(), new Subject(), new Subject(), new Subject()];
constructor(public dialogRef: MatDialogRef<OpenChannelComponent>, @Inject(MAT_DIALOG_DATA) public data: OpenChannelAlert, private store: Store<RTLState>, private actions: Actions, private commonService: CommonService) { }
constructor(private logger: LoggerService, public dialogRef: MatDialogRef<OpenChannelComponent>,
@Inject(MAT_DIALOG_DATA) public data: OpenChannelAlert, private store: Store<RTLState>,
private actions: Actions, private commonService: CommonService, private dataService: DataService) { }
ngOnInit() {
if (this.data.message) {
@ -138,7 +144,12 @@ export class OpenChannelComponent implements OnInit, OnDestroy {
}
onOpenChannel(): boolean | void {
if ((!this.peer && !this.selectedPubkey) || (!this.fundingAmount || ((this.totalBalance - this.fundingAmount) < 0) || ((this.selTransType === '1' || this.selTransType === '2') && !this.transTypeValue))) {
if (
(!this.peer && !this.selectedPubkey) ||
(!this.fundingAmount ||
((this.totalBalance - this.fundingAmount) < 0) || ((this.selTransType === '1' || this.selTransType === '2') && !this.transTypeValue)) ||
(this.selTransType === '2' && this.recommendedFee.minimumFee > +this.transTypeValue)
) {
return true;
}
// Taproot channel's commitment type is 5
@ -160,6 +171,19 @@ export class OpenChannelComponent implements OnInit, OnDestroy {
}
}
onSelTransTypeChanged(event) {
this.transTypeValue = '';
if (event.value === this.transTypes[2].id) {
this.dataService.getRecommendedFeeRates().pipe(takeUntil(this.unSubs[3])).subscribe({
next: (rfRes: RecommendedFeeRates) => {
this.recommendedFee = rfRes;
}, error: (err) => {
this.logger.error(err);
}
});
}
}
ngOnDestroy() {
this.unSubs.forEach((completeSub) => {
completeSub.next(<any>null);

Loading…
Cancel
Save