diff --git a/js/controllers/import.js b/js/controllers/import.js index 6d83e62a5..22b4a50ae 100644 --- a/js/controllers/import.js +++ b/js/controllers/import.js @@ -30,7 +30,7 @@ angular.module('copayApp.controllers').controller('ImportController', $rootScope.iden.importEncryptedWallet(encryptedObj, password, skipFields, opts, function(err, w) { if (!w) { $scope.loading = false; - notification.error('Error', err || 'Wrong password'); + $scope.error = 'Wrong password'; $rootScope.$digest(); return; } @@ -47,7 +47,7 @@ angular.module('copayApp.controllers').controller('ImportController', updateStatus('Importing wallet - We are almost there...'); if (err) { $scope.loading = false; - notification.error('Error', 'Error updating indexes: ' + err); + $scope.error = 'Error updating indexes: ' + err; } controllerUtils.installWalletHandlers($scope, w); controllerUtils.setFocusedWallet(w); @@ -72,7 +72,7 @@ angular.module('copayApp.controllers').controller('ImportController', function(err, wallet) { if (err) { $scope.loading = false; - notification.error('Error', 'Could not read wallet. Please check your password'); + $scope.error = 'Could not read wallet. Please check your password'; } else { controllerUtils.installWalletHandlers($scope, wallet); controllerUtils.setFocusedWallet(wallet); @@ -89,7 +89,7 @@ angular.module('copayApp.controllers').controller('ImportController', if (form.$invalid) { $scope.loading = false; - notification.error('Error', 'There is an error in the form.'); + $scope.error = 'There is an error in the form'; return; } @@ -104,8 +104,7 @@ angular.module('copayApp.controllers').controller('ImportController', if (!backupFile && !backupText) { $scope.loading = false; - notification.error('Error', 'Please, select your backup file'); - $scope.loading = false; + $scope.error = 'Please, select your backup file'; return; } @@ -115,7 +114,7 @@ angular.module('copayApp.controllers').controller('ImportController', copay.Compatibility.importEncryptedWallet($rootScope.iden, backupText, $scope.password, {}, function(err, wallet) { if (err) { - notification.error('Error', 'Could not read wallet. Please check your password'); + $scope.error = 'Could not read wallet. Please check your password'; } else { copay.Compatibility.deleteOldWallet(backupOldWallet); controllerUtils.installWalletHandlers($scope, wallet); diff --git a/js/models/Identity.js b/js/models/Identity.js index 536c90274..046aaf6b0 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -288,7 +288,18 @@ Identity.prototype.close = function(cb) { Identity.prototype.importEncryptedWallet = function(cypherText, password, opts, cb) { var crypto = opts.cryptoUtil || cryptoUtil; var obj = crypto.decrypt(password, cypherText); - if (!obj) return cb(new Error('Could not decrypt')); +console.log('[Identity.js.290:obj:]',obj); //TODO + + if (!obj) { + // 0.7.3 broken KDF + log.debug('Trying legacy encryption...'); + var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100); + obj = crypto.decrypt(passphrase, ejson); + } +console.log('[Identity.js.300:obj:]',obj); //TOD + + if (!obj) + return cb(new Error('Could not decrypt')); try { obj = JSON.parse(obj); } catch (e) { @@ -338,13 +349,21 @@ Identity.prototype.closeWallet = function(wallet, cb) { }); }; -Identity.importFromEncryptedFullJson = function(str, password, opts, cb) { +Identity.importFromEncryptedFullJson = function(ejson, password, opts, cb) { var crypto = opts.cryptoUtil || cryptoUtil; - var str = crypto.decrypt(password, str); + var str = crypto.decrypt(password, ejson); + if (!str) { - return cb('BADSTR'); + // 0.7.3 broken KDF + log.debug('Trying legacy encryption...'); + var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100); + str = crypto.decrypt(passphrase, ejson); } + + if (!str) + return cb('BADSTR'); + return Identity.importFromFullJson(str, password, opts, cb); }; diff --git a/views/import.html b/views/import.html index 8b3ec1f33..19e8d5068 100644 --- a/views/import.html +++ b/views/import.html @@ -10,6 +10,13 @@
+

+ + {{error|translate}} +

+ +
Choose backup file from your computer