mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #6857 from JDonadio/new/create-single-wallet
New/create single wallet
This commit is contained in:
commit
5a725acd72
|
@ -25,6 +25,7 @@ import { CopayApp } from './app.component';
|
|||
|
||||
/* Pages */
|
||||
import { AddPage } from '../pages/add/add';
|
||||
import { SingleWalletPage } from '../pages/add/single-wallet/single-wallet';
|
||||
import { BackupRequestPage } from '../pages/onboarding/backup-request/backup-request';
|
||||
import { DisclaimerPage } from '../pages/onboarding/disclaimer/disclaimer';
|
||||
import { EmailPage } from '../pages/onboarding/email/email';
|
||||
|
@ -75,6 +76,7 @@ export function createTranslateLoader(http: Http) {
|
|||
|
||||
let pages: any = [
|
||||
AddPage,
|
||||
SingleWalletPage,
|
||||
AboutPage,
|
||||
AdvancedPage,
|
||||
AltCurrencyPage,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { NavController } from 'ionic-angular';
|
||||
import { SingleWalletPage } from "./single-wallet/single-wallet";
|
||||
|
||||
@Component({
|
||||
selector: 'page-add',
|
||||
|
@ -13,7 +14,7 @@ export class AddPage {
|
|||
}
|
||||
|
||||
goToSingleWallet() {
|
||||
// this.navCtrl.push();
|
||||
this.navCtrl.push(SingleWalletPage);
|
||||
}
|
||||
|
||||
goToSharedeWallet() {
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>Create personal wallet</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content>
|
||||
<form [formGroup]="createForm" (ngSubmit)="create()">
|
||||
<ion-item>
|
||||
<ion-label stacked>Wallet name</ion-label>
|
||||
<ion-input type="text" [(ngModel)]="formData.walletName" formControlName="walletName" required></ion-input>
|
||||
</ion-item>
|
||||
|
||||
<ion-item-divider color="light"></ion-item-divider>
|
||||
|
||||
<ion-item (click)="showAdvOpts = !showAdvOpts">
|
||||
<ion-label *ngIf="!showAdvOpts">Show advanced options</ion-label>
|
||||
<ion-label *ngIf="showAdvOpts">Hide advanced options</ion-label>
|
||||
</ion-item>
|
||||
|
||||
<div *ngIf="showAdvOpts">
|
||||
<ion-item>
|
||||
<ion-label stacked>Wallet service URL</ion-label>
|
||||
<ion-input type="text" [(ngModel)]="formData.bwsURL" formControlName="bwsURL"></ion-input>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label stacked>Wallet key</ion-label>
|
||||
<ion-select [(ngModel)]="formData.selectedSeed.id" formControlName="selectedSeed" (ionChange)="seedOptionsChange(formData.selectedSeed.id)">
|
||||
<ion-option *ngFor="let opt of seedOptions" [value]="opt.id">{{opt.label}}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label stacked>Add a password</ion-label>
|
||||
<ion-toggle [(ngModel)]="formData.addPassword" formControlName="addPassword" (ionChange)="resetPasswordFields()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<div *ngIf="formData.addPassword">
|
||||
<ion-item>
|
||||
<ion-label stacked>Password</ion-label>
|
||||
<ion-input type="password" [(ngModel)]="formData.password" formControlName="password"></ion-input>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label stacked>Confirm password</ion-label>
|
||||
<ion-input type="password" [(ngModel)]="formData.confirmPassword" formControlName="confirmPassword"></ion-input>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<div class="warning">
|
||||
<strong translate>This password cannot be recovered. If the password is lost, there is no way you could recover your funds.</strong>
|
||||
</div>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label stacked>I have written it down</ion-label>
|
||||
<ion-checkbox [(ngModel)]="formData.writtenDown" formControlName="writtenDown" checked="false"></ion-checkbox>
|
||||
</ion-item>
|
||||
</div>
|
||||
|
||||
<ion-item>
|
||||
<ion-label stacked>Testnet</ion-label>
|
||||
<ion-toggle [(ngModel)]="formData.testnet" formControlName="testnet"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<ion-label stacked>Single address</ion-label>
|
||||
<ion-toggle [(ngModel)]="formData.singleAddress" formControlName="singleAddress"></ion-toggle>
|
||||
</ion-item>
|
||||
</div>
|
||||
<button ion-button block type="submit" [disabled]="!createForm.valid || validatePasswords()">Create wallet</button>
|
||||
</form>
|
||||
</ion-content>
|
|
@ -0,0 +1,9 @@
|
|||
.warning {
|
||||
background-color: #ef473a;
|
||||
border-color: #e42112;
|
||||
color: #fff;
|
||||
padding: 0.5rem;
|
||||
border: 1px solid;
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { NavController } from 'ionic-angular';
|
||||
import { Validators, FormBuilder, FormGroup } from '@angular/forms';
|
||||
|
||||
import { AppProvider } from '../../../providers/app/app';
|
||||
|
||||
@Component({
|
||||
selector: 'page-single-wallet',
|
||||
templateUrl: 'single-wallet.html'
|
||||
})
|
||||
export class SingleWalletPage implements OnInit{
|
||||
public formData: any;
|
||||
public showAdvOpts: boolean;
|
||||
public seedOptions: any;
|
||||
|
||||
private appName: string;
|
||||
private createForm: FormGroup;
|
||||
|
||||
constructor(
|
||||
public navCtrl: NavController,
|
||||
private app: AppProvider,
|
||||
private fb: FormBuilder
|
||||
) {
|
||||
this.showAdvOpts = false;
|
||||
this.formData = {
|
||||
walletName: null,
|
||||
bwsURL: 'https://bws.bitpay.com/bws/api',
|
||||
addPassword: false,
|
||||
password: null,
|
||||
confirmPassword: null,
|
||||
writtenDown: false,
|
||||
testnet: false,
|
||||
singleAddress: false,
|
||||
};
|
||||
this.appName = this.app.info.name;
|
||||
this.updateSeedSourceSelect(1);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.createForm = this.fb.group({
|
||||
walletName: ['', Validators.required],
|
||||
bwsURL: [''],
|
||||
selectedSeed: [''],
|
||||
addPassword: [''],
|
||||
password: [''],
|
||||
confirmPassword: [''],
|
||||
writtenDown: ['false'],
|
||||
testnet: [''],
|
||||
singleAddress: [''],
|
||||
});
|
||||
|
||||
this.createForm.get('addPassword').valueChanges.subscribe((addPassword: boolean) => {
|
||||
if (addPassword) {
|
||||
this.createForm.get('password').setValidators([Validators.required]);
|
||||
this.createForm.get('confirmPassword').setValidators([Validators.required]);
|
||||
}else {
|
||||
this.createForm.get('password').clearValidators();
|
||||
this.createForm.get('confirmPassword').clearValidators();
|
||||
}
|
||||
this.createForm.get('password').updateValueAndValidity();
|
||||
this.createForm.get('confirmPassword').updateValueAndValidity();
|
||||
})
|
||||
}
|
||||
|
||||
validatePasswords() {
|
||||
if (this.formData.addPassword) {
|
||||
if (this.formData.password == this.formData.confirmPassword) {
|
||||
if (this.formData.writtenDown) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
updateSeedSourceSelect(n: number) {
|
||||
this.seedOptions = [{
|
||||
id: 'new',
|
||||
label: 'Random',
|
||||
supportsTestnet: true
|
||||
}, {
|
||||
id: 'set',
|
||||
label: 'Specify Recovery Phrase...',
|
||||
supportsTestnet: false
|
||||
}];
|
||||
this.formData.selectedSeed = {
|
||||
id: this.seedOptions[0].id
|
||||
};
|
||||
|
||||
/* Disable Hardware Wallets for BitPay distribution */
|
||||
var opts = [];
|
||||
|
||||
if (this.appName == 'copay') {
|
||||
// if (n > 1 && walletService.externalSource.ledger.supported)
|
||||
// opts.push({
|
||||
// id: walletService.externalSource.ledger.id,
|
||||
// label: walletService.externalSource.ledger.longName,
|
||||
// supportsTestnet: walletService.externalSource.ledger.supportsTestnet
|
||||
// });
|
||||
|
||||
// if (walletService.externalSource.trezor.supported) {
|
||||
// opts.push({
|
||||
// id: walletService.externalSource.trezor.id,
|
||||
// label: walletService.externalSource.trezor.longName,
|
||||
// supportsTestnet: walletService.externalSource.trezor.supportsTestnet
|
||||
// });
|
||||
// }
|
||||
|
||||
// if (walletService.externalSource.intelTEE.supported) {
|
||||
// opts.push({
|
||||
// id: walletService.externalSource.intelTEE.id,
|
||||
// label: walletService.externalSource.intelTEE.longName,
|
||||
// supportsTestnet: walletService.externalSource.intelTEE.supportsTestnet
|
||||
// });
|
||||
// }
|
||||
}
|
||||
this.seedOptions = this.seedOptions.concat(opts);
|
||||
};
|
||||
|
||||
seedOptionsChange(seed: any) {
|
||||
this.formData.selectedSeed.id = seed;
|
||||
this.resetPasswordFields();
|
||||
}
|
||||
|
||||
resetPasswordFields() {
|
||||
this.formData.password = null;
|
||||
this.formData.confirmPassword = null;
|
||||
this.formData.writtenDown = false;
|
||||
}
|
||||
|
||||
create() {
|
||||
console.log(this.formData);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue