From 1884f646cd1dffd0c7c1634090f5d4684de37857 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 19 Oct 2016 13:36:22 -0300 Subject: [PATCH] import wallet with pk encrypted --- src/js/services/profileService.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index de2c29e98..3c210bcbc 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -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 @@ -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, {