Skip to content

Commit

Permalink
Merge pull request bitpay#596 from JDonadio/fix/import-with-pk-encrypted
Browse files Browse the repository at this point in the history
Fix import wallet with pk encrypted
  • Loading branch information
cmgustavo authored Oct 19, 2016
2 parents 5d45e30 + 1884f64 commit ff931ec
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/js/services/profileService.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,16 @@ angular.module('copayApp.services')
$log.debug('Importing Wallet:', opts);

try {
var c = JSON.parse(str);

if (c.xPrivKey && c.xPrivKeyEncrypted) {
$log.warn('Found both encrypted and decrypted key. Deleting the encrypted version');
delete c.xPrivKeyEncrypted;
delete c.mnemonicEncrypted;
}

str = JSON.stringify(c);

walletClient.import(str, {
compressed: opts.compressed,
password: opts.password
Expand All @@ -609,14 +619,6 @@ angular.module('copayApp.services')
return cb(gettext('Could not import. Check input file and spending password'));
}

str = JSON.parse(str);

if (str.xPrivKey && str.xPrivKeyEncrypted) {
$log.warn('Found both encrypted and decrypted key. Deleting the encrypted version');
delete str.xPrivKeyEncrypted;
delete str.mnemonicEncrypted;
}

var addressBook = str.addressBook || {};

addAndBindWalletClient(walletClient, {
Expand Down

0 comments on commit ff931ec

Please sign in to comment.