From ea7c8c5383167226359c6da93bc56c5b7fe309ad Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 16:22:54 -0300 Subject: [PATCH] fix backup --- public/views/backup.html | 4 ++++ src/js/controllers/backup.js | 26 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/public/views/backup.html b/public/views/backup.html index 1606bff0f..46cb5ce27 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -7,6 +7,10 @@   + +
+delete mnemonics. You can still export it. +
diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 19a6ccdfb..ad8c3cd3e 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -4,29 +4,34 @@ angular.module('copayApp.controllers').controller('backupController', function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) { var wallet = profileService.getWallet($stateParams.walletId); - var xPriv6; $scope.walletName = wallet.credentials.walletName; $scope.n = wallet.n; + var keys; $scope.credentialsEncrypted = wallet.isPrivKeyEncrypted(); var isDeletedSeed = function() { - if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted)) + if (!wallet.credentials.mnemonic && !wallet.credentials.mnemonicEncrypted) return true; + return false; }; $scope.init = function() { $scope.deleted = isDeletedSeed(); - if ($scope.deleted) return; + if ($scope.deleted) { + $log.debug('no mnemonics'); + return; + } - walletService.getKeys(wallet, function(err, keys) { - if (err) { - $state.go('preferences'); + walletService.getKeys(wallet, function(err, k) { + if (err || !k) { + $state.go('wallet.preferences'); return; } $scope.credentialsEncrypted = false; - $scope.initFlow(keys); + keys = k; + $scope.initFlow(); }); }; @@ -41,9 +46,10 @@ angular.module('copayApp.controllers').controller('backupController', }); }; - $scope.initFlow = function(keys) { + $scope.initFlow = function() { + if (!keys) return; + var words = keys.mnemonic; - xPriv6 = keys.xPrivKey.substr(wallet.credentials.xPrivKey.length - 6); $scope.mnemonicWords = words.split(/[\u3000\s]+/); $scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords); @@ -127,7 +133,7 @@ angular.module('copayApp.controllers').controller('backupController', return cb(err); } - if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey-6) != xPriv6) { + if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey) != keys.xPrivKey) { delete walletClient.credentials; return cb('Private key mismatch'); }