Commit 6418f25b authored by dev0tion's avatar dev0tion

Add Stratis to recovery process

parent 1f552fe5
...@@ -91,20 +91,45 @@ export class RecoverComponent implements OnInit { ...@@ -91,20 +91,45 @@ export class RecoverComponent implements OnInit {
private onRecoverClicked(){ private onRecoverClicked(){
this.walletRecovery = new WalletRecovery( this.walletRecovery = new WalletRecovery(
this.recoverWalletForm.get("walletName").value,
this.recoverWalletForm.get("walletMnemonic").value, this.recoverWalletForm.get("walletMnemonic").value,
this.recoverWalletForm.get("walletPassword").value, this.recoverWalletForm.get("walletPassword").value,
this.recoverWalletForm.get("selectNetwork").value, this.recoverWalletForm.get("selectNetwork").value,
this.globalService.getWalletPath(),
this.recoverWalletForm.get("walletName").value,
this.creationDate 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 this.apiService
.recoverWallet(recoverWallet) .recoverStratisWallet(recoverWallet)
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
...@@ -126,6 +151,7 @@ export class RecoverComponent implements OnInit { ...@@ -126,6 +151,7 @@ export class RecoverComponent implements OnInit {
} }
} }
} }
); )
;
} }
} }
export class WalletRecovery { 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.mnemonic = mnemonic;
this.password = password; this.password = password;
this.network = network; this.network = network;
this.folderPath = folderPath;
this.name = walletName;
this.creationDate = creationDate; this.creationDate = creationDate;
this.folderPath = folderPath;
} }
mnemonic: string; mnemonic: string;
password: string; password: string;
folderPath: string;
name: string; name: string;
network: string; network: string;
creationDate: Date; creationDate: Date;
folderPath?: string;
} }
...@@ -60,13 +60,20 @@ export class ApiService { ...@@ -60,13 +60,20 @@ export class ApiService {
} }
/** /**
* Recover a wallet. * Recover a Bitcoin wallet.
*/ */
recoverWallet(data: WalletRecovery): Observable<any> { recoverBitcoinWallet(data: WalletRecovery): Observable<any> {
this.getCurrentCoin(); 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 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); .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