allow importing HW seeds

This commit is contained in:
Matias Alejo Garcia 2017-06-12 16:22:50 -03:00
commit da15bc939b
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
5 changed files with 52 additions and 9 deletions

View file

@ -1,7 +1,7 @@
'use strict';
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) {
function($scope, $timeout, $log, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, profileService, configService, sjcl, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService, popupService, gettextCatalog, appConfigService, hwWallet) {
var reader = new FileReader();
var defaults = configService.getDefaults();
@ -38,6 +38,21 @@ angular.module('copayApp.controllers').controller('importController',
$scope.formData.seedSource = $scope.seedOptions[0];
}
$scope.seedOptionsAll = [];
$scope.seedOptionsAll.push({
id: walletService.externalSource.ledger.id,
label: walletService.externalSource.ledger.longName,
});
$scope.seedOptionsAll.push({
id: walletService.externalSource.trezor.id,
label: walletService.externalSource.trezor.longName,
});
$scope.formData.seedSourceAll = $scope.seedOptionsAll[0];
$timeout(function() {
$scope.$apply();
});
@ -159,6 +174,7 @@ angular.module('copayApp.controllers').controller('importController',
$timeout(function() {
profileService.importMnemonic(words, opts, function(err, client) {
ongoingProcess.set('importingWallet', false);
if (err) {
@ -177,7 +193,7 @@ angular.module('copayApp.controllers').controller('importController',
};
$scope.setDerivationPath = function() {
$scope.formData.derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
$scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
};
$scope.getFile = function() {
@ -256,6 +272,18 @@ angular.module('copayApp.controllers').controller('importController',
}
opts.passphrase = $scope.formData.passphrase || null;
if ($scope.formData.fromHardwareWallet) {
$log.debug('Importing seed from hardware wallet');
$log.warn('This wont work for Intel TEE wallets');
var id = $scope.formData.seedSourceAll.id;
var isMultisig = opts.derivationStrategy =='BIP48';
var account = opts.account;
opts.entropySourcePath = 'm/' + hwWallet.getEntropyPath(id, isMultisig, account);
}
console.log('[import.js.283:opts:]',opts); //TODO
_importMnemonic(words, opts);
};
@ -269,6 +297,7 @@ angular.module('copayApp.controllers').controller('importController',
lopts.externalSource = walletService.externalSource.trezor.id;
lopts.bwsurl = $scope.formData.bwsurl;
console.log('[import.js.299:lopts:]',lopts); //TODO
ongoingProcess.set('importingWallet', true);
$log.debug('Import opts', lopts);