diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index a7e180504..3d398a5ea 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -82,7 +82,6 @@ angular.module('copayApp.controllers').controller('importController', }; var _importExtendedPrivateKey = function(xPrivKey, opts) { -console.log('[import.js.84:xPrivKey:]',xPrivKey); //TODO self.loading = true; $timeout(function() { @@ -177,7 +176,16 @@ console.log('[import.js.84:xPrivKey:]',xPrivKey); //TODO if ($scope.bwsurl) opts.bwsurl = $scope.bwsurl; - var passphrase = form.passphrase.$modelValue; + + var pathData = derivationPathHelper.parse($scope.derivationPath); + if (!pathData) { + this.error = gettext('Invalid derivation path'); + return; + } + opts.account = pathData.account; + opts.networkName = pathData.networkName; + opts.derivationStrategy = pathData.derivationStrategy; + var words = form.words.$modelValue; this.error = null; @@ -199,18 +207,9 @@ console.log('[import.js.84:xPrivKey:]',xPrivKey); //TODO return; } + var passphrase = form.passphrase.$modelValue; opts.passphrase = form.passphrase.$modelValue || null; - var pathData = derivationPathHelper.parse($scope.derivationPath); - if (!pathData) { - this.error = gettext('Invalid derivation path'); - return; - } - opts.account = pathData.account; - opts.networkName = pathData.networkName; - opts.derivationStrategy = pathData.derivationStrategy; - - _importMnemonic(words, opts); }; diff --git a/src/js/services/derivationPathHelper.js b/src/js/services/derivationPathHelper.js index 04588692d..ad2d8e397 100644 --- a/src/js/services/derivationPathHelper.js +++ b/src/js/services/derivationPathHelper.js @@ -16,6 +16,13 @@ angular.module('copayApp.services').factory('derivationPathHelper', function(lod case "44'": ret.derivationStrategy = 'BIP44'; break; + case "45'": + return { + derivationStrategy: 'BIP45', + networkName: 'livenet', + account: 0, + } + break; case "48'": ret.derivationStrategy = 'BIP48'; break; @@ -37,7 +44,7 @@ angular.module('copayApp.services').factory('derivationPathHelper', function(lod var match = arr[3].match(/(\d+)'/); if (!match) return false; - ret.account = + match[1] + ret.account = +match[1] return ret; }; diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 1dc8deb8e..b01435585 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -495,7 +495,7 @@ angular.module('copayApp.services') var walletClient = bwcService.getClient(); $log.debug('Importing Wallet xPrivKey'); - walletClient.importFromExtendedPrivateKey(xPrivKey, function(err) { + walletClient.importFromExtendedPrivateKey(xPrivKey, opts, function(err) { if (err) return bwsError.cb(err, gettext('Could not import'), cb);