mirror of https://github.com/BTCPrivate/copay.git
allow importing HW seeds
This commit is contained in:
parent
7eede29079
commit
da15bc939b
|
@ -22,7 +22,7 @@
|
||||||
"windowsAppId": "804636ee-b017-4cad-8719-e58ac97ffa5c",
|
"windowsAppId": "804636ee-b017-4cad-8719-e58ac97ffa5c",
|
||||||
"pushSenderId": "1036948132229",
|
"pushSenderId": "1036948132229",
|
||||||
"description": "A Secure Bitcoin Wallet",
|
"description": "A Secure Bitcoin Wallet",
|
||||||
"version": "3.4.0",
|
"version": "3.4.1",
|
||||||
"androidVersion": "340001",
|
"androidVersion": "340001",
|
||||||
"_extraCSS": null,
|
"_extraCSS": null,
|
||||||
"_enabledExtensions": {
|
"_enabledExtensions": {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('importController',
|
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 reader = new FileReader();
|
||||||
var defaults = configService.getDefaults();
|
var defaults = configService.getDefaults();
|
||||||
|
@ -38,6 +38,21 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
$scope.formData.seedSource = $scope.seedOptions[0];
|
$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() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
|
@ -159,6 +174,7 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
profileService.importMnemonic(words, opts, function(err, client) {
|
profileService.importMnemonic(words, opts, function(err, client) {
|
||||||
|
|
||||||
ongoingProcess.set('importingWallet', false);
|
ongoingProcess.set('importingWallet', false);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -177,7 +193,7 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.setDerivationPath = function() {
|
$scope.setDerivationPath = function() {
|
||||||
$scope.formData.derivationPath = $scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
|
$scope.formData.testnetEnabled ? derivationPathHelper.defaultTestnet : derivationPathHelper.default;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getFile = function() {
|
$scope.getFile = function() {
|
||||||
|
@ -256,6 +272,18 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.passphrase = $scope.formData.passphrase || null;
|
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);
|
_importMnemonic(words, opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -269,6 +297,7 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
|
|
||||||
lopts.externalSource = walletService.externalSource.trezor.id;
|
lopts.externalSource = walletService.externalSource.trezor.id;
|
||||||
lopts.bwsurl = $scope.formData.bwsurl;
|
lopts.bwsurl = $scope.formData.bwsurl;
|
||||||
|
console.log('[import.js.299:lopts:]',lopts); //TODO
|
||||||
ongoingProcess.set('importingWallet', true);
|
ongoingProcess.set('importingWallet', true);
|
||||||
$log.debug('Import opts', lopts);
|
$log.debug('Import opts', lopts);
|
||||||
|
|
||||||
|
|
|
@ -208,9 +208,9 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
var shouldSkipValidation = function(walletId) {
|
var shouldSkipValidation = function(walletId) {
|
||||||
return root.profile.isChecked(platformInfo.ua, walletId) || isIOS || isWP;
|
return root.profile.isChecked(platformInfo.ua, walletId) || isIOS || isWP;
|
||||||
}
|
}
|
||||||
// Used when reading wallets from the profile
|
// Used when reading wallets from the profile
|
||||||
root.bindWallet = function(credentials, cb) {
|
root.bindWallet = function(credentials, cb) {
|
||||||
if (!credentials.walletId || !credentials.m)
|
if (!credentials.walletId || !credentials.m)
|
||||||
return cb('bindWallet should receive credentials JSON');
|
return cb('bindWallet should receive credentials JSON');
|
||||||
|
@ -618,6 +618,8 @@ angular.module('copayApp.services')
|
||||||
walletClient.importFromMnemonic(words, {
|
walletClient.importFromMnemonic(words, {
|
||||||
network: opts.networkName,
|
network: opts.networkName,
|
||||||
passphrase: opts.passphrase,
|
passphrase: opts.passphrase,
|
||||||
|
entropySourcePath: opts.entropySourcePath,
|
||||||
|
derivationStrategy: opts.derivationStrategy || 'BIP44',
|
||||||
account: opts.account || 0,
|
account: opts.account || 0,
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -18,7 +18,9 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.getEntropySource = function(isMultisig, account, callback) {
|
root.getEntropySource = function(isMultisig, account, callback) {
|
||||||
|
console.log('[trezor.js.20:isMultisig:]',root.description.id, isMultisig, account); //TODO
|
||||||
root.getXPubKey(hwWallet.getEntropyPath(root.description.id, isMultisig, account), function(data) {
|
root.getXPubKey(hwWallet.getEntropyPath(root.description.id, isMultisig, account), function(data) {
|
||||||
|
console.log('[trezor.js.21:data:]',data); //TODO
|
||||||
if (!data.success)
|
if (!data.success)
|
||||||
return callback(hwWallet._err(data));
|
return callback(hwWallet._err(data));
|
||||||
|
|
||||||
|
@ -30,6 +32,7 @@ angular.module('copayApp.services')
|
||||||
root.getXPubKey = function(path, callback) {
|
root.getXPubKey = function(path, callback) {
|
||||||
$log.debug('TREZOR deriving xPub path:', path);
|
$log.debug('TREZOR deriving xPub path:', path);
|
||||||
try {
|
try {
|
||||||
|
console.log('[trezor.js.35:path:]',path); //TODO
|
||||||
TrezorConnect.getXPubKey(path, callback);
|
TrezorConnect.getXPubKey(path, callback);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
callback('Error connecting Trezor');
|
callback('Error connecting Trezor');
|
||||||
|
|
|
@ -49,14 +49,23 @@
|
||||||
ng-model="formData.derivationPath">
|
ng-model="formData.derivationPath">
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
||||||
|
<ion-toggle ng-model="formData.fromHardwareWallet" toggle-class="toggle-positive">
|
||||||
|
<span translate>From Hardware Wallet</span>
|
||||||
|
</ion-toggle>
|
||||||
|
|
||||||
|
<select ng-model="formData.seedSourceAll" ng-options="seed as seed.label for seed in seedOptionsAll"></select>
|
||||||
|
|
||||||
|
<ion-toggle ng-model="formData.testnetEnabled" ng-change="setDerivationPath()" toggle-class="toggle-positive">
|
||||||
|
<span translate>Testnet</span>
|
||||||
|
</ion-toggle>
|
||||||
|
|
||||||
|
|
||||||
<label class="item item-input item-stacked-label">
|
<label class="item item-input item-stacked-label">
|
||||||
<span class="input-label" translate>Wallet Service URL</span>
|
<span class="input-label" translate>Wallet Service URL</span>
|
||||||
<input type="text" ng-model="formData.bwsurl">
|
<input type="text" ng-model="formData.bwsurl">
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<ion-toggle ng-model="formData.testnetEnabled" ng-change="setDerivationPath()" toggle-class="toggle-positive">
|
|
||||||
<span translate>Testnet</span>
|
|
||||||
</ion-toggle>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue