create working for ledger
This commit is contained in:
parent
d1c1638b14
commit
f633a15a2d
6 changed files with 55 additions and 51 deletions
|
|
@ -49,9 +49,8 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
}];
|
||||
$scope.seedSource = self.seedOptions[0];
|
||||
|
||||
|
||||
// TODO
|
||||
// if (!isChromeApp) return;
|
||||
// TODO
|
||||
// if (!isChromeApp) return;
|
||||
|
||||
if (n > 1)
|
||||
self.seedOptions.push({
|
||||
|
|
@ -63,6 +62,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
id: 'trezor',
|
||||
label: gettext('Trezor Hardware Wallet'),
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
this.TCValues = lodash.range(2, defaults.limits.totalCopayers + 1);
|
||||
|
|
@ -71,12 +71,18 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
this.setTotalCopayers = function(tc) {
|
||||
updateRCSelect(tc);
|
||||
updateSeedSourceSelect(tc);
|
||||
self.seedSourceId = $scope.seedSource.id;
|
||||
};
|
||||
|
||||
|
||||
this.setSeedSource = function(src) {
|
||||
self.seedSourceId = $scope.seedSource.id;
|
||||
console.log('[create.js.78:seedSourceId:]',self.seedSourceId); //TODO
|
||||
|
||||
if (self.seedSourceId == 'ledger')
|
||||
self.accountValues = lodash.range(0, 99);
|
||||
else
|
||||
self.accountValues = lodash.range(1, 100);
|
||||
|
||||
$timeout(function() {
|
||||
$rootScope.$apply();
|
||||
});
|
||||
|
|
@ -95,7 +101,7 @@ console.log('[create.js.78:seedSourceId:]',self.seedSourceId); //TODO
|
|||
networkName: form.isTestnet.$modelValue ? 'testnet' : 'livenet',
|
||||
bwsurl: $scope.bwsurl
|
||||
};
|
||||
var setSeed = form.setSeed.$modelValue;
|
||||
var setSeed = self.seedSourceId =='set';
|
||||
if (setSeed) {
|
||||
var words = form.privateKey.$modelValue;
|
||||
if (words.indexOf(' ') == -1 && words.indexOf('prv') == 1 && words.length > 108) {
|
||||
|
|
@ -113,12 +119,16 @@ console.log('[create.js.78:seedSourceId:]',self.seedSourceId); //TODO
|
|||
return;
|
||||
}
|
||||
|
||||
if (form.hwLedger.$modelValue || form.hwTrezor.$modelValue) {
|
||||
self.hwWallet = form.hwLedger.$modelValue ? 'Ledger' : 'TREZOR';
|
||||
|
||||
var src = form.hwLedger.$modelValue ? ledger : trezor;
|
||||
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
|
||||
var account = $scope.account;
|
||||
if (!account) {
|
||||
this.error = gettext('Please select account');
|
||||
return;
|
||||
}
|
||||
self.hwWallet = self.seedSourceId == 'ledger' ? 'Ledger' : 'Trezor';
|
||||
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
||||
|
||||
var account = form.account.$modelValue;
|
||||
src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) {
|
||||
self.hwWallet = false;
|
||||
if (err) {
|
||||
|
|
@ -178,4 +188,5 @@ console.log('[create.js.78:seedSourceId:]',self.seedSourceId); //TODO
|
|||
$rootScope.hideWalletNavigation = false;
|
||||
});
|
||||
updateSeedSourceSelect(1);
|
||||
self.seedSourceId = 'new'
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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