diff --git a/index.html b/index.html
index 972943ea6..542a75b53 100644
--- a/index.html
+++ b/index.html
@@ -187,7 +187,9 @@
diff --git a/js/controllers/backup.js b/js/controllers/backup.js
index 5c468fe24..03c67f2bf 100644
--- a/js/controllers/backup.js
+++ b/js/controllers/backup.js
@@ -8,7 +8,7 @@ angular.module('copay.backup').controller('BackupController',
// TODO: get the real encrypted wallet.
var _getEncryptedWallet = function() {
- var wallet = JSON.stringify($rootScope.wallet.toObj());
+ var wallet = $rootScope.wallet.toEncryptedObj();
return wallet;
};
diff --git a/js/controllers/import.js b/js/controllers/import.js
index 43c3376c2..2d5630915 100644
--- a/js/controllers/import.js
+++ b/js/controllers/import.js
@@ -1,7 +1,7 @@
'use strict';
angular.module('copay.import').controller('ImportController',
- function($scope, $rootScope, walletFactory, controllerUtils) {
+ function($scope, $rootScope, walletFactory, controllerUtils, Passphrase) {
$scope.title = 'Import a backup';
$scope.getFile = function() {
@@ -10,13 +10,18 @@ angular.module('copay.import').controller('ImportController',
// If we use onloadend, we need to check the readyState.
reader.onloadend = function(evt) {
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
- var obj = JSON.parse(evt.target.result);
- $rootScope.wallet = walletFactory.fromObj(obj);
-
+ var encryptedObj = evt.target.result;
+ var passphrase = Passphrase.getBase64($scope.password);
+ $rootScope.wallet = walletFactory.fromEncryptedObj(encryptedObj, passphrase);
controllerUtils.startNetwork($rootScope.wallet);
}
};
- reader.readAsBinaryString($scope.file);
+ $scope.import = function() {
+ if ($scope.password != '') {
+ reader.readAsBinaryString($scope.file);
+ }
+ };
+
};
});