fix history sync
This commit is contained in:
parent
1e9b99981e
commit
232b78ee8c
12 changed files with 96 additions and 73 deletions
|
|
@ -16,28 +16,28 @@ angular.module('copayApp.services')
|
|||
return msg;
|
||||
};
|
||||
|
||||
root.getAddressPath = function(isMultisig, account) {
|
||||
var rootPath;
|
||||
|
||||
if (account) {
|
||||
rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
||||
} else {
|
||||
// Old ledger wallet compat
|
||||
rootPath = 44;
|
||||
}
|
||||
return rootPath + "'/" + root.LIVENET_PATH + "'/" + account + "'";
|
||||
root.getRootPath = function(device, isMultisig, account) {
|
||||
if (!isMultisig) return root.UNISIG_ROOTPATH;
|
||||
|
||||
// Compat
|
||||
if (device == 'ledger' && account ==0) return root.UNISIG_ROOTPATH;
|
||||
|
||||
return root.MULTISIG_ROOTPATH;
|
||||
};
|
||||
|
||||
root.getAddressPath = function(device, isMultisig, account) {
|
||||
return root.getRootPath(device,isMultisig,account) + "'/" + root.LIVENET_PATH + "'/" + account + "'";
|
||||
}
|
||||
|
||||
root.getEntropyPath = function(isMultisig, account) {
|
||||
root.getEntropyPath = function(device, isMultisig, account) {
|
||||
var path;
|
||||
if (account) {
|
||||
var rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
||||
path = root.ENTROPY_INDEX_PATH + rootPath + "'/" + account + "'";
|
||||
} else {
|
||||
// Old ledger wallet compat
|
||||
path = root.ENTROPY_INDEX_PATH + "0'";
|
||||
}
|
||||
return path;
|
||||
|
||||
// Old ledger wallet compat
|
||||
if (device == 'ledger' && account == 0)
|
||||
return root.ENTROPY_INDEX_PATH + "0'";
|
||||
|
||||
return root.ENTROPY_INDEX_PATH + root.getRootPath(device,isMultisig,account) + "'/" + account + "'";
|
||||
};
|
||||
|
||||
root.pubKeyToEntropySource = function(xPubKey) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
|
||||
root.getEntropySource = function(isMultisig, account, callback) {
|
||||
root.getXPubKey(hwWallet.getEntropyPath(isMultisig, account), function(data) {
|
||||
root.getXPubKey(hwWallet.getEntropyPath('ledger', isMultisig, account), function(data) {
|
||||
if (!data.success)
|
||||
return callback(hwWallet._err(data));
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ angular.module('copayApp.services')
|
|||
if (err) return callback(err);
|
||||
|
||||
opts.entropySource = entropySource;
|
||||
root.getXPubKey(hwWallet.getAddressPath(isMultisig, account), function(data) {
|
||||
root.getXPubKey(hwWallet.getAddressPath('ledger', isMultisig, account), function(data) {
|
||||
if (!data.success) {
|
||||
$log.warn(data.message);
|
||||
return callback(data);
|
||||
|
|
@ -45,6 +45,9 @@ angular.module('copayApp.services')
|
|||
opts.extendedPublicKey = data.xpubkey;
|
||||
opts.externalSource = 'ledger';
|
||||
opts.account = account;
|
||||
|
||||
// Old ledger compat
|
||||
opts.derivationStrategy = account ? 'BIP48' : 'BIP44';
|
||||
return callback(null, opts);
|
||||
});
|
||||
});
|
||||
|
|
@ -54,11 +57,10 @@ angular.module('copayApp.services')
|
|||
root.callbacks["sign_p2sh"] = callback;
|
||||
var redeemScripts = [];
|
||||
var paths = [];
|
||||
|
||||
var tx = bwcService.getUtils().buildTx(txp);
|
||||
var tx = bwcService.buildTx(txp);
|
||||
for (var i = 0; i < tx.inputs.length; i++) {
|
||||
redeemScripts.push(new ByteString(tx.inputs[i].redeemScript.toBuffer().toString('hex'), GP.HEX).toString());
|
||||
paths.push(hwWallet.getAddressPath(isMultisig, account) + txp.inputs[i].path.substring(1));
|
||||
paths.push(hwWallet.getAddressPath('ledger', isMultisig, account) + txp.inputs[i].path.substring(1));
|
||||
}
|
||||
var splitTransaction = root._splitTransaction(new ByteString(tx.toString(), GP.HEX));
|
||||
var inputs = [];
|
||||
|
|
|
|||
|
|
@ -173,12 +173,6 @@ angular.module('copayApp.services')
|
|||
var walletClient = bwcService.getClient();
|
||||
var network = opts.networkName || 'livenet';
|
||||
|
||||
// TODO refactor this and use bwc contants?
|
||||
var derivationStrategy = 'BIP44';
|
||||
if (opts.fromHardware && opts.n > 1) {
|
||||
derivationStrategy = 'BIP48';
|
||||
}
|
||||
|
||||
|
||||
if (opts.mnemonic) {
|
||||
try {
|
||||
|
|
@ -187,7 +181,7 @@ angular.module('copayApp.services')
|
|||
network: network,
|
||||
passphrase: opts.passphrase,
|
||||
account: opts.account || 0,
|
||||
derivationStrategy: derivationStrategy,
|
||||
derivationStrategy: opts.derivationStrategy || 'BIP44',
|
||||
});
|
||||
|
||||
} catch (ex) {
|
||||
|
|
@ -205,7 +199,7 @@ angular.module('copayApp.services')
|
|||
try {
|
||||
walletClient.seedFromExtendedPublicKey(opts.extendedPublicKey, opts.externalSource, opts.entropySource, {
|
||||
account: opts.account || 0,
|
||||
derivationStrategy: derivationStrategy,
|
||||
derivationStrategy: opts.derivationStrategy || 'BIP44',
|
||||
});
|
||||
} catch (ex) {
|
||||
$log.warn("Creating wallet from Extended Public Key Arg:", ex, opts);
|
||||
|
|
@ -319,7 +313,7 @@ angular.module('copayApp.services')
|
|||
walletId: walletId
|
||||
});
|
||||
|
||||
delete root.walletClients[walletId];
|
||||
delete root.walletClients[walletId];
|
||||
root.focusedClient = null;
|
||||
|
||||
storageService.clearLastAddress(walletId, function(err) {
|
||||
|
|
@ -446,6 +440,7 @@ angular.module('copayApp.services')
|
|||
|
||||
walletClient.importFromExtendedPublicKey(opts.extendedPublicKey, opts.externalSource, opts.entropySource, {
|
||||
account: opts.account || 0,
|
||||
derivationStrategy: opts.derivationStrategy || 'BIP44',
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ angular.module('copayApp.services')
|
|||
root.callbacks = {};
|
||||
|
||||
root.getEntropySource = function(isMultisig, account, callback) {
|
||||
root.getXPubKey(hwWallet.getEntropyPath(isMultisig, account), function(data) {
|
||||
root.getXPubKey(hwWallet.getEntropyPath('trezor', isMultisig, account), function(data) {
|
||||
if (!data.success)
|
||||
return callback(hwWallet._err(data));
|
||||
|
||||
|
|
@ -31,13 +31,17 @@ angular.module('copayApp.services')
|
|||
$log.debug('Waiting TREZOR to settle...');
|
||||
$timeout(function() {
|
||||
|
||||
root.getXPubKey(hwWallet.getAddressPath(isMultisig, account), function(data) {
|
||||
root.getXPubKey(hwWallet.getAddressPath('trezor', isMultisig, account), function(data) {
|
||||
if (!data.success)
|
||||
return callback(hwWallet._err(data));
|
||||
|
||||
opts.extendedPublicKey = data.xpubkey;
|
||||
opts.externalSource = 'trezor';
|
||||
opts.account = account;
|
||||
|
||||
if (isMultisig)
|
||||
opts.derivationStrategy = 'BIP48';
|
||||
|
||||
return callback(null, opts);
|
||||
});
|
||||
}, SETTLE_TIME);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue