mirror of https://github.com/BTCPrivate/copay.git
receive view
This commit is contained in:
parent
f8bc0a1d8f
commit
e9616e7289
|
@ -87,7 +87,7 @@
|
|||
|
||||
<ion-item *ngIf="formData.selectedSeed.id == 'new'">
|
||||
<ion-label stacked>Testnet</ion-label>
|
||||
<ion-toggle [(ngModel)]="formData.testnet" formControlName="testnet" (ionChange)="setDerivationPath()"></ion-toggle>
|
||||
<ion-toggle [(ngModel)]="formData.testnetEnabled" formControlName="testnetEnabled" (ionChange)="setDerivationPath()"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
<ion-item *ngIf="formData.selectedSeed.id == 'set'">
|
||||
|
|
|
@ -76,7 +76,7 @@ export class CreateWalletPage implements OnInit {
|
|||
confirmPassword: [''],
|
||||
recoveryPhraseBackedUp: [''],
|
||||
derivationPath: [''],
|
||||
testnet: [''],
|
||||
testnetEnabled: [''],
|
||||
singleAddress: [''],
|
||||
});
|
||||
|
||||
|
@ -162,9 +162,7 @@ export class CreateWalletPage implements OnInit {
|
|||
coin: this.formData.coin
|
||||
};
|
||||
|
||||
console.log(opts);
|
||||
this.profileProvider.createWallet(opts).then((wallet) => {
|
||||
console.log(wallet);
|
||||
this.navCtrl.setRoot(HomePage);
|
||||
this.navCtrl.popToRoot();
|
||||
});
|
||||
|
|
|
@ -23,7 +23,6 @@ export class HomePage {
|
|||
) {
|
||||
this.checkUpdate();
|
||||
this.wallets = this.profileProvider.getWallets();
|
||||
console.log(this.wallets);
|
||||
this.updateAllWallets();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { NavController, NavParams } from 'ionic-angular';
|
||||
import { AmountPage } from '../send/amount/amount';
|
||||
import { WalletProvider } from '../../providers/wallet/wallet';
|
||||
import { ProfileProvider } from '../../providers/profile/profile';
|
||||
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@Component({
|
||||
selector: 'page-receive',
|
||||
|
@ -11,27 +15,57 @@ export class ReceivePage {
|
|||
public protocolHandler: string;
|
||||
public address: string;
|
||||
public qrAddress: string;
|
||||
public wallets: any;
|
||||
public wallet: any;
|
||||
|
||||
constructor(public navCtrl: NavController, public navParams: NavParams) {
|
||||
this.protocolHandler = "bitcoin";
|
||||
this.address = "1FgGP9dKqtWC1Q9xGhPYVmAeyezeZCFjhf";
|
||||
constructor(
|
||||
private navCtrl: NavController,
|
||||
private navParams: NavParams,
|
||||
private profileProvider: ProfileProvider,
|
||||
private walletProvider: WalletProvider
|
||||
) {
|
||||
this.wallets = this.profileProvider.getWallets();
|
||||
this.updateQrAddress();
|
||||
}
|
||||
|
||||
ionViewDidLoad() {
|
||||
console.log('ionViewDidLoad ReceivePage');
|
||||
this.onSelect(this.checkSelectedWallet(this.wallet, this.wallets));
|
||||
}
|
||||
|
||||
requestSpecificAmount() {
|
||||
this.navCtrl.push(AmountPage, {address: this.address, sending: false});
|
||||
private onSelect(wallet: any): any {
|
||||
this.wallet = wallet;
|
||||
this.setProtocolHandler();
|
||||
this.setAddress();
|
||||
}
|
||||
|
||||
setAddress() {
|
||||
this.address = this.address === "1FgGP9dKqtWC1Q9xGhPYVmAeyezeZCFjhf" ? "1RTes3reeRTs1Q9xGhPYVmQFrdUyCr3EsX" : "1FgGP9dKqtWC1Q9xGhPYVmAeyezeZCFjhf";
|
||||
this.updateQrAddress();
|
||||
private setProtocolHandler(): void {
|
||||
this.protocolHandler = this.walletProvider.getProtocolHandler(this.wallet);
|
||||
}
|
||||
|
||||
updateQrAddress () {
|
||||
private checkSelectedWallet(wallet: any, wallets: any): any {
|
||||
if (!wallet) return wallets[0];
|
||||
let w = _.find(wallets, (w: any) => {
|
||||
return w.id == wallet.id;
|
||||
});
|
||||
if (!w) return wallets[0];
|
||||
return wallet;
|
||||
}
|
||||
|
||||
public requestSpecificAmount(): void {
|
||||
this.navCtrl.push(AmountPage, { address: this.address, sending: false });
|
||||
}
|
||||
|
||||
private setAddress(newAddr?: boolean): void {
|
||||
this.walletProvider.getAddress(this.wallet, newAddr).then((addr) => {
|
||||
this.address = addr;
|
||||
this.updateQrAddress();
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
|
||||
private updateQrAddress(): void {
|
||||
this.qrAddress = this.protocolHandler + ":" + this.address;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ export class ProfileProvider {
|
|||
private needsBackup(wallet: any): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.requiresBackup(wallet)) {
|
||||
return reject(false);
|
||||
return resolve(false);
|
||||
}
|
||||
|
||||
this.persistenceProvider.getBackupFlag(wallet.credentials.walletId).then((val: string) => {
|
||||
|
@ -218,13 +218,13 @@ export class ProfileProvider {
|
|||
}
|
||||
return resolve();
|
||||
}).catch((err: any) => {
|
||||
return reject(err);
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public setLastKnownBalance(wid: string, balance: number): void {
|
||||
this.persistenceProvider.setBalanceCache(wid, { balance: balance, updatedOn: Math.floor(Date.now() / 1000), });
|
||||
this.persistenceProvider.setBalanceCache(wid, { balance: balance, updatedOn: Math.floor(Date.now() / 1000) });
|
||||
}
|
||||
|
||||
private runValidation(wallet: any, delay?: number, retryDelay?: number) {
|
||||
|
|
|
@ -223,6 +223,8 @@ export class WalletProvider {
|
|||
|
||||
cache.alternativeBalanceAvailable = true;
|
||||
cache.isRateAvailable = true;
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -290,7 +292,7 @@ export class WalletProvider {
|
|||
resolve(status);
|
||||
}).catch((err) => {
|
||||
return reject(err);
|
||||
});;
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -309,7 +311,7 @@ export class WalletProvider {
|
|||
});
|
||||
}
|
||||
|
||||
private getAddress(wallet: any, forceNew: boolean): Promise<any> {
|
||||
public getAddress(wallet: any, forceNew: boolean): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.persistenceProvider.getLastAddress(wallet.id).then((addr) => {
|
||||
if (!forceNew && addr) return resolve(addr);
|
||||
|
|
Loading…
Reference in New Issue