check mnemonic strings match
This commit is contained in:
parent
ef822f5bad
commit
fce9ef7f62
1 changed files with 22 additions and 14 deletions
|
|
@ -140,23 +140,31 @@ angular.module('copayApp.controllers').controller('backupController',
|
||||||
function confirm() {
|
function confirm() {
|
||||||
self.backupError = false;
|
self.backupError = false;
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var customWordList = lodash.pluck(self.customWords, 'word');
|
||||||
var separator = self.useIdeograms ? '\u3000' : ' ';
|
|
||||||
var customSentence = lodash.pluck(self.customWords, 'word').join(separator);
|
|
||||||
var passphrase = $scope.passphrase || '';
|
|
||||||
|
|
||||||
try {
|
if (!lodash.isEqual(self.mnemonicWords, customWordList)) {
|
||||||
walletClient.seedFromMnemonic(customSentence, {
|
return backupError('Mnemonic string mismatch')
|
||||||
network: fc.credentials.network,
|
|
||||||
passphrase: passphrase,
|
|
||||||
account: fc.credentials.account
|
|
||||||
})
|
|
||||||
} catch (err) {
|
|
||||||
return backupError(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (walletClient.credentials.xPrivKey != self.xPrivKey) {
|
if (self.mnemonicHasPassphrase) {
|
||||||
return backupError('Private key mismatch');
|
var walletClient = bwcService.getClient();
|
||||||
|
var separator = self.useIdeograms ? '\u3000' : ' ';
|
||||||
|
var customSentence = customWordList.join(separator);
|
||||||
|
var passphrase = $scope.passphrase || '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
walletClient.seedFromMnemonic(customSentence, {
|
||||||
|
network: fc.credentials.network,
|
||||||
|
passphrase: passphrase,
|
||||||
|
account: fc.credentials.account
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
return backupError(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (walletClient.credentials.xPrivKey != self.xPrivKey) {
|
||||||
|
return backupError('Private key mismatch');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.$emit('Local/BackupDone');
|
$rootScope.$emit('Local/BackupDone');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue