@ -11,11 +11,14 @@ import { Peer, GetInfo } from '../../../../shared/models/lndModels';
import { OpenChannelAlert } from '../../../../shared/models/alertData' ;
import { OpenChannelAlert } from '../../../../shared/models/alertData' ;
import { APICallStatusEnum , LNDActions , TRANS_TYPES } from '../../../../shared/services/consts-enums-functions' ;
import { APICallStatusEnum , LNDActions , TRANS_TYPES } from '../../../../shared/services/consts-enums-functions' ;
import { RecommendedFeeRates } from '../../../../shared/models/rtlModels' ;
import { RTLState } from '../../../../store/rtl.state' ;
import { RTLState } from '../../../../store/rtl.state' ;
import { rootSelectedNode } from '../../../../store/rtl.selector' ;
import { rootSelectedNode } from '../../../../store/rtl.selector' ;
import { saveNewChannel } from '../../../store/lnd.actions' ;
import { saveNewChannel } from '../../../store/lnd.actions' ;
import { Node } from '../../../../shared/models/RTLconfig' ;
import { Node } from '../../../../shared/models/RTLconfig' ;
import { CommonService } from '../../../../shared/services/common.service' ;
import { CommonService } from '../../../../shared/services/common.service' ;
import { DataService } from '../../../../shared/services/data.service' ;
import { LoggerService } from '../../../../shared/services/logger.service' ;
@Component ( {
@Component ( {
selector : 'rtl-open-channel' ,
selector : 'rtl-open-channel' ,
@ -47,9 +50,12 @@ export class OpenChannelComponent implements OnInit, OnDestroy {
public spendUnconfirmed = false ;
public spendUnconfirmed = false ;
public transTypeValue = '' ;
public transTypeValue = '' ;
public transTypes = TRANS_TYPES ;
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 ( ) ] ;
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() {
ngOnInit() {
if ( this . data . message ) {
if ( this . data . message ) {
@ -138,7 +144,12 @@ export class OpenChannelComponent implements OnInit, OnDestroy {
}
}
onOpenChannel ( ) : boolean | void {
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 ;
return true ;
}
}
// Taproot channel's commitment type is 5
// 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() {
ngOnDestroy() {
this . unSubs . forEach ( ( completeSub ) = > {
this . unSubs . forEach ( ( completeSub ) = > {
completeSub . next ( < any > null ) ;
completeSub . next ( < any > null ) ;