Merge pull request #5797 from ajp8164/feat/intel-tee
Baseline Intel TEE support
This commit is contained in:
commit
803a9ca365
27 changed files with 635 additions and 102 deletions
|
|
@ -1,11 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('createController',
|
||||
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) {
|
||||
|
||||
/* For compressed keys, m*73 + n*34 <= 496 */
|
||||
var COPAYER_PAIR_LIMITS = {
|
||||
|
|
@ -67,9 +63,11 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
var seedOptions = [{
|
||||
id: 'new',
|
||||
label: gettextCatalog.getString('Random'),
|
||||
}, {
|
||||
supportsTestnet: true
|
||||
}, {
|
||||
id: 'set',
|
||||
label: gettextCatalog.getString('Specify Recovery Phrase...'),
|
||||
supportsTestnet: false
|
||||
}];
|
||||
|
||||
$scope.seedSource = seedOptions[0];
|
||||
|
|
@ -81,16 +79,26 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
*/
|
||||
|
||||
if (appConfigService.name == 'copay') {
|
||||
if (n > 1 && isChromeApp) {
|
||||
if (n > 1 && walletService.externalSource.ledger.supported)
|
||||
seedOptions.push({
|
||||
id: 'ledger',
|
||||
label: 'Ledger Hardware Wallet',
|
||||
id: walletService.externalSource.ledger.id,
|
||||
label: walletService.externalSource.ledger.longName,
|
||||
supportsTestnet: walletService.externalSource.ledger.supportsTestnet
|
||||
});
|
||||
|
||||
if (walletService.externalSource.trezor.supported) {
|
||||
seedOptions.push({
|
||||
id: walletService.externalSource.trezor.id,
|
||||
label: walletService.externalSource.trezor.longName,
|
||||
supportsTestnet: walletService.externalSource.trezor.supportsTestnet
|
||||
});
|
||||
}
|
||||
if (isChromeApp || isDevel) {
|
||||
|
||||
if (walletService.externalSource.intelTEE.supported) {
|
||||
seedOptions.push({
|
||||
id: 'trezor',
|
||||
label: 'Trezor Hardware Wallet',
|
||||
id: walletService.externalSource.intelTEE.id,
|
||||
label: walletService.externalSource.intelTEE.longName,
|
||||
supportsTestnet: walletService.externalSource.intelTEE.supportsTestnet
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -151,23 +159,37 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
return;
|
||||
}
|
||||
|
||||
if ($scope.seedSource.id == 'ledger' || $scope.seedSource.id == 'trezor') {
|
||||
if ($scope.seedSource.id == walletService.externalSource.ledger.id || $scope.seedSource.id == walletService.externalSource.trezor.id || $scope.seedSource.id == walletService.externalSource.intelTEE.id) {
|
||||
var account = $scope.formData.account;
|
||||
if (!account || account < 1) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($scope.seedSource.id == 'trezor')
|
||||
if ($scope.seedSource.id == walletService.externalSource.trezor.id || $scope.seedSource.id == walletService.externalSource.intelTEE.id)
|
||||
account = account - 1;
|
||||
|
||||
opts.account = account;
|
||||
ongoingProcess.set('connecting' + $scope.seedSource.id, true);
|
||||
ongoingProcess.set('connecting ' + $scope.seedSource.id, true);
|
||||
|
||||
var src = $scope.seedSource.id == 'ledger' ? ledger : trezor;
|
||||
var src;
|
||||
switch ($scope.seedSource.id) {
|
||||
case walletService.externalSource.ledger.id:
|
||||
src = ledger;
|
||||
break;
|
||||
case walletService.externalSource.trezor.id:
|
||||
src = trezor;
|
||||
break;
|
||||
case walletService.externalSource.intelTEE.id:
|
||||
src = intelTEE;
|
||||
break;
|
||||
default:
|
||||
this.error = gettextCatalog.getString('Invalid seed source id: ' + $scope.seedSource.id);
|
||||
return;
|
||||
}
|
||||
|
||||
src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) {
|
||||
ongoingProcess.set('connecting' + $scope.seedSource.id, false);
|
||||
src.getInfoForNewWallet(opts.n > 1, account, opts.networkName, function(err, lopts) {
|
||||
ongoingProcess.set('connecting ' + $scope.seedSource.id, false);
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
var errors = bwcService.getErrors();
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.isDevel = platformInfo.isDevel;
|
||||
$scope.isChromeApp = platformInfo.isChromeApp;
|
||||
$scope.supportsLedger = platformInfo.supportsLedger;
|
||||
$scope.supportsTrezor = platformInfo.supportsTrezor;
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.formData = {};
|
||||
$scope.formData.bwsurl = defaults.bws.url;
|
||||
|
|
@ -23,17 +23,17 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
$scope.seedOptions = [];
|
||||
|
||||
if ($scope.isChromeApp) {
|
||||
if ($scope.supportsLedger) {
|
||||
$scope.seedOptions.push({
|
||||
id: 'ledger',
|
||||
label: 'Ledger Hardware Wallet',
|
||||
id: walletService.externalSource.ledger.id,
|
||||
label: walletService.externalSource.ledger.longName,
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.isChromeApp || $scope.isDevel) {
|
||||
if ($scope.supportsTrezor) {
|
||||
$scope.seedOptions.push({
|
||||
id: 'trezor',
|
||||
label: 'Trezor Hardware Wallet',
|
||||
id: walletService.externalSource.trezor.id,
|
||||
label: walletService.externalSource.trezor.longName,
|
||||
});
|
||||
$scope.formData.seedSource = $scope.seedOptions[0];
|
||||
}
|
||||
|
|
@ -260,14 +260,14 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
$scope.importTrezor = function(account, isMultisig) {
|
||||
trezor.getInfoForNewWallet(isMultisig, account, function(err, lopts) {
|
||||
trezor.getInfoForNewWallet(isMultisig, account, 'livenet', function(err, lopts) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
|
||||
lopts.externalSource = 'trezor';
|
||||
lopts.externalSource = walletService.externalSource.trezor.id;
|
||||
lopts.bwsurl = $scope.formData.bwsurl;
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$log.debug('Import opts', lopts);
|
||||
|
|
@ -293,7 +293,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
var account = $scope.formData.account;
|
||||
|
||||
if ($scope.formData.seedSource.id == 'trezor') {
|
||||
if ($scope.formData.seedSource.id == walletService.externalSource.trezor.id) {
|
||||
if (account < 1) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number'));
|
||||
return;
|
||||
|
|
@ -302,11 +302,11 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
}
|
||||
|
||||
switch ($scope.formData.seedSource.id) {
|
||||
case ('ledger'):
|
||||
case (walletService.externalSource.ledger.id):
|
||||
ongoingProcess.set('connectingledger', true);
|
||||
$scope.importLedger(account);
|
||||
break;
|
||||
case ('trezor'):
|
||||
case (walletService.externalSource.trezor.id):
|
||||
ongoingProcess.set('connectingtrezor', true);
|
||||
$scope.importTrezor(account, $scope.formData.isMultisig);
|
||||
break;
|
||||
|
|
@ -316,14 +316,14 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
$scope.importLedger = function(account) {
|
||||
ledger.getInfoForNewWallet(true, account, function(err, lopts) {
|
||||
ledger.getInfoForNewWallet(true, account, 'livenet', function(err, lopts) {
|
||||
ongoingProcess.clear();
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
|
||||
lopts.externalSource = 'ledger';
|
||||
lopts.externalSource = lopts.externalSource = walletService.externalSource.ledger.id;
|
||||
lopts.bwsurl = $scope.formData.bwsurl;
|
||||
ongoingProcess.set('importingWallet', true);
|
||||
$log.debug('Import opts', lopts);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('joinController',
|
||||
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
function($scope, $rootScope, $timeout, $state, $ionicHistory, $ionicScrollDelegate, profileService, configService, storageService, applicationService, gettextCatalog, lodash, ledger, trezor, intelTEE, derivationPathHelper, ongoingProcess, walletService, $log, $stateParams, popupService, appConfigService) {
|
||||
|
||||
var self = this;
|
||||
var defaults = configService.getDefaults();
|
||||
|
|
@ -64,17 +61,24 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
*/
|
||||
|
||||
if (appConfigService.name == 'copay') {
|
||||
if (isChromeApp) {
|
||||
if (walletService.externalSource.ledger.supported) {
|
||||
self.seedOptions.push({
|
||||
id: 'ledger',
|
||||
label: 'Ledger Hardware Wallet',
|
||||
id: walletService.externalSource.ledger.id,
|
||||
label: walletService.externalSource.ledger.longName
|
||||
});
|
||||
}
|
||||
|
||||
if (isChromeApp || isDevel) {
|
||||
if (walletService.externalSource.trezor.supported) {
|
||||
self.seedOptions.push({
|
||||
id: 'trezor',
|
||||
label: 'Trezor Hardware Wallet',
|
||||
id: walletService.externalSource.trezor.id,
|
||||
label: walletService.externalSource.trezor.longName
|
||||
});
|
||||
}
|
||||
|
||||
if (walletService.externalSource.intelTEE.supported) {
|
||||
seedOptions.push({
|
||||
id: walletService.externalSource.intelTEE.id,
|
||||
label: walletService.externalSource.intelTEE.longName
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +101,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
var opts = {
|
||||
secret: form.secret.$modelValue,
|
||||
myName: form.myName.$modelValue,
|
||||
bwsurl: $scope.bwsurl,
|
||||
bwsurl: $scope.bwsurl
|
||||
}
|
||||
|
||||
var setSeed = self.seedSourceId == 'set';
|
||||
|
|
@ -130,21 +134,38 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
return;
|
||||
}
|
||||
|
||||
if (self.seedSourceId == 'ledger' || self.seedSourceId == 'trezor') {
|
||||
if (self.seedSourceId == walletService.externalSource.ledger.id || self.seedSourceId == walletService.externalSource.trezor.id || self.seedSourceId == walletService.externalSource.intelTEE.id) {
|
||||
var account = $scope.account;
|
||||
if (!account || account < 1) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Invalid account number'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.seedSourceId == 'trezor')
|
||||
if (self.seedSourceId == walletService.externalSource.trezor.id || self.seedSourceId == walletService.externalSource.intelTEE.id)
|
||||
account = account - 1;
|
||||
|
||||
opts.account = account;
|
||||
opts.isMultisig = true;
|
||||
ongoingProcess.set('connecting' + self.seedSourceId, true);
|
||||
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
||||
|
||||
src.getInfoForNewWallet(true, account, function(err, lopts) {
|
||||
var src;
|
||||
switch (self.seedSourceId) {
|
||||
case walletService.externalSource.ledger.id:
|
||||
src = ledger;
|
||||
break;
|
||||
case walletService.externalSource.trezor.id:
|
||||
src = trezor;
|
||||
break;
|
||||
case walletService.externalSource.intelTEE.id:
|
||||
src = intelTEE;
|
||||
break;
|
||||
default:
|
||||
this.error = gettextCatalog.getString('Invalid seed source id: ' + self.seedSourceId);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: cannot currently join an intelTEE testnet wallet (need to detect from the secret)
|
||||
src.getInfoForNewWallet(true, account, 'livenet', function(err, lopts) {
|
||||
ongoingProcess.set('connecting' + self.seedSourceId, false);
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
|
|
|
|||
|
|
@ -89,9 +89,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
value: $scope.wallet.balanceHidden
|
||||
};
|
||||
|
||||
if (wallet.isPrivKeyExternal)
|
||||
$scope.externalSource = wallet.getPrivKeyExternalSourceName() == 'ledger' ? 'Ledger' : 'Trezor';
|
||||
|
||||
$scope.touchIdAvailable = fingerprintService.isAvailable();
|
||||
$scope.touchIdEnabled = {
|
||||
value: config.touchIdFor ? config.touchIdFor[walletId] : null
|
||||
|
|
|
|||
28
src/js/controllers/preferencesExternal.js
Normal file
28
src/js/controllers/preferencesExternal.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesExternalController', function($scope, $stateParams, lodash, gettextCatalog, popupService, profileService, walletService) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
|
||||
$scope.externalSource = lodash.find(walletService.externalSource, function(source) {
|
||||
return source.id == wallet.getPrivKeyExternalSourceName();
|
||||
});
|
||||
|
||||
if ($scope.externalSource.isEmbeddedHardware) {
|
||||
$scope.hardwareConnected = $scope.externalSource.version.length > 0;
|
||||
|
||||
$scope.showMneumonicFromHardwarePopup = function() {
|
||||
var title = gettextCatalog.getString('Warning!');
|
||||
var message = gettextCatalog.getString('Are you being watched? Anyone with your recovery phrase can access or spend your bitcoin.');
|
||||
popupService.showConfirm(title, message, null, null, function(res) {
|
||||
if (res) {
|
||||
walletService.showMneumonicFromHardware(wallet, function(err) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err.message || err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesInformation',
|
||||
function($scope, $log, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, $state) {
|
||||
function($scope, $log, $ionicHistory, platformInfo, lodash, profileService, configService, $stateParams, $state, walletService) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
$scope.wallet = wallet;
|
||||
|
||||
|
|
@ -44,5 +44,13 @@ angular.module('copayApp.controllers').controller('preferencesInformation',
|
|||
$scope.M = c.m;
|
||||
$scope.N = c.n;
|
||||
$scope.pubKeys = lodash.pluck(c.publicKeyRing, 'xPubKey');
|
||||
$scope.externalSource = null;
|
||||
|
||||
if (wallet.isPrivKeyExternal()) {
|
||||
$scope.externalSource = lodash.find(walletService.externalSource, function(source) {
|
||||
return source.id == wallet.getPrivKeyExternalSourceName();
|
||||
}).name;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -145,6 +145,22 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
});
|
||||
};
|
||||
|
||||
$scope.shouldShowReceiveAddressFromHardware = function() {
|
||||
var wallet = $scope.wallet;
|
||||
if (wallet.isPrivKeyExternal() && wallet.credentials.hwInfo) {
|
||||
return (wallet.credentials.hwInfo.name == walletService.externalSource.intelTEE.id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.showReceiveAddressFromHardware = function() {
|
||||
var wallet = $scope.wallet;
|
||||
if (wallet.isPrivKeyExternal() && wallet.credentials.hwInfo) {
|
||||
walletService.showReceiveAddressFromHardware(wallet, $scope.addr, function(){});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.wallets = profileService.getWallets();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue