Merge pull request #1609 from cmgustavo/feature/import-from-localstorage
Import Old wallets from localStorage
This commit is contained in:
commit
fcb2401fff
13 changed files with 67 additions and 81 deletions
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
|
||||
controllerUtils.redirIfLogged();
|
||||
$scope.retreiving = true;
|
||||
|
||||
identityService.check($scope);
|
||||
$scope.retreiving = false;
|
||||
|
||||
$scope.createProfile = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
|
||||
angular.module('copayApp.controllers').controller('HomeController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService, Compatibility) {
|
||||
controllerUtils.redirIfLogged();
|
||||
$scope.retreiving = true;
|
||||
|
||||
identityService.check($scope);
|
||||
$scope.confirmedEmail = getParam('confirmed');
|
||||
$scope.retreiving = false;
|
||||
Compatibility.check($scope);
|
||||
|
||||
$scope.openProfile = function(form) {
|
||||
if (form && form.$invalid) {
|
||||
notification.error('Error', 'Please enter the required fields');
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
$scope.hideAdv = true;
|
||||
$scope.is_iOS = isMobile.iOS();
|
||||
|
||||
Compatibility.check($scope);
|
||||
|
||||
var reader = new FileReader();
|
||||
|
||||
var updateStatus = function(status) {
|
||||
|
|
@ -65,7 +67,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
reader.onloadend = function(evt) {
|
||||
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
|
||||
var encryptedObj = evt.target.result;
|
||||
Compatibility.importEncryptedWallet($rootScope.iden, encryptedObj, $scope.password, {},
|
||||
copay.Compatibility.importEncryptedWallet($rootScope.iden, encryptedObj, $scope.password, {},
|
||||
function(err, wallet){
|
||||
if (err) {
|
||||
notification.error('Error', 'Could not read wallet. Please check your password');
|
||||
|
|
@ -91,8 +93,13 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
|
||||
var backupFile = $scope.file;
|
||||
var backupText = form.backupText.$modelValue;
|
||||
var backupOldWallet = form.backupOldWallet.$modelValue;
|
||||
var password = form.password.$modelValue;
|
||||
|
||||
if (backupOldWallet) {
|
||||
backupText = backupOldWallet.value;
|
||||
}
|
||||
|
||||
if (!backupFile && !backupText) {
|
||||
$scope.loading = false;
|
||||
notification.error('Error', 'Please, select your backup file');
|
||||
|
|
@ -104,11 +111,12 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
reader.readAsBinaryString(backupFile);
|
||||
}
|
||||
else {
|
||||
Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {},
|
||||
copay.Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {},
|
||||
function(err, wallet){
|
||||
if (err) {
|
||||
notification.error('Error', 'Could not read wallet. Please check your password');
|
||||
} else {
|
||||
copay.Compatibility.deleteOldWallet(backupOldWallet);
|
||||
controllerUtils.installWalletHandlers($scope, wallet);
|
||||
controllerUtils.setFocusedWallet(wallet);
|
||||
return;
|
||||
|
|
@ -118,7 +126,7 @@ angular.module('copayApp.controllers').controller('ImportController',
|
|||
try {
|
||||
_importBackup(backupText);
|
||||
} catch(e) {
|
||||
Compatibility.importEncryptedWallet(backupText, $scope.password, $scope.skipPublicKeyRing, $scope.skipTxProposals);
|
||||
copay.Compatibility.importEncryptedWallet(backupText, $scope.password, $scope.skipPublicKeyRing, $scope.skipTxProposals);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue