mirror of https://github.com/BTCPrivate/copay.git
fix ledger paths
This commit is contained in:
parent
50a46d87c0
commit
a8032e1e4b
|
@ -7,7 +7,7 @@ angular.module('copayApp.services')
|
|||
root.MAX_SLOT = 20;
|
||||
|
||||
// Ledger magic number to get xPub without user confirmation
|
||||
root.ENTROPY_INDEX_PATH = "m/0xb11e/";
|
||||
root.ENTROPY_INDEX_PATH = "0xb11e/";
|
||||
|
||||
root.callbacks = {};
|
||||
|
||||
|
@ -26,6 +26,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
|
||||
var b = bwcService.getBitcore();
|
||||
|
||||
var x = b.HDPublicKey(data.xpubkey);
|
||||
data.entropySource = x.publicKey.toString();
|
||||
return callback(data);
|
||||
|
@ -37,6 +38,8 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.getXPubKey = function(path, callback) {
|
||||
|
||||
$log.debug('Ledger deriving xPub path:', path);
|
||||
root.callbacks["get_xpubkey"] = callback;
|
||||
root._messageAfterSession({
|
||||
command: "get_xpubkey",
|
||||
|
@ -85,6 +88,7 @@ angular.module('copayApp.services')
|
|||
root._reverseBytestring(input.prevout.bytes(32)).toString()
|
||||
]);
|
||||
}
|
||||
$log.debug('Ledger signing paths:', paths);
|
||||
root._messageAfterSession({
|
||||
command: "sign_p2sh",
|
||||
inputs: inputs,
|
||||
|
@ -143,7 +147,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
|
||||
root._getPath = function(index) {
|
||||
return "m/" + index + "'/45'";
|
||||
return index + "'/45'";
|
||||
}
|
||||
|
||||
root._splitTransaction = function(transaction) {
|
||||
|
|
|
@ -171,7 +171,7 @@ angular.module('copayApp.services')
|
|||
var network = opts.networkName || 'livenet';
|
||||
|
||||
if (opts.mnemonic && opts.mnemonic.indexOf('m/' != 0)) {
|
||||
var xPrivKey = root._processDerivation(opts.mnemonic, network);
|
||||
var xPrivKey = root._preDerivation(opts.mnemonic, network);
|
||||
if (!xPrivKey)
|
||||
return bwsError.cb('Bad derivation', gettext('Could not import'), cb);
|
||||
opts.mnemonic = null;
|
||||
|
@ -371,23 +371,24 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
|
||||
root._processDerivation = function(words, network) {
|
||||
root._preDerivation = function(words, network) {
|
||||
var wordList = words.split(/ /).filter(function(v) {
|
||||
return v.length > 0;
|
||||
});
|
||||
var path = wordList.shift();
|
||||
var walletClient = bwcService.getClient();
|
||||
$log.debug('processDerivation', path);
|
||||
$log.info('preDerivation:', path);
|
||||
walletClient.seedFromMnemonic(wordList.join(' '), null, network);
|
||||
var k = new bitcore.HDPrivateKey(walletClient.credentials.xPrivKey);
|
||||
return k.toString();
|
||||
var k2 = k.derive(path);
|
||||
return k2.toString();
|
||||
};
|
||||
|
||||
root.importMnemonic = function(words, opts, cb) {
|
||||
var walletClient = bwcService.getClient();
|
||||
|
||||
if (words.indexOf('m/') == 0) {
|
||||
var xPrivKey = root._processDerivation(words, opts.networkName);
|
||||
var xPrivKey = root._preDerivation(words, opts.networkName);
|
||||
if (!xPrivKey)
|
||||
return bwsError.cb('Bad derivation', gettext('Could not import'), cb);
|
||||
return root.importExtendedPrivateKey(xPrivKey, cb);
|
||||
|
|
Loading…
Reference in New Issue