diff --git a/public/views/backup.html b/public/views/backup.html
index 61051c585..621d20cb9 100644
--- a/public/views/backup.html
+++ b/public/views/backup.html
@@ -118,9 +118,10 @@
+
-
+
+
diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js
index 4ade95ce5..9a663f726 100644
--- a/src/js/controllers/backup.js
+++ b/src/js/controllers/backup.js
@@ -6,14 +6,11 @@ angular.module('copayApp.controllers').controller('backupController',
var self = this;
var fc = profileService.focusedClient;
var customWords = [];
- var mnemonic = null;
function init() {
$scope.passphrase = '';
resetAllButtons();
customWords = [];
- mnemonic = null;
- self.xPrivKey = null;
self.step = 1;
self.deleted = false;
self.credentialsEncrypted = false;
@@ -26,11 +23,13 @@ angular.module('copayApp.controllers').controller('backupController',
if (fc.credentials && !fc.credentials.mnemonicEncrypted && !fc.credentials.mnemonic)
self.deleted = true;
- if (fc.isPrivKeyEncrypted()) {
+ if (fc.isPrivKeyEncrypted() && !self.deleted) {
self.credentialsEncrypted = true;
passwordRequest();
- } else
- setWords(getMnemonic());
+ } else {
+ if (!self.deleted)
+ initWords();
+ }
function getMnemonic() {
mnemonic = fc.getMnemonic();
@@ -50,13 +49,21 @@ angular.module('copayApp.controllers').controller('backupController',
}
}
- function setWords(words) {
- if (words) {
- self.mnemonicWords = words.split(/[\u3000\s]+/);
- self.shuffledMnemonicWords = lodash.sortBy(self.mnemonicWords);
- self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
- self.useIdeograms = words.indexOf("\u3000") >= 0;
- }
+ function initWords() {
+ var words = fc.getMnemonic();
+ console.log('words: ', fc.getMnemonic());
+ console.log('credentials: ', fc.credentials);
+ self.xPrivKey = fc.credentials.xPrivKey;
+ profileService.lockFC();
+
+ self.mnemonicWords = words.split(/[\u3000\s]+/);
+ self.shuffledMnemonicWords = lodash.sortBy(self.mnemonicWords);;
+ self.mnemonicHasPassphrase = fc.mnemonicHasPassphrase();
+ self.useIdeograms = words.indexOf("\u3000") >= 0;
+
+ console.log('self.mnemonicWords: ', self.mnemonicWords);
+ console.log('self.shuffledMnemonicWords: ', self.shuffledMnemonicWords);
+ console.log('self.mnemonicHasPassphrase: ', self.mnemonicHasPassphrase);
};
self.toggle = function() {
@@ -72,7 +79,7 @@ angular.module('copayApp.controllers').controller('backupController',
function passwordRequest() {
try {
- setWords(getMnemonic());
+ initWords();
} catch (e) {
if (e.message && e.message.match(/encrypted/) && fc.isPrivKeyEncrypted()) {
@@ -88,7 +95,7 @@ angular.module('copayApp.controllers').controller('backupController',
}
self.credentialsEncrypted = false;
- setWords(getMnemonic());
+ initWords();
$timeout(function() {
$scope.$apply();
@@ -99,10 +106,10 @@ angular.module('copayApp.controllers').controller('backupController',
}
function resetAllButtons() {
- var node = document.getElementById('addWord');
- node.innerHTML = '';
- lodash.each(self.mnemonicWords, function(d) {
- document.getElementById(d).disabled = false;
+ document.getElementById('addWord').innerHTML = '';
+ var nodes = document.getElementById("buttons").getElementsByTagName('button');
+ lodash.each(nodes, function(n) {
+ document.getElementById(n.id).disabled = false;
});
}
@@ -113,15 +120,19 @@ angular.module('copayApp.controllers').controller('backupController',
});
}
- self.disableButton = function(word) {
- document.getElementById(word).disabled = true;
- customWords.push(word);
- self.addButton(word);
+ self.disableButton = function(index, word) {
+ var element = {
+ index: index,
+ word: word
+ };
+ document.getElementById(index + word).disabled = true;
+ customWords.push(element);
+ self.addButton(index, word);
}
- self.addButton = function(word) {
- var btnhtml = '