fix import from xPriv (#4192)
This commit is contained in:
parent
b0db8f4eeb
commit
88ac00afcc
3 changed files with 20 additions and 14 deletions
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue