You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import { Component, OnDestroy } from '@angular/core';
|
|
import { Subject } from 'rxjs';
|
|
import { takeUntil } from 'rxjs/operators';
|
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
|
|
import { DataService } from '../../../shared/services/data.service';
|
|
import { LoggerService } from '../../../shared/services/logger.service';
|
|
|
|
@Component({
|
|
selector: 'rtl-cln-verify',
|
|
templateUrl: './verify.component.html',
|
|
styleUrls: ['./verify.component.scss']
|
|
})
|
|
export class CLNVerifyComponent implements OnDestroy {
|
|
|
|
public message = '';
|
|
public verifiedMessage = '';
|
|
public signature = '';
|
|
public verifiedSignature = '';
|
|
public showVerifyStatus = false;
|
|
public verifyRes = { pubkey: '', verified: null };
|
|
private unSubs: Array<Subject<void>> = [new Subject(), new Subject()];
|
|
|
|
constructor(private dataService: DataService, private snackBar: MatSnackBar, private logger: LoggerService) { }
|
|
|
|
onVerify(): boolean | void {
|
|
if ((!this.message || this.message === '') || (!this.signature || this.signature === '')) {
|
|
return true;
|
|
}
|
|
this.dataService.verifyMessage(this.message, this.signature).pipe(takeUntil(this.unSubs[0])).
|
|
subscribe((res) => {
|
|
this.verifyRes = res;
|
|
this.showVerifyStatus = true;
|
|
this.verifiedMessage = this.message;
|
|
this.verifiedSignature = this.signature;
|
|
});
|
|
}
|
|
|
|
onChange() {
|
|
if (this.verifiedMessage !== this.message || this.verifiedSignature !== this.signature) {
|
|
this.showVerifyStatus = false;
|
|
this.verifyRes = { pubkey: '', verified: null };
|
|
}
|
|
}
|
|
|
|
resetData() {
|
|
this.message = '';
|
|
this.signature = '';
|
|
this.verifyRes = null;
|
|
this.showVerifyStatus = false;
|
|
}
|
|
|
|
onCopyField(payload: string) {
|
|
this.snackBar.open('Pubkey copied.');
|
|
this.logger.info('Copied Text: ' + payload);
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.unSubs.forEach((completeSub) => {
|
|
completeSub.next(<any>null);
|
|
completeSub.complete();
|
|
});
|
|
}
|
|
|
|
}
|