diff --git a/js/controllers/import.js b/js/controllers/import.js index 33fa8df23..9c802fa0c 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -36,10 +36,7 @@ angular.module('copayApp.controllers').controller('ImportController', $scope.error = 'Could not read wallet. Please check your password'; } else { controllerUtils.installWalletHandlers($scope, wallet); - updateStatus('Importing wallet - Scanning for transactions...'); - wallet.updateIndexes(function(err) { - controllerUtils.setFocusedWallet(wallet); - }); + controllerUtils.setFocusedWallet(wallet); } } ); diff --git a/js/controllers/importProfile.js b/js/controllers/importProfile.js index 358259790..a9a841a71 100644 --- a/js/controllers/importProfile.js +++ b/js/controllers/importProfile.js @@ -28,6 +28,7 @@ angular.module('copayApp.controllers').controller('ImportProfileController', passphraseConfig: config.passphraseConfig, }, function(err, iden) { if (err && !iden) { + $scope.loading = false; $scope.error = (err.toString() || '').match('BADSTR') ? 'Bad password or corrupt profile file' : 'Unknown error'; } else { var firstWallet = iden.getLastFocusedWallet(); @@ -54,14 +55,13 @@ angular.module('copayApp.controllers').controller('ImportProfileController', }; $scope.import = function(form) { + $scope.loading = true; if (form.$invalid) { $scope.loading = false; $scope.error = 'Please enter the required fields'; return; } - $rootScope.starting = true; - var backupFile = $scope.file; var backupText = form.backupText.$modelValue; var password = form.password.$modelValue; diff --git a/js/models/Identity.js b/js/models/Identity.js index 937c8e380..f516ce1e6 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -275,6 +275,9 @@ Identity.prototype.close = function(cb) { }, cb); }; + +// TODO: Add feedback function +// Identity.prototype.importWalletFromObj = function(obj, opts, cb) { var self = this; preconditions.checkArgument(cb); @@ -288,17 +291,21 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) { var w = importFunction(obj, readOpts); if (!w) return cb(new Error('Could not decrypt')); + log.debug('Wallet decryped:' + w.getName()); self._checkVersion(w.version); - self.addWallet(w); - self.bindWallet(w); - self.storeWallet(w, function(err) { - if (err) return cb(err); - - self.store({ - noWallets: true - }, function(err) { - return cb(err, w); + log.debug('Updating Indexes for wallet:' + w.getName()); + w.updateIndexes(function(err) { + log.debug('Adding wallet to profile:' + w.getName()); + self.addWallet(w); + self.bindWallet(w); + self.storeWallet(w, function(err) { + if (err) return cb(err); + self.store({ + noWallets: true + }, function(err) { + return cb(err, w); + }); }); }); }; @@ -348,11 +355,16 @@ Identity.importFromFullJson = function(str, password, opts, cb) { opts.email = email; opts.password = password; + if (!email) + return cb('BADSTR'); + var iden = new Identity(opts); json.wallets = json.wallets || {}; async.map(json.wallets, function(walletData, callback) { + if (!walletData) + return callback(); iden.importWalletFromObj(walletData, opts, function(err, w) { if (err) return callback(err); diff --git a/views/importProfile.html b/views/importProfile.html index 67c2b587a..a0ea36cef 100644 --- a/views/importProfile.html +++ b/views/importProfile.html @@ -1,6 +1,11 @@
+
+ {{ importStatus|translate }} +
+ +
Copay @@ -19,7 +24,7 @@
- Choose backup file from your computer + Choose backup file @@ -57,6 +62,7 @@
+