Initial Intel TEE integration.
This commit is contained in:
parent
62cc46e455
commit
0c69dfb061
24 changed files with 492 additions and 75 deletions
|
|
@ -1,7 +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) {
|
||||
function($scope, $rootScope, $timeout, $log, lodash, $state, $ionicScrollDelegate, $ionicHistory, profileService, configService, gettextCatalog, ledger, trezor, intelTEE, platformInfo, derivationPathHelper, ongoingProcess, walletService, storageService, popupService, appConfigService) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isCordova = platformInfo.isCordova;
|
||||
|
|
@ -68,6 +68,9 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
id: 'new',
|
||||
label: gettextCatalog.getString('Random'),
|
||||
}, {
|
||||
id: walletService.externalSource.intelTEE.id,
|
||||
label: gettextCatalog(walletService.externalSource.intelTEE.name),
|
||||
}, {
|
||||
id: 'set',
|
||||
label: gettextCatalog.getString('Specify Recovery Phrase...'),
|
||||
}];
|
||||
|
|
@ -81,16 +84,16 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
*/
|
||||
|
||||
if (appConfigService.name == 'copay') {
|
||||
if (n > 1 && isChromeApp) {
|
||||
if (n > 1 && isChromeApp)
|
||||
seedOptions.push({
|
||||
id: 'ledger',
|
||||
label: 'Ledger Hardware Wallet',
|
||||
id: walletService.externalSource.ledger.id,
|
||||
label: walletService.externalSource.ledger.longName,
|
||||
});
|
||||
}
|
||||
|
||||
if (isChromeApp || isDevel) {
|
||||
seedOptions.push({
|
||||
id: 'trezor',
|
||||
label: 'Trezor Hardware Wallet',
|
||||
id: walletService.externalSource.trezor.id,
|
||||
label: walletService.externalSource.trezor.longName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -151,22 +154,36 @@ 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 || self.seedSourceId == 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 || self.seedSource.id == walletService.externalSource.intelTEE.id)
|
||||
account = account - 1;
|
||||
|
||||
opts.account = account;
|
||||
ongoingProcess.set('connecting' + $scope.seedSource.id, true);
|
||||
|
||||
var src = $scope.seedSource.id == 'ledger' ? ledger : trezor;
|
||||
var src;
|
||||
switch (self.seedSourceId) {
|
||||
case walletService.externalSource.ledger.id:
|
||||
src = legder;
|
||||
break;
|
||||
case walletService.externalSource.trezor.id:
|
||||
src = trezor;
|
||||
break;
|
||||
case walletService.externalSource.intelTEE.id:
|
||||
src = intelTEE;
|
||||
break;
|
||||
default:
|
||||
this.error = gettextCatalog('Invalid seed source id: ' + self.seedSourceId);
|
||||
return;
|
||||
}
|
||||
|
||||
src.getInfoForNewWallet(opts.n > 1, account, function(err, lopts) {
|
||||
src.getInfoForNewWallet(opts, function(err, lopts) {
|
||||
ongoingProcess.set('connecting' + $scope.seedSource.id, false);
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
angular.module('copayApp.controllers').controller('importController',
|
||||
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, appConfigService) {
|
||||
|
||||
var isChromeApp = platformInfo.isChromeApp;
|
||||
var isDevel = platformInfo.isDevel;
|
||||
var reader = new FileReader();
|
||||
var defaults = configService.getDefaults();
|
||||
var errors = bwcService.getErrors();
|
||||
|
|
@ -25,15 +27,15 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
|
||||
if ($scope.isChromeApp) {
|
||||
$scope.seedOptions.push({
|
||||
id: 'ledger',
|
||||
label: 'Ledger Hardware Wallet',
|
||||
id: walletService.externalSource.ledger.id,
|
||||
label: walletService.externalSource.ledger.longName,
|
||||
});
|
||||
}
|
||||
|
||||
if ($scope.isChromeApp || $scope.isDevel) {
|
||||
$scope.seedOptions.push({
|
||||
id: 'trezor',
|
||||
label: 'Trezor Hardware Wallet',
|
||||
id: walletService.externalSource.trezor.id,
|
||||
label: walletService.externalSource.ledger.longName,
|
||||
});
|
||||
$scope.formData.seedSource = $scope.seedOptions[0];
|
||||
}
|
||||
|
|
@ -267,7 +269,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
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 +295,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 +304,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;
|
||||
|
|
@ -323,7 +325,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -66,15 +66,15 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
if (appConfigService.name == 'copay') {
|
||||
if (isChromeApp) {
|
||||
self.seedOptions.push({
|
||||
id: 'ledger',
|
||||
label: 'Ledger Hardware Wallet',
|
||||
id: walletService.externalSource.ledger.id,
|
||||
label: walletService.externalSource.ledger.longName,
|
||||
});
|
||||
}
|
||||
|
||||
if (isChromeApp || isDevel) {
|
||||
self.seedOptions.push({
|
||||
id: 'trezor',
|
||||
label: 'Trezor Hardware Wallet',
|
||||
id: walletService.externalSource.trezor.id,
|
||||
label: walletService.externalSource.trezor.longName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -130,19 +130,19 @@ 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) {
|
||||
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)
|
||||
account = account - 1;
|
||||
|
||||
opts.account = account;
|
||||
ongoingProcess.set('connecting' + self.seedSourceId, true);
|
||||
var src = self.seedSourceId == 'ledger' ? ledger : trezor;
|
||||
var src = self.seedSourceId == walletService.externalSource.ledger.id ? ledger : trezor;
|
||||
|
||||
src.getInfoForNewWallet(true, account, function(err, lopts) {
|
||||
ongoingProcess.set('connecting' + self.seedSourceId, false);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
24
src/js/controllers/preferencesExternal.js
Normal file
24
src/js/controllers/preferencesExternal.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesExternalController', function($scope, lodash, profileService, walletService) {
|
||||
var wallet = profileService.getWallet($stateParams.walletId);
|
||||
|
||||
$scope.externalSource = lodash.find(walletService.externalSource, function(source) {
|
||||
return source.id == wallet.getPrivKeyExternalSourceName();
|
||||
}).name;
|
||||
|
||||
$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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -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