Merge pull request #4330 from isocolsky/optimize-backup-verif

Optimize backup verification
This commit is contained in:
Matias Alejo Garcia 2016-06-09 14:53:27 -03:00
commit 07064a8679

View file

@ -140,9 +140,16 @@ angular.module('copayApp.controllers').controller('backupController',
function confirm() { function confirm() {
self.backupError = false; self.backupError = false;
var customWordList = lodash.pluck(self.customWords, 'word');
if (!lodash.isEqual(self.mnemonicWords, customWordList)) {
return backupError('Mnemonic string mismatch')
}
if (self.mnemonicHasPassphrase) {
var walletClient = bwcService.getClient(); var walletClient = bwcService.getClient();
var separator = self.useIdeograms ? '\u3000' : ' '; var separator = self.useIdeograms ? '\u3000' : ' ';
var customSentence = lodash.pluck(self.customWords, 'word').join(separator); var customSentence = customWordList.join(separator);
var passphrase = $scope.passphrase || ''; var passphrase = $scope.passphrase || '';
try { try {
@ -158,6 +165,7 @@ angular.module('copayApp.controllers').controller('backupController',
if (walletClient.credentials.xPrivKey != self.xPrivKey) { if (walletClient.credentials.xPrivKey != self.xPrivKey) {
return backupError('Private key mismatch'); return backupError('Private key mismatch');
} }
}
$rootScope.$emit('Local/BackupDone'); $rootScope.$emit('Local/BackupDone');
}; };