create working for ledger
This commit is contained in:
parent
d1c1638b14
commit
f633a15a2d
6 changed files with 55 additions and 51 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services')
|
||||
.factory('hwWallet', function($log) {
|
||||
.factory('hwWallet', function($log, bwcService) {
|
||||
var root = {};
|
||||
|
||||
// Ledger magic number to get xPub without user confirmation
|
||||
|
|
@ -11,7 +11,7 @@ angular.module('copayApp.services')
|
|||
root.LIVENET_PATH = 0;
|
||||
|
||||
root._err = function(data) {
|
||||
var msg = 'HW WALLET Error: ' + (data.error || data.message || 'unknown');
|
||||
var msg = 'Hardware Wallet Error: ' + (data.error || data.message || 'unknown');
|
||||
$log.warn(msg);
|
||||
return msg;
|
||||
};
|
||||
|
|
@ -23,8 +23,7 @@ angular.module('copayApp.services')
|
|||
|
||||
root.getEntropyPath = function(isMultisig, account) {
|
||||
var rootPath = isMultisig ? root.MULTISIG_ROOTPATH : root.UNISIG_ROOTPATH;
|
||||
var path = hwWallet.ENTROPY_INDEX_PATH + rootPath + "'/"
|
||||
account + "'";
|
||||
var path = root.ENTROPY_INDEX_PATH + rootPath + "'/" + account + "'";
|
||||
return path;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ angular.module('copayApp.services')
|
|||
|
||||
root.getInfoForNewWallet = function(isMultisig, account, callback) {
|
||||
var opts = {};
|
||||
root.getEntropySource(isMultisig, account, function(entropySource) {
|
||||
root.getEntropySource(isMultisig, account, function(err, entropySource) {
|
||||
if (err) return callback(err);
|
||||
|
||||
opts.entropySource = entropySource;
|
||||
|
|
@ -51,7 +51,7 @@ angular.module('copayApp.services')
|
|||
}
|
||||
opts.extendedPublicKey = data.xpubkey;
|
||||
opts.externalSource = 'ledger';
|
||||
opts.externalIndex = account;
|
||||
opts.account = account;
|
||||
return callback(null, opts);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ angular.module('copayApp.services')
|
|||
walletClient.seedFromMnemonic(opts.mnemonic, {
|
||||
network: network,
|
||||
passphrase: opts.passphrase,
|
||||
account: 0,
|
||||
account: opts.account || 0,
|
||||
});
|
||||
} catch (ex) {
|
||||
$log.info(ex);
|
||||
|
|
@ -197,7 +197,7 @@ angular.module('copayApp.services')
|
|||
} else if (opts.extendedPublicKey) {
|
||||
try {
|
||||
walletClient.seedFromExtendedPublicKey(opts.extendedPublicKey, opts.externalSource, opts.entropySource, {
|
||||
account: 0
|
||||
account: opts.account || 0,
|
||||
});
|
||||
} catch (ex) {
|
||||
$log.warn("Creating wallet from Extended Public Key Arg:", ex, opts);
|
||||
|
|
@ -420,7 +420,7 @@ angular.module('copayApp.services')
|
|||
walletClient.importFromMnemonic(words, {
|
||||
network: opts.networkName,
|
||||
passphrase: opts.passphrase,
|
||||
account: 0,
|
||||
account: opts.account,
|
||||
}, function(err) {
|
||||
if (err)
|
||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||
|
|
@ -437,7 +437,7 @@ angular.module('copayApp.services')
|
|||
$log.debug('Importing Wallet XPubKey');
|
||||
|
||||
walletClient.importFromExtendedPublicKey(opts.extendedPublicKey, opts.externalSource, opts.entropySource, {
|
||||
account: 0
|
||||
account: opts.account || 0,
|
||||
}, function(err) {
|
||||
if (err) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services')
|
||||
.factory('trezor', function($log, $timeout, bwcService, gettext, lodash, bitcore, hwWallet) {
|
||||
.factory('trezor', function($log, $timeout, gettext, lodash, bitcore, hwWallet) {
|
||||
var root = {};
|
||||
|
||||
var SETTLE_TIME = 3000;
|
||||
|
|
@ -24,10 +24,11 @@ angular.module('copayApp.services')
|
|||
|
||||
|
||||
root.getInfoForNewWallet = function(isMultisig, account, callback) {
|
||||
account = account - 1;
|
||||
var opts = {};
|
||||
root.getEntropySource(isMultisig, account, function(err, data) {
|
||||
if (err) return callback(err);
|
||||
opts.entropySource = data.entropySource;
|
||||
opts.entropySource = data;
|
||||
$log.debug('Waiting TREZOR to settle...');
|
||||
$timeout(function() {
|
||||
|
||||
|
|
@ -37,7 +38,7 @@ angular.module('copayApp.services')
|
|||
|
||||
opts.extendedPublicKey = data.xpubkey;
|
||||
opts.externalSource = 'trezor';
|
||||
opts.externalIndex = account;
|
||||
opts.account = account;
|
||||
return callback(null, opts);
|
||||
});
|
||||
}, SETTLE_TIME);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue