Commit 6418f25b authored by dev0tion's avatar dev0tion

Add Stratis to recovery process

parent 1f552fe5
......@@ -91,20 +91,45 @@ export class RecoverComponent implements OnInit {
private onRecoverClicked(){
this.walletRecovery = new WalletRecovery(
this.recoverWalletForm.get("walletName").value,
this.recoverWalletForm.get("walletMnemonic").value,
this.recoverWalletForm.get("walletPassword").value,
this.recoverWalletForm.get("selectNetwork").value,
this.globalService.getWalletPath(),
this.recoverWalletForm.get("walletName").value,
this.creationDate
);
this.recoverWallet(this.walletRecovery);
);
this.recoverWallets(this.walletRecovery);
}
private recoverWallet(recoverWallet: WalletRecovery) {
private recoverWallets(recoverWallet: WalletRecovery) {
this.apiService
.recoverBitcoinWallet(recoverWallet)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
//Bitcoin Wallet Recovered
}
},
error => {
console.log(error);
if (error.status === 0) {
alert("Something went wrong while connecting to the API. Please restart the application.");
} else if (error.status >= 400) {
if (!error.json().errors[0]) {
console.log(error);
}
else {
alert(error.json().errors[0].message);
}
}
},
() => this.recoverStratisWallet(recoverWallet)
)
;
}
private recoverStratisWallet(recoverWallet: WalletRecovery){
this.apiService
.recoverWallet(recoverWallet)
.recoverStratisWallet(recoverWallet)
.subscribe(
response => {
if (response.status >= 200 && response.status < 400) {
......@@ -126,6 +151,7 @@ export class RecoverComponent implements OnInit {
}
}
}
);
)
;
}
}
export class WalletRecovery {
constructor(mnemonic: string, password: string, network:string, folderPath: string, walletName: string, creationDate: Date) {
constructor(walletName: string, mnemonic: string, password: string, network:string, creationDate: Date, folderPath: string = null) {
this.name = walletName;
this.mnemonic = mnemonic;
this.password = password;
this.network = network;
this.folderPath = folderPath;
this.name = walletName;
this.creationDate = creationDate;
this.folderPath = folderPath;
}
mnemonic: string;
password: string;
folderPath: string;
name: string;
network: string;
creationDate: Date;
folderPath?: string;
}
......@@ -60,13 +60,20 @@ export class ApiService {
}
/**
* Recover a wallet.
* Recover a Bitcoin wallet.
*/
recoverWallet(data: WalletRecovery): Observable<any> {
this.getCurrentCoin();
recoverBitcoinWallet(data: WalletRecovery): Observable<any> {
return this.http
.post(this.bitcoinApiUrl + '/wallet/recover/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response);
}
/**
* Recover a Stratis wallet.
*/
recoverStratisWallet(data: WalletRecovery): Observable<any> {
return this.http
.post(this.currentApiUrl + '/wallet/recover/', JSON.stringify(data), {headers: this.headers})
.post(this.stratisApiUrl + '/wallet/recover/', JSON.stringify(data), {headers: this.headers})
.map((response: Response) => response);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment