From 7eede2907986a4dcec277f05615c3136360ad801 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 6 Jun 2017 20:52:09 -0300 Subject: [PATCH 1/3] fix sign target --- app-template/package-template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app-template/package-template.json b/app-template/package-template.json index dfed0be08..9373b5b7d 100644 --- a/app-template/package-template.json +++ b/app-template/package-template.json @@ -107,7 +107,7 @@ "run:android": "cordova run android --device", "run:android-release": "cordova run android --device --release", "log:android": "adb logcat | grep chromium", - "sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && ../android-sdk-macosx/build-tools/21.1.1/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk", + "sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && ../android-sdk-macosx/build-tools/25.0.3/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk", "apply:copay": "npm i fs-extra && cd app-template && node apply.js copay && npm i && cordova prepare", "apply:bitpay": "npm i fs-extra && cd app-template && node apply.js bitpay && npm i && cordova prepare", "test": "echo \"no package tests configured\"", From da15bc939baa38c3e8d9825bfc16cf41f71993a1 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 12 Jun 2017 16:22:50 -0300 Subject: [PATCH 2/3] allow importing HW seeds --- app-template/copay/appConfig.json | 2 +- src/js/controllers/import.js | 33 +++++++++++++++++++++++++++++-- src/js/services/profileService.js | 8 +++++--- src/js/services/trezor.js | 3 +++ www/views/tab-import-phrase.html | 15 +++++++++++--- 5 files changed, 52 insertions(+), 9 deletions(-) diff --git a/app-template/copay/appConfig.json b/app-template/copay/appConfig.json index cde53fefa..625cbd184 100644 --- a/app-template/copay/appConfig.json +++ b/app-template/copay/appConfig.json @@ -22,7 +22,7 @@ "windowsAppId": "804636ee-b017-4cad-8719-e58ac97ffa5c", "pushSenderId": "1036948132229", "description": "A Secure Bitcoin Wallet", - "version": "3.4.0", + "version": "3.4.1", "androidVersion": "340001", "_extraCSS": null, "_enabledExtensions": { diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index c5657d5cf..0c3fbdf7d 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -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); diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 6ef9b96b0..8c5a93662 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -208,9 +208,9 @@ angular.module('copayApp.services') }; var shouldSkipValidation = function(walletId) { - return root.profile.isChecked(platformInfo.ua, walletId) || isIOS || isWP; - } - // Used when reading wallets from the profile + return root.profile.isChecked(platformInfo.ua, walletId) || isIOS || isWP; + } + // Used when reading wallets from the profile root.bindWallet = function(credentials, cb) { if (!credentials.walletId || !credentials.m) return cb('bindWallet should receive credentials JSON'); @@ -618,6 +618,8 @@ angular.module('copayApp.services') walletClient.importFromMnemonic(words, { network: opts.networkName, passphrase: opts.passphrase, + entropySourcePath: opts.entropySourcePath, + derivationStrategy: opts.derivationStrategy || 'BIP44', account: opts.account || 0, }, function(err) { if (err) { diff --git a/src/js/services/trezor.js b/src/js/services/trezor.js index 0411386fc..b835e1ae9 100644 --- a/src/js/services/trezor.js +++ b/src/js/services/trezor.js @@ -18,7 +18,9 @@ angular.module('copayApp.services') }; 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) { +console.log('[trezor.js.21:data:]',data); //TODO if (!data.success) return callback(hwWallet._err(data)); @@ -30,6 +32,7 @@ angular.module('copayApp.services') root.getXPubKey = function(path, callback) { $log.debug('TREZOR deriving xPub path:', path); try { +console.log('[trezor.js.35:path:]',path); //TODO TrezorConnect.getXPubKey(path, callback); } catch (e) { callback('Error connecting Trezor'); diff --git a/www/views/tab-import-phrase.html b/www/views/tab-import-phrase.html index 4146cac79..50d021038 100644 --- a/www/views/tab-import-phrase.html +++ b/www/views/tab-import-phrase.html @@ -49,14 +49,23 @@ ng-model="formData.derivationPath"> + + + From Hardware Wallet + + + + + + Testnet + + + - - Testnet - From 210d867c59f4d421a1e3816855fa94fcfd2670f4 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 12 Jun 2017 16:53:03 -0300 Subject: [PATCH 3/3] Fix toggle --- src/js/controllers/import.js | 3 ++- www/views/tab-import-phrase.html | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 0c3fbdf7d..331a2bfff 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -17,6 +17,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.formData.account = 1; $scope.importErr = false; $scope.isCopay = appConfigService.name == 'copay'; + $scope.fromHardwareWallet = { value: false }; if ($stateParams.code) $scope.processWalletInfo($stateParams.code); @@ -273,7 +274,7 @@ angular.module('copayApp.controllers').controller('importController', opts.passphrase = $scope.formData.passphrase || null; - if ($scope.formData.fromHardwareWallet) { + if ($scope.fromHardwareWallet.value) { $log.debug('Importing seed from hardware wallet'); $log.warn('This wont work for Intel TEE wallets'); diff --git a/www/views/tab-import-phrase.html b/www/views/tab-import-phrase.html index 50d021038..5b692f17e 100644 --- a/www/views/tab-import-phrase.html +++ b/www/views/tab-import-phrase.html @@ -50,11 +50,16 @@ - - From Hardware Wallet + + From Hardware Wallet - + Testnet