From effbd098a6cd0bb8363fce5a48631d8f698df1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 29 Aug 2016 11:56:31 -0300 Subject: [PATCH 01/15] onboarding allow push notifications --- public/views/onboarding/collectEmail.html | 4 +-- public/views/onboarding/notifications.html | 2 +- .../controllers/onboarding/backupRequest.js | 2 +- .../controllers/onboarding/backupWarning.js | 2 +- src/js/controllers/onboarding/collectEmail.js | 10 ++++-- .../controllers/onboarding/notifications.js | 6 ++-- src/js/controllers/onboarding/tour.js | 2 +- src/js/services/profileService.js | 36 ++++++++++--------- 8 files changed, 36 insertions(+), 28 deletions(-) diff --git a/public/views/onboarding/collectEmail.html b/public/views/onboarding/collectEmail.html index b03f80f7f..a539eaaa0 100644 --- a/public/views/onboarding/collectEmail.html +++ b/public/views/onboarding/collectEmail.html @@ -1,7 +1,7 @@ - + - diff --git a/public/views/onboarding/notifications.html b/public/views/onboarding/notifications.html index cb97ea4cd..555a06d08 100644 --- a/public/views/onboarding/notifications.html +++ b/public/views/onboarding/notifications.html @@ -1,5 +1,5 @@ - +

Push Notifications diff --git a/src/js/controllers/onboarding/backupRequest.js b/src/js/controllers/onboarding/backupRequest.js index 8b22651a6..60ae381f2 100644 --- a/src/js/controllers/onboarding/backupRequest.js +++ b/src/js/controllers/onboarding/backupRequest.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('backupRequestController', function($rootScope, $scope, $state, $ionicPopup, $stateParams, profileService, walletService) { +angular.module('copayApp.controllers').controller('backupRequestController', function($scope, $state, $ionicPopup) { $scope.openPopup = function() { var backupLaterPopup = $ionicPopup.show({ diff --git a/src/js/controllers/onboarding/backupWarning.js b/src/js/controllers/onboarding/backupWarning.js index abde7a7d3..f0b7c4978 100644 --- a/src/js/controllers/onboarding/backupWarning.js +++ b/src/js/controllers/onboarding/backupWarning.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('backupWarningController', function($rootScope, $scope, $state, $ionicPopup, $stateParams, profileService, walletService) { +angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $ionicPopup, profileService) { $scope.openPopup = function() { var backupWarningPopup = $ionicPopup.show({ diff --git a/src/js/controllers/onboarding/collectEmail.js b/src/js/controllers/onboarding/collectEmail.js index 2d19a1a2f..e92aa6cc9 100644 --- a/src/js/controllers/onboarding/collectEmail.js +++ b/src/js/controllers/onboarding/collectEmail.js @@ -1,6 +1,11 @@ 'use strict'; -angular.module('copayApp.controllers').controller('collectEmailController', function($rootScope, $scope, $state, $stateParams, $timeout, $ionicModal, profileService, walletService) { +angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $stateParams, profileService, walletService, platformInfo) { + + $scope.skip = function() { + if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); + else $state.go('onboarding.notifications'); + } $scope.save = function(form) { var wallet = profileService.getWallet($stateParams.walletId); @@ -10,7 +15,8 @@ angular.module('copayApp.controllers').controller('collectEmailController', func email: email, }, function(err) { if (err) $log.warn(err); - $state.go('onboarding.notifications'); + if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); + else $state.go('onboarding.notifications'); }); }; diff --git a/src/js/controllers/onboarding/notifications.js b/src/js/controllers/onboarding/notifications.js index dabb17eb3..2b40cd65a 100644 --- a/src/js/controllers/onboarding/notifications.js +++ b/src/js/controllers/onboarding/notifications.js @@ -1,11 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, platformInfo) { - - if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); +angular.module('copayApp.controllers').controller('notificationsController', function($scope, $state, profileService) { $scope.allowNotif = function() { - // T O D O + profileService.pushNotificationsInit(); $state.go('onboarding.backupRequest'); } diff --git a/src/js/controllers/onboarding/tour.js b/src/js/controllers/onboarding/tour.js index 2f361158c..662b0431d 100644 --- a/src/js/controllers/onboarding/tour.js +++ b/src/js/controllers/onboarding/tour.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.controllers').controller('tourController', - function($scope, $stateParams, $state, $log, $timeout, ongoingProcess, storageService, profileService) { + function($scope, $state, $log, $timeout, ongoingProcess, profileService) { $scope.init = function() { diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 12d55b3e5..f50a6cd29 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -16,19 +16,23 @@ angular.module('copayApp.services') root.profile = null; - Object.defineProperty(root, "focusedClient", { - get: function () { throw "focusedClient is not used any more" }, - set: function () { throw "focusedClient is not used any more" } + Object.defineProperty(root, "focusedClient", { + get: function() { + throw "focusedClient is not used any more" + }, + set: function() { + throw "focusedClient is not used any more" + } }); - - root.wallet = {}; // decorated version of client + + root.wallet = {}; // decorated version of client root.updateWalletSettings = function(wallet) { var defaults = configService.getDefaults(); var config = configService.getSync(); - wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url); + wallet.usingCustomBWS = config.bwsFor[wallet.id] && (config.bwsFor[wallet.id] != defaults.bws.url); wallet.name = config.aliasFor[wallet.id] || wallet.credentials.walletName; wallet.color = config.colorFor[wallet.id] || '#4A90E2'; @@ -69,7 +73,7 @@ angular.module('copayApp.services') // notification? - // TODO (put this in wallet ViewModel) + // TODO (put this in wallet ViewModel) if (wallet.cachedStatus) wallet.cachedStatus.isValid = false; @@ -99,7 +103,7 @@ angular.module('copayApp.services') } wallet.setNotificationsInterval(UPDATE_PERIOD); wallet.openWallet(function(err) { - if (wallet.status !== true) + if (wallet.status !== true) $log.log('Wallet + ' + walletId + ' status:' + wallet.status) }); }); @@ -107,7 +111,7 @@ angular.module('copayApp.services') $rootScope.$on('Local/SettingsUpdated', function(e, walletId) { if (!walletId || walletId == wallet.id) { - $log.debug('Updating settings for wallet:' + wallet.id); + $log.debug('Updating settings for wallet:' + wallet.id); root.updateWalletSettings(wallet); } }); @@ -159,7 +163,7 @@ angular.module('copayApp.services') if (!credentials.walletId || !credentials.m) return cb('bindWallet should receive credentials JSON'); - // Create the client + // Create the client var getBWSURL = function(walletId) { var config = configService.getSync(); var defaults = configService.getDefaults(); @@ -206,9 +210,6 @@ angular.module('copayApp.services') } bindWallets(function() { - if (usePushNotifications) - root.pushNotificationsInit(); - root.isBound = true; lodash.each(root._queue, function(x) { @@ -224,6 +225,8 @@ angular.module('copayApp.services') if (!val) { return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer')); } + if (usePushNotifications) + root.pushNotificationsInit(); $rootScope.$emit('disclaimerAccepted'); return cb(); }); @@ -716,10 +719,11 @@ angular.module('copayApp.services') ret = lodash.filter(ret, function(w) { return w.isComplete(); }); - } else { - } + } else {} - return lodash.sortBy(ret, [ function(x) { return x.isComplete(); }, 'createdOn']); + return lodash.sortBy(ret, [function(x) { + return x.isComplete(); + }, 'createdOn']); }; return root; From d6c2915d66ca54df47e3d73528fc6f778a44e1a6 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Thu, 25 Aug 2016 19:07:41 -0300 Subject: [PATCH 02/15] . --- public/views/tab-home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/views/tab-home.html b/public/views/tab-home.html index 1fae3a978..dad46a8b3 100644 --- a/public/views/tab-home.html +++ b/public/views/tab-home.html @@ -22,7 +22,7 @@ More ({{notificationsMore}}) -(ToDo: 1-1 no here yet) +(ToDo: Cache, refresh & seft not. 1-1 no here yet)
From cc7bc88ee6e703c7a88da87ffcaeccb2747aeb5d Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 11:24:22 -0300 Subject: [PATCH 03/15] . --- chrome-app/manifest.json | 2 +- package.json | 10 ++++------ webkitbuilds/.desktop | 2 +- webkitbuilds/setup-win.iss | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/chrome-app/manifest.json b/chrome-app/manifest.json index fc689fd60..7f7f2324b 100644 --- a/chrome-app/manifest.json +++ b/chrome-app/manifest.json @@ -5,7 +5,7 @@ "manifest_version": 2, "name": "BitPay", "description": "The BitPay Bitcoin Wallet", - "version": "0.3.0", + "version": "0.6.0", "permissions": [ "storage", "unlimitedStorage", diff --git a/package.json b/package.json index 0785ac8e7..f7955d753 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ - { + { "//":"PLEASE! Do not edit this file directly", - "//":" Modify it at app-template/", + "//":" Modify it at app-template/", "name": "bitpay", "description": "The BitPay Bitcoin Wallet", "author": "BitPay", - "version": "0.3.0", + "version": "0.6.0", "keywords": [ "wallet", "copay", @@ -23,10 +23,8 @@ "visible": true, "resizable": true, "frame": true, - "width": 400, + "width": 800, "height": 600, - "min_width": 400, - "min_height": 600, "position": "center", "fullscreen": false }, diff --git a/webkitbuilds/.desktop b/webkitbuilds/.desktop index 67bbc6f08..e83b575d2 100644 --- a/webkitbuilds/.desktop +++ b/webkitbuilds/.desktop @@ -1,6 +1,6 @@ [Desktop Entry] Type=Application -Version=0.3.0 +Version=0.6.0 Name=BitPay Comment=The BitPay Bitcoin Wallet Exec=bitpay diff --git a/webkitbuilds/setup-win.iss b/webkitbuilds/setup-win.iss index 7973ff779..356408e01 100755 --- a/webkitbuilds/setup-win.iss +++ b/webkitbuilds/setup-win.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "bitpay" -#define MyAppVersion "0.3.0" +#define MyAppVersion "0.6.0" #define MyAppPublisher "BitPay" #define MyAppURL "https://bitpay.com" #define MyAppExeName "*NAMECASENOSPACE.exe" From 5864afd8c08db91528f77e37fe1cd371407f3bd1 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 11:58:23 -0300 Subject: [PATCH 04/15] BWC 4.0 WIP --- app-template/package.json | 2 +- package.json | 2 +- public/views/preferences.html | 23 +++-- src/js/controllers/backup.js | 35 +++---- src/js/controllers/preferences.js | 52 ++++------- src/js/services/walletService.js | 148 ++++++++++++++++-------------- 6 files changed, 122 insertions(+), 140 deletions(-) diff --git a/app-template/package.json b/app-template/package.json index 369729f80..1b9235f8c 100644 --- a/app-template/package.json +++ b/app-template/package.json @@ -42,7 +42,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "2.11.0", + "bitcore-wallet-client": "4.0.0", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", diff --git a/package.json b/package.json index f7955d753..dbd5438d2 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "url": "https://github.com/bitpay/copay/issues" }, "dependencies": { - "bitcore-wallet-client": "2.11.0", + "bitcore-wallet-client": "4.0.0", "coveralls": "^2.11.9", "express": "^4.11.2", "fs": "0.0.2", diff --git a/public/views/preferences.html b/public/views/preferences.html index 0a3f1260a..075194522 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -20,18 +20,12 @@
- Devices + Wallet Type - 1 + wallet.m-of-wallet.n
-
- Required number of signatures - - 1 - -
-
+
Hardware wallet {{wallet.externalSource}} @@ -56,15 +50,20 @@
Security
-
+
Backup
-
- +
+ Request Spending Password
+
+ + Request Fingerprint + +
Delete recovery phrase diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 65ab2a89f..3d8045df4 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('backupController', function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) { var wallet = profileService.getWallet($stateParams.walletId); + var xPriv6; $scope.walletName = wallet.credentials.walletName; $scope.n = wallet.n; @@ -15,36 +16,17 @@ angular.module('copayApp.controllers').controller('backupController', return false; }; - var handleEncryptedWallet = function(client, cb) { - if (!walletService.isEncrypted(client)) { - return cb(); - } - - $rootScope.$emit('Local/NeedsPassword', false, function(err, password) { - if (err) return cb(err); - return cb(walletService.unlock(client, password)); - }); - }; - $scope.init = function() { $scope.deleted = isDeletedSeed(); if ($scope.deleted) return; - fingerprintService.check(wallet, function(err) { + walletService.getKey(wallet, function(err, mnemonics, xpriv) { if (err) { $state.go('preferences'); return; } - - handleEncryptedWallet(wallet, function(err) { - if (err) { - $log.warn('Error decrypting credentials:', $scope.error); - $state.go('preferences'); - return; - } - $scope.credentialsEncrypted = false; - $scope.initFlow(); - }); + $scope.credentialsEncrypted = false; + $scope.initFlow(mnemonics, xpriv); }); }; @@ -61,7 +43,8 @@ angular.module('copayApp.controllers').controller('backupController', $scope.initFlow = function() { var words = wallet.getMnemonic(); - $scope.xPrivKey = wallet.credentials.xPrivKey; + xPriv6 = wallet.credentials.xPrivKey.substr(wallet.credentials.xPrivKey.length - 6); + $scope.mnemonicWords = words.split(/[\u3000\s]+/); $scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords); $scope.mnemonicHasPassphrase = wallet.mnemonicHasPassphrase(); @@ -72,6 +55,7 @@ angular.module('copayApp.controllers').controller('backupController', $scope.selectComplete = false; $scope.backupError = false; + words = lodash.repeat('x', 300); $timeout(function() { $scope.$apply(); }, 10); @@ -139,10 +123,12 @@ angular.module('copayApp.controllers').controller('backupController', account: wallet.credentials.account }); } catch (err) { + walletClient.credentials.xPrivKey = lodash.repeat('x', 64); return cb(err); } - if (walletClient.credentials.xPrivKey != $scope.xPrivKey) { + if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey-6) != xPriv6) { + walletClient.credentials.xPrivKey = lodash.repeat('x', 64); return cb('Private key mismatch'); } } @@ -155,6 +141,7 @@ angular.module('copayApp.controllers').controller('backupController', var finalStep = function() { ongoingProcess.set('validatingWords', true); confirm(function(err) { + xPriv6 = lodash.repeat('x', 6); ongoingProcess.set('validatingWords', false); if (err) { backupError(err); diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index 4a72ae416..5118d70ef 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesController', - function($scope, $rootScope, $timeout, $log, $stateParams, configService, profileService, fingerprintService, walletService) { + function($scope, $rootScope, $timeout, $log, $stateParams, configService, profileService, fingerprintService, walletService, $state) { var wallet = profileService.getWallet($stateParams.walletId); var walletId = wallet.credentials.walletId; @@ -10,22 +10,20 @@ angular.module('copayApp.controllers').controller('preferencesController', $scope.init = function() { $scope.externalSource = null; - if (wallet) { - var config = configService.getSync(); - config.aliasFor = config.aliasFor || {}; - $scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName; - $scope.color = config.colorFor[walletId] || '#4A90E2'; + if (!wallet) + return $state.go('tabs.home'); - $scope.encryptEnabled = walletService.isEncrypted(wallet); - if (wallet.isPrivKeyExternal) - $scope.externalSource = wallet.getPrivKeyExternalSourceName() == 'ledger' ? 'Ledger' : 'Trezor'; + var config = configService.getSync(); + config.aliasFor = config.aliasFor || {}; + $scope.alias = config.aliasFor[walletId] || wallet.credentials.walletName; + $scope.color = config.colorFor[walletId] || '#4A90E2'; - // TODO externalAccount - //this.externalIndex = wallet.getExternalIndex(); - } + $scope.encryptEnabled = walletService.isEncrypted(wallet); + if (wallet.isPrivKeyExternal) + $scope.externalSource = wallet.getPrivKeyExternalSourceName() == 'ledger' ? 'Ledger' : 'Trezor'; - $scope.touchidAvailable = fingerprintService.isAvailable(); - $scope.touchidEnabled = config.touchIdFor ? config.touchIdFor[walletId] : null; + $scope.touchIdAvailable = fingerprintService.isAvailable(); + $scope.touchIdEnabled = config.touchIdFor ? config.touchIdFor[walletId] : null; $scope.deleted = false; if (wallet.credentials && !wallet.credentials.mnemonicEncrypted && !wallet.credentials.mnemonic) { @@ -101,29 +99,15 @@ angular.module('copayApp.controllers').controller('preferencesController', } }; - $scope.touchidChange = function() { - - var opts = { - touchIdFor: {} - }; - opts.touchIdFor[walletId] = $scope.touchidEnabled; - - fingerprintService.check(wallet, function(err) { + $scope.touchIdChange = function() { + var newStatus = $scope.touchIdEnabled; + walletService.setTouchId(wallet, newStatus, function(err) { if (err) { - $log.debug(err); - $timeout(function() { - $scope.touchidError = true; - $scope.touchidEnabled = true; - }, 100); + $log.warn(err); + $scope.touchIdEnabled = !newStatus; return; } - configService.set(opts, function(err) { - if (err) { - $log.debug(err); - $scope.touchidError = true; - $scope.touchidEnabled = false; - } - }); + $log.debug('Touch Id status changed: ' + newStatus); }); }; }); diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index b8b006e7e..5d3cbaf4c 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -547,27 +547,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim return isEncrypted; }; - root.lock = function(wallet) { - try { - wallet.lock(); - } catch (e) { - $log.warn('Encrypting wallet:', e); - }; - }; - - root.unlock = function(wallet, password) { - if (lodash.isEmpty(wallet)) - return 'MISSING_PARAMETER'; - if (lodash.isEmpty(password)) - return 'NO_PASSWORD_GIVEN'; - try { - wallet.unlock(password); - } catch (e) { - $log.warn('Decrypting wallet:', e); - return 'PASSWORD_INCORRECT'; - } - }; - root.createTx = function(wallet, txp, cb) { if (lodash.isEmpty(txp) || lodash.isEmpty(wallet)) return cb('MISSING_PARAMETER'); @@ -619,8 +598,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; - root.signTx = function(wallet, txp, cb) { - if (lodash.isEmpty(txp) || lodash.isEmpty(wallet)) + root.signTx = function(wallet, txp, password, cb) { + if (lodash.isEmpty(txp) || lodash.isEmpty(wallet) || lodash.isEmpty(cb)) return cb('MISSING_PARAMETER'); if (wallet.isPrivKeyExternal()) { @@ -637,8 +616,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim } else { try { - wallet.signTxProposal(txp, function(err, signedTxp) { - $log.debug('Transaction signed'); + wallet.signTxProposal(txp, password, function(err, signedTxp) { + $log.debug('Transaction signed err:' + err); return cb(err, signedTxp); }); } catch (e) { @@ -896,7 +875,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim askPassword(wallet.name, function(password) { if (!password) return cb('no password'); - return cb(root.unlock(wallet, password)); + + return cb(null, password); }); }; @@ -932,6 +912,19 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; + + root.prepare = function(wallet, cb) { + fingerprintService.check(wallet, function(err) { + if (err) return cb(err); + + root.handleEncryptedWallet(wallet, function(err, password) { + if (err) return cb(err); + + return cb(null, password); + }); + }); + }; + root.publishAndSign = function(wallet, txp, cb) { var publishFn = root.publishTx; @@ -943,56 +936,50 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; } - fingerprintService.check(wallet, function(err) { + root.prepare(wallet, function(err, password) { if (err) return cb(err); - root.handleEncryptedWallet(wallet, function(err) { + ongoingProcess.set('sendingTx', true); + publishFn(wallet, txp, function(err, publishedTxp) { + ongoingProcess.set('sendingTx', false); if (err) return cb(err); - ongoingProcess.set('sendingTx', true); - publishFn(wallet, txp, function(err, publishedTxp) { - ongoingProcess.set('sendingTx', false); - if (err) return cb(err); - - ongoingProcess.set('signingTx', true); - root.signTx(wallet, publishedTxp, function(err, signedTxp) { - root.lock(wallet); - - ongoingProcess.set('signingTx', false); - root.invalidateCache(wallet); + ongoingProcess.set('signingTx', true); + root.signTx(wallet, publishedTxp, password, function(err, signedTxp) { + ongoingProcess.set('signingTx', false); + root.invalidateCache(wallet); - if (err) { - // TODO? - var msg = err.message ? - err.message : - gettext('The payment was created but could not be completed. Please try again from home screen'); - $rootScope.$emit('Local/TxAction', wallet.id); - return cb(err); - } + if (err) { + // TODO? + var msg = err.message ? + err.message : + gettext('The payment was created but could not be completed. Please try again from home screen'); + $rootScope.$emit('Local/TxAction', wallet.id); + return cb(err); + } - if (signedTxp.status == 'accepted') { - ongoingProcess.set('broadcastingTx', true); - root.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) { - ongoingProcess.set('broadcastingTx', false); - if (err) return cb(err); + if (signedTxp.status == 'accepted') { + ongoingProcess.set('broadcastingTx', true); + root.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) { + ongoingProcess.set('broadcastingTx', false); + if (err) return cb(err); - var type = txStatus.notify(broadcastedTxp); - root.openStatusModal(type, broadcastedTxp, function() { - $rootScope.$emit('Local/TxAction', wallet.id); - }); - - return cb(null, broadcastedTxp) - }); - } else { - var type = txStatus.notify(signedTxp); - root.openStatusModal(type, signedTxp, function() { - root.invalidateCache(wallet); + var type = txStatus.notify(broadcastedTxp); + root.openStatusModal(type, broadcastedTxp, function() { $rootScope.$emit('Local/TxAction', wallet.id); }); - return cb(null, signedTxp); - } - }); + + return cb(null, broadcastedTxp) + }); + } else { + var type = txStatus.notify(signedTxp); + root.openStatusModal(type, signedTxp, function() { + root.invalidateCache(wallet); + $rootScope.$emit('Local/TxAction', wallet.id); + }); + return cb(null, signedTxp); + } }); }); }); @@ -1004,7 +991,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim if (err) return cb(err); notifications = lodash.filter(notifications, function(x) { - return x.type != 'NewBlock' && x.type != 'BalanceUpdated' && x.type !='NewOutgoingTxByThirdParty'; + return x.type != 'NewBlock' && x.type != 'BalanceUpdated' && x.type != 'NewOutgoingTxByThirdParty'; }); var idToName = {}; @@ -1110,7 +1097,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim } }); - // messsages... + // messages... var u = bwcService.getUtils(); lodash.each(finale, function(x) { @@ -1124,6 +1111,31 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; + root.setTouchId = function(wallet, enabled, cb) { + fingerprintService.check(wallet, function(err) { + if (err) return cb(err); { + $log.debug(err); + return; + } + configService.set(opts, cb); + }); + }; + + root.getKey = function(wallet, cb) { + root.prepare(wallet, function(err, password) { + if (err) return cb(err); + var keys; + + try { + keys = wallet.getKeys(password); + } catch (e) { + return cb(err); + } + + return cb(null, keys); + }); + }; + return root; }); From 392d8f7292681d5e793c4195c279a4dc67f38fa0 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 15:17:41 -0300 Subject: [PATCH 05/15] encrypted wallet feat migrated to BWC 4.0.0 --- public/views/preferences.html | 4 +- src/js/controllers/confirm.js | 2 +- src/js/controllers/preferences.js | 78 +++++++++---------------------- src/js/controllers/tab-home.js | 1 - src/js/services/profileService.js | 13 ------ src/js/services/walletService.js | 72 ++++++++++++++++------------ 6 files changed, 69 insertions(+), 101 deletions(-) diff --git a/public/views/preferences.html b/public/views/preferences.html index 075194522..6e761c24a 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -22,7 +22,7 @@
Wallet Type - wallet.m-of-wallet.n + {{wallet.m}}-of-{{wallet.n}}
@@ -55,7 +55,7 @@
- + Request Spending Password
diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 4ec35031e..e9af90994 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -189,7 +189,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( }; var setSendError = function(msg) { - showAlert(gettext('Error creating transaction'), msg); + showAlert(gettext('Error at confirm:'), msg); }; function apply(txp) { diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index 5118d70ef..92fb04344 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -31,71 +31,39 @@ angular.module('copayApp.controllers').controller('preferencesController', } }; - var handleEncryptedWallet = function(cb) { - $rootScope.$emit('Local/NeedsPassword', false, function(err, password) { - if (err) return cb(err); - return cb(walletService.unlock(wallet, password)); - }); - }; - $scope.encryptChange = function() { if (!wallet) return; var val = $scope.encryptEnabled; - var setPrivateKeyEncryption = function(password, cb) { - $log.debug('Encrypting private key for', wallet.credentials.walletName); - - wallet.setPrivateKeyEncryption(password); - wallet.lock(); - profileService.updateCredentials(JSON.parse(wallet.export()), function() { - $log.debug('Wallet encrypted'); - return cb(); - }); - }; - - var disablePrivateKeyEncryption = function(cb) { - $log.debug('Disabling private key encryption for', wallet.credentials.walletName); - - try { - wallet.disablePrivateKeyEncryption(); - } catch (e) { - return cb(e); - } - profileService.updateCredentials(JSON.parse(wallet.export()), function() { - $log.debug('Wallet encryption disabled'); - return cb(); - }); - }; - if (val && !walletService.isEncrypted(wallet)) { - $rootScope.$emit('Local/NeedsPassword', true, function(err, password) { - if (err || !password) { + $log.debug('Encrypting private key for', wallet.name); + walletService.encrypt(wallet, function(err) { + if (err) { + $log.warn(err); + + // ToDo show error? $scope.encryptEnabled = false; return; } - setPrivateKeyEncryption(password, function() { - $rootScope.$emit('Local/NewEncryptionSetting'); + profileService.updateCredentials(JSON.parse(wallet.export()), function() { + $log.debug('Wallet encrypted'); + return; + }); + }) + } else if (!val && walletService.isEncrypted(wallet)) { + walletService.decrypt(wallet, function(err) { + if (err) { + $log.warn(err); + + // ToDo show error? $scope.encryptEnabled = true; + return; + } + profileService.updateCredentials(JSON.parse(wallet.export()), function() { + $log.debug('Wallet decrypted'); + return; }); - }); - } else { - if (!val && walletService.isEncrypted(wallet)) { - handleEncryptedWallet(function(err) { - if (err) { - $scope.encryptEnabled = true; - return; - } - disablePrivateKeyEncryption(function(err) { - $rootScope.$emit('Local/NewEncryptionSetting'); - if (err) { - $scope.encryptEnabled = true; - $log.error(err); - return; - } - $scope.encryptEnabled = false; - }); - }); - } + }) } }; diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index da9538144..b6886b5c2 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -37,7 +37,6 @@ angular.module('copayApp.controllers').controller('tabHomeController', walletService.getNotifications(wallet, { timeSpan: timeSpan }, function(err, n) { -console.log('[tab-home.js.39]', wallet.name, n); //TODO if (err) { console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO return; diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 12d55b3e5..d54881695 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -87,11 +87,6 @@ angular.module('copayApp.services') }); }); - if (wallet.hasPrivKeyEncrypted() && !wallet.isPrivKeyEncrypted()) { - $log.warn('Auto locking unlocked wallet:' + walletId); - wallet.lock(); - } - wallet.initialize({}, function(err) { if (err) { $log.error('Could not init notifications err:', err); @@ -548,14 +543,6 @@ angular.module('copayApp.services') return cb(gettext('Could not import. Check input file and spending password')); } - if (walletClient.hasPrivKeyEncrypted()) { - try { - walletClient.disablePrivateKeyEncryption(); - } catch (e) { - $log.warn(e); - } - } - str = JSON.parse(str); var addressBook = str.addressBook || {}; diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 5d3cbaf4c..26407ee1e 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -557,28 +557,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim else return cb(null, createdTxp); }); } else { - wallet.getFeeLevels(wallet.credentials.network, function(err, levels) { + wallet.createTxProposal(txp, function(err, createdTxp) { if (err) return cb(err); - - var feeLevelValue = lodash.find(levels, { - level: txp.feeLevel - }); - - if (!feeLevelValue || !feeLevelValue.feePerKB) - return cb({ - message: 'Could not get dynamic fee for level: ' + feeLevel - }); - - $log.debug('Dynamic fee: ' + txp.feeLevel + ' ' + feeLevelValue.feePerKB + ' SAT'); - - txp.feePerKb = feeLevelValue.feePerKB; - wallet.createTxProposal(txp, function(err, createdTxp) { - if (err) return cb(err); - else { - $log.debug('Transaction created'); - return cb(null, createdTxp); - } - }); + else { + $log.debug('Transaction created'); + return cb(null, createdTxp); + } }); } }; @@ -599,7 +583,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }; root.signTx = function(wallet, txp, password, cb) { - if (lodash.isEmpty(txp) || lodash.isEmpty(wallet) || lodash.isEmpty(cb)) + if (!wallet || !txp || !cb) return cb('MISSING_PARAMETER'); if (wallet.isPrivKeyExternal()) { @@ -840,12 +824,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim // An alert dialog - var askPassword = function(name, cb) { + var askPassword = function(name, title, cb) { var scope = $rootScope.$new(true); scope.data = []; var pass = $ionicPopup.show({ template: '', - title: 'Enter Spending Password', + title: title, subTitle: name, scope: scope, buttons: [{ @@ -870,10 +854,39 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; + + root.encrypt = function(wallet, cb) { + askPassword(wallet.name, gettext('Enter new spending password'), function(password) { + if (!password) return cb('no password'); + askPassword(wallet.name, gettext('Confirm you new spending password'), function(password2) { + if (!password2 || password != password2) + return cb('password mismatch'); + + wallet.encryptPrivateKey(password); + return cb(); + }); + }); + }; + + + root.decrypt = function(wallet, cb) { + $log.debug('Disabling private key encryption for' + wallet.name); + askPassword(wallet.name, gettext('Enter Spending Password'), function(password) { + if (!password) return cb('no password'); + + try { + wallet.decryptPrivateKey(password); + } catch (e) { + return cb(e); + } + return cb(); + }); + }; + root.handleEncryptedWallet = function(wallet, cb) { if (!root.isEncrypted(wallet)) return cb(); - askPassword(wallet.name, function(password) { + askPassword(wallet.name, gettext('Enter Spending Password'), function(password) { if (!password) return cb('no password'); return cb(null, password); @@ -937,12 +950,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim } root.prepare(wallet, function(err, password) { - if (err) return cb(err); + if (err) return cb('Prepare error: ' + err); ongoingProcess.set('sendingTx', true); publishFn(wallet, txp, function(err, publishedTxp) { ongoingProcess.set('sendingTx', false); - if (err) return cb(err); + if (err) return cb('Send Error: ' + err); ongoingProcess.set('signingTx', true); root.signTx(wallet, publishedTxp, password, function(err, signedTxp) { @@ -951,19 +964,20 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim if (err) { + $log.warn('sign error:' + err); // TODO? var msg = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen'); $rootScope.$emit('Local/TxAction', wallet.id); - return cb(err); + return cb(msg); } if (signedTxp.status == 'accepted') { ongoingProcess.set('broadcastingTx', true); root.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) { ongoingProcess.set('broadcastingTx', false); - if (err) return cb(err); + if (err) return cb('sign error' + err); var type = txStatus.notify(broadcastedTxp); root.openStatusModal(type, broadcastedTxp, function() { From 410153a2da449194b1f4c07299d2dce209069a06 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 15:24:46 -0300 Subject: [PATCH 06/15] . --- src/js/controllers/buyAmazon.js | 1 - src/js/controllers/sellCoinbase.js | 69 +----------------------------- 2 files changed, 1 insertion(+), 69 deletions(-) diff --git a/src/js/controllers/buyAmazon.js b/src/js/controllers/buyAmazon.js index afb87955e..335ab0cbc 100644 --- a/src/js/controllers/buyAmazon.js +++ b/src/js/controllers/buyAmazon.js @@ -244,7 +244,6 @@ angular.module('copayApp.controllers').controller('buyAmazonController', } walletService.signTx(wallet, publishedTxp, function(err, signedTxp) { - walletService.lock(wallet); if (err) { $log.debug(err); walletService.removeTx(wallet, signedTxp, function(err) { diff --git a/src/js/controllers/sellCoinbase.js b/src/js/controllers/sellCoinbase.js index 9d9f876eb..6ce9b28b3 100644 --- a/src/js/controllers/sellCoinbase.js +++ b/src/js/controllers/sellCoinbase.js @@ -30,14 +30,6 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', ]; $scope.selectedPriceSensitivity = $scope.priceSensitivity[1]; - var handleEncryptedWallet = function(client, cb) { - if (!walletService.isEncrypted(client)) return cb(); - $rootScope.$emit('Local/NeedsPassword', false, function(err, password) { - if (err) return cb(err); - return cb(walletService.unlock(client, password)); - }); - }; - this.init = function(testnet) { self.allWallets = profileService.getWallets(testnet ? 'testnet' : 'livenet', 1); @@ -263,66 +255,7 @@ angular.module('copayApp.controllers').controller('sellCoinbaseController', this.confirmTx = function(txp, cb) { - fingerprintService.check(client, function(err) { - if (err) { - $log.debug(err); - return cb(err); - } - - handleEncryptedWallet(client, function(err) { - if (err) { - $log.debug(err); - return cb(err); - } - - ongoingProcess.set('Sending Bitcoin to Coinbase...', true); - walletService.publishTx(client, txp, function(err, publishedTxp) { - if (err) { - ongoingProcess.set('Sending Bitcoin to Coinbase...', false); - $log.debug(err); - return cb({ - errors: [{ - message: 'Transaction could not be published: ' + err.message - }] - }); - } - - walletService.signTx(client, publishedTxp, function(err, signedTxp) { - walletService.lock(client); - if (err) { - ongoingProcess.set('Sending Bitcoin to Coinbase...', false); - $log.debug(err); - walletService.removeTx(client, signedTxp, function(err) { - if (err) $log.debug(err); - }); - return cb({ - errors: [{ - message: 'The payment was created but could not be completed: ' + err.message - }] - }); - } - - walletService.broadcastTx(client, signedTxp, function(err, broadcastedTxp) { - if (err) { - ongoingProcess.set('Sending Bitcoin to Coinbase...', false); - $log.debug(err); - walletService.removeTx(client, broadcastedTxp, function(err) { - if (err) $log.debug(err); - }); - return cb({ - errors: [{ - message: 'The payment was created but could not be broadcasted: ' + err.message - }] - }); - } - $timeout(function() { - return cb(null, broadcastedTxp); - }, 5000); - }); - }); - }); - }); - }); + // TODO see walletService createAndPublish }; }); From aa42db1458698371764ee5e2ab75b309b26d1c71 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 15:49:05 -0300 Subject: [PATCH 07/15] bp to walletService --- src/js/controllers/bitpayCard.js | 57 ++----------------------- src/js/controllers/modals/txpDetails.js | 4 -- src/js/controllers/sellGlidera.js | 53 ++++++++++------------- 3 files changed, 25 insertions(+), 89 deletions(-) diff --git a/src/js/controllers/bitpayCard.js b/src/js/controllers/bitpayCard.js index b861275e7..9451b38fa 100644 --- a/src/js/controllers/bitpayCard.js +++ b/src/js/controllers/bitpayCard.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, fingerprintService, ongoingProcess, bwcError, bitcore, pbkdf2Service, moment, platformInfo) { +angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, platformInfo) { var self = this; var wallet; @@ -205,7 +205,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi }; walletService.createTx(wallet, txp, function(err, createdTxp) { - ongoingProcess.set('Processing Transaction...', false); if (err) { self.error = bwcError.msg(err); $timeout(function() { @@ -213,10 +212,9 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi }); return; } - self.confirmTx(createdTxp, function(err, tx) { - ongoingProcess.set('Processing Transaction...', false); + walletService.publishAndSign(createdTxp, function(err, tx) { if (err) { - self.error = bwcError.msg(err); + self.error = err; $timeout(function() { $scope.$digest(); }); @@ -234,55 +232,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi }, 100); }; - this.confirmTx = function(txp, cb) { - - fingerprintService.check(wallet, function(err) { - if (err) { - $log.debug(err); - return cb(err); - } - - walletService.handleEncryptedWallet(wallet, function(err) { - if (err) { - $log.debug(err); - return bwcError.cb(err, null, cb); - } - - ongoingProcess.set('Processing Transaction...', true); - walletService.publishTx(wallet, txp, function(err, publishedTxp) { - if (err) { - $log.debug(err); - return bwcError.cb(err, null, cb); - } - - walletService.signTx(wallet, publishedTxp, function(err, signedTxp) { - walletService.lock(wallet); - if (err) { - $log.debug(err); - walletService.removeTx(wallet, signedTxp, function(err) { - if (err) $log.debug(err); - }); - return bwcError.cb(err, null, cb); - } - - walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) { - if (err) { - $log.debug(err); - walletService.removeTx(wallet, broadcastedTxp, function(err) { - if (err) $log.debug(err); - }); - return bwcError.cb(err, null, cb); - } - $timeout(function() { - return cb(null, broadcastedTxp); - }, 5000); - }); - }); - }); - }); - }); - }; - this.authenticate = function() { self.error = null; diff --git a/src/js/controllers/modals/txpDetails.js b/src/js/controllers/modals/txpDetails.js index 497a33e95..b426602e6 100644 --- a/src/js/controllers/modals/txpDetails.js +++ b/src/js/controllers/modals/txpDetails.js @@ -48,10 +48,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi }, 10); }; - $scope.$on('$destroy', function() { - walletService.lock($scope.wallet); - }); - $scope.reject = function(txp) { $scope.loading = true; $scope.error = null; diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index 66c0f0de0..e50757128 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -208,53 +208,44 @@ angular.module('copayApp.controllers').controller('sellGlideraController', self.error = err.message ||  bwcError.msg(err); return; } - fingerprintService.check(wallet, function(err) { + walletService.prepare(wallet, txp, function(err, password) { if (err) { self.error = err.message ||  bwcError.msg(err); return; } - - walletService.handleEncryptedWallet(wallet, function(err) { + ongoingProcess.set('signingTx', true); + walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) { if (err) { + ongoingProcess.clear(); self.error = err.message ||  bwcError.msg(err); - return; } - ongoingProcess.set('signingTx', true); - walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) { + walletService.signTx(wallet, publishedTxp, function(err, password, signedTxp) { + walletService.removeTx(wallet, signedTxp, function(err) { + if (err) $log.debug(err); + }); + ongoingProcess.clear(); if (err) { - ongoingProcess.clear(); self.error = err.message ||  bwcError.msg(err); + return; } - - walletService.signTx(wallet, publishedTxp, function(err, signedTxp) { - walletService.lock(wallet); - walletService.removeTx(wallet, signedTxp, function(err) { - if (err) $log.debug(err); - }); + var rawTx = signedTxp.raw; + var data = { + refundAddress: refundAddress, + signedTransaction: rawTx, + priceUuid: self.sellPrice.priceUuid, + useCurrentPrice: self.sellPrice.priceUuid ? false : true, + ip: null + }; + ongoingProcess.set('Seling Bitcoin', true); + glideraService.sell(token, twoFaCode, data, function(err, data) { ongoingProcess.clear(); if (err) { self.error = err.message ||  bwcError.msg(err); return; } - var rawTx = signedTxp.raw; - var data = { - refundAddress: refundAddress, - signedTransaction: rawTx, - priceUuid: self.sellPrice.priceUuid, - useCurrentPrice: self.sellPrice.priceUuid ? false : true, - ip: null - }; - ongoingProcess.set('Seling Bitcoin', true); - glideraService.sell(token, twoFaCode, data, function(err, data) { - ongoingProcess.clear(); - if (err) { - self.error = err.message ||  bwcError.msg(err); - return; - } - self.success = data; - $scope.update(); - }); + self.success = data; + $scope.update(); }); }); }); From f534b0bc2df8eac3f918bb91a032e4be825da0b6 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 16:13:18 -0300 Subject: [PATCH 08/15] fix spending passwor in export --- src/js/controllers/backup.js | 20 +++++---------- src/js/controllers/export.js | 9 ++----- src/js/services/walletService.js | 44 +++++++++++++------------------- 3 files changed, 27 insertions(+), 46 deletions(-) diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 3d8045df4..19a6ccdfb 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -8,7 +8,7 @@ angular.module('copayApp.controllers').controller('backupController', $scope.walletName = wallet.credentials.walletName; $scope.n = wallet.n; - $scope.credentialsEncrypted = wallet.isPrivKeyEncrypted; + $scope.credentialsEncrypted = wallet.isPrivKeyEncrypted(); var isDeletedSeed = function() { if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted)) @@ -20,13 +20,13 @@ angular.module('copayApp.controllers').controller('backupController', $scope.deleted = isDeletedSeed(); if ($scope.deleted) return; - walletService.getKey(wallet, function(err, mnemonics, xpriv) { + walletService.getKeys(wallet, function(err, keys) { if (err) { $state.go('preferences'); return; } $scope.credentialsEncrypted = false; - $scope.initFlow(mnemonics, xpriv); + $scope.initFlow(keys); }); }; @@ -41,9 +41,9 @@ angular.module('copayApp.controllers').controller('backupController', }); }; - $scope.initFlow = function() { - var words = wallet.getMnemonic(); - xPriv6 = wallet.credentials.xPrivKey.substr(wallet.credentials.xPrivKey.length - 6); + $scope.initFlow = function(keys) { + var words = keys.mnemonic; + xPriv6 = keys.xPrivKey.substr(wallet.credentials.xPrivKey.length - 6); $scope.mnemonicWords = words.split(/[\u3000\s]+/); $scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords); @@ -128,7 +128,7 @@ angular.module('copayApp.controllers').controller('backupController', } if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey-6) != xPriv6) { - walletClient.credentials.xPrivKey = lodash.repeat('x', 64); + delete walletClient.credentials; return cb('Private key mismatch'); } } @@ -141,7 +141,6 @@ angular.module('copayApp.controllers').controller('backupController', var finalStep = function() { ongoingProcess.set('validatingWords', true); confirm(function(err) { - xPriv6 = lodash.repeat('x', 6); ongoingProcess.set('validatingWords', false); if (err) { backupError(err); @@ -192,9 +191,4 @@ angular.module('copayApp.controllers').controller('backupController', $scope.selectComplete = false; }; - - $scope.$on('$destroy', function() { - walletService.lock(wallet); - }); - }); diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index 7c3870993..1ea44845f 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('exportController', - function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, notification, gettext, gettextCatalog, $state, $stateParams) { + function($rootScope, $scope, $timeout, $log, lodash, backupService, walletService, storageService, profileService, platformInfo, gettext, gettextCatalog, $state, $stateParams) { var prevState; var isWP = platformInfo.isWP; var isAndroid = platformInfo.isAndroid; @@ -21,7 +21,7 @@ angular.module('copayApp.controllers').controller('exportController', $scope.canSign = wallet.canSign(); walletService.getEncodedWalletInfo(wallet, function(err, code) { - if (err) { + if (err || !code) { $log.warn(err); return $state.go('wallet.preferencesAdvanced') } @@ -48,10 +48,6 @@ angular.module('copayApp.controllers').controller('exportController', }; */ - $scope.$on('$destroy', function() { - walletService.lock(wallet); - }); - $scope.downloadWalletBackup = function() { $scope.getAddressbook(function(err, localAddressBook) { if (err) { @@ -68,7 +64,6 @@ angular.module('copayApp.controllers').controller('exportController', $scope.error = true; return; } - notification.success(gettext('Success'), gettext('Encrypted export file saved')); $state.go('tabs.home'); }); }); diff --git a/src/js/services/walletService.js b/src/js/services/walletService.js index 26407ee1e..f4230fc33 100644 --- a/src/js/services/walletService.js +++ b/src/js/services/walletService.js @@ -1028,42 +1028,34 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim root.getEncodedWalletInfo = function(wallet, cb) { - var getCode = function() { - var derivationPath = wallet.credentials.getBaseAddressDerivationPath(); - var encodingType = { - mnemonic: 1, - xpriv: 2, - xpub: 3 - }; - var info; + var derivationPath = wallet.credentials.getBaseAddressDerivationPath(); + var encodingType = { + mnemonic: 1, + xpriv: 2, + xpub: 3 + }; + var info; - // not supported yet - if (wallet.credentials.derivationStrategy != 'BIP44' || !wallet.canSign()) - return null; + // not supported yet + if (wallet.credentials.derivationStrategy != 'BIP44' || !wallet.canSign()) + return null; - if (wallet.credentials.mnemonic) { + root.getKeys(wallet, function(err, keys){ + if (err || !keys) return cb(err); + + if (keys.mnemonic) { info = { type: encodingType.mnemonic, - data: wallet.credentials.mnemonic, + data: keys.mnemonic, } } else { info = { type: encodingType.xpriv, - data: wallet.credentials.xPrivKey + data: keys.xPrivKey } } - return info.type + '|' + info.data + '|' + wallet.credentials.network.toLowerCase() + '|' + derivationPath + '|' + (wallet.credentials.mnemonicHasPassphrase); - }; + return cb(null, info.type + '|' + info.data + '|' + wallet.credentials.network.toLowerCase() + '|' + derivationPath + '|' + (wallet.credentials.mnemonicHasPassphrase)); - fingerprintService.check(wallet, function(err) { - if (err) return cb(err); - - root.handleEncryptedWallet(wallet, function(err) { - if (err) return cb(err); - - var code = getCode(); - return cb(null, code); - }); }); }; @@ -1135,7 +1127,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim }); }; - root.getKey = function(wallet, cb) { + root.getKeys = function(wallet, cb) { root.prepare(wallet, function(err, password) { if (err) return cb(err); var keys; From ea7c8c5383167226359c6da93bc56c5b7fe309ad Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 29 Aug 2016 16:22:54 -0300 Subject: [PATCH 09/15] fix backup --- public/views/backup.html | 4 ++++ src/js/controllers/backup.js | 26 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/public/views/backup.html b/public/views/backup.html index 1606bff0f..46cb5ce27 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -7,6 +7,10 @@   + +
+delete mnemonics. You can still export it. +
diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index 19a6ccdfb..ad8c3cd3e 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -4,29 +4,34 @@ angular.module('copayApp.controllers').controller('backupController', function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) { var wallet = profileService.getWallet($stateParams.walletId); - var xPriv6; $scope.walletName = wallet.credentials.walletName; $scope.n = wallet.n; + var keys; $scope.credentialsEncrypted = wallet.isPrivKeyEncrypted(); var isDeletedSeed = function() { - if (lodash.isEmpty(wallet.credentials.mnemonic) && lodash.isEmpty(wallet.credentials.mnemonicEncrypted)) + if (!wallet.credentials.mnemonic && !wallet.credentials.mnemonicEncrypted) return true; + return false; }; $scope.init = function() { $scope.deleted = isDeletedSeed(); - if ($scope.deleted) return; + if ($scope.deleted) { + $log.debug('no mnemonics'); + return; + } - walletService.getKeys(wallet, function(err, keys) { - if (err) { - $state.go('preferences'); + walletService.getKeys(wallet, function(err, k) { + if (err || !k) { + $state.go('wallet.preferences'); return; } $scope.credentialsEncrypted = false; - $scope.initFlow(keys); + keys = k; + $scope.initFlow(); }); }; @@ -41,9 +46,10 @@ angular.module('copayApp.controllers').controller('backupController', }); }; - $scope.initFlow = function(keys) { + $scope.initFlow = function() { + if (!keys) return; + var words = keys.mnemonic; - xPriv6 = keys.xPrivKey.substr(wallet.credentials.xPrivKey.length - 6); $scope.mnemonicWords = words.split(/[\u3000\s]+/); $scope.shuffledMnemonicWords = shuffledWords($scope.mnemonicWords); @@ -127,7 +133,7 @@ angular.module('copayApp.controllers').controller('backupController', return cb(err); } - if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey-6) != xPriv6) { + if (walletClient.credentials.xPrivKey.substr(walletClient.credentials.xPrivKey) != keys.xPrivKey) { delete walletClient.credentials; return cb('Private key mismatch'); } From 6e1b7ec620e32d96b6803c37c19d7750d25ed62c Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 29 Aug 2016 17:01:34 -0300 Subject: [PATCH 10/15] Bitpay Card: uses common widget for selecting wallet. Minor fixes --- public/views/amount.html | 6 +-- public/views/bitpayCard.html | 36 +++++----------- public/views/buyAmazon.html | 2 +- src/js/controllers/bitpayCard.js | 62 ++++++++-------------------- src/js/services/bitpayCardService.js | 30 +++++++------- src/sass/main.scss | 15 +++++++ 6 files changed, 61 insertions(+), 90 deletions(-) diff --git a/public/views/amount.html b/public/views/amount.html index 51a2f2422..afb62b7fa 100644 --- a/public/views/amount.html +++ b/public/views/amount.html @@ -30,10 +30,10 @@
-
+
- - + {{alternativeIsoCode}} + {{unitName}}
{{amount || "0.00" }}
diff --git a/public/views/bitpayCard.html b/public/views/bitpayCard.html index 79289a5a7..3a7dc4ec5 100644 --- a/public/views/bitpayCard.html +++ b/public/views/bitpayCard.html @@ -15,7 +15,7 @@ -
+
Sandbox version. Only for testing purpose
@@ -31,7 +31,7 @@ Login to your account 2-Step Verification

-
{{bitpayCard.error}} @@ -63,7 +63,7 @@
- @@ -90,7 +90,7 @@
- @@ -121,7 +121,7 @@ -
{{bitpayCard.error}}
@@ -176,7 +176,7 @@
-
{{bitpayCard.error}} @@ -199,25 +199,11 @@ ng-model="fiat" autocomplete="off" required> - USD + USD - + +

@@ -234,8 +220,8 @@

- diff --git a/public/views/buyAmazon.html b/public/views/buyAmazon.html index f711b64a7..33ddb7985 100644 --- a/public/views/buyAmazon.html +++ b/public/views/buyAmazon.html @@ -50,7 +50,7 @@ max="500" ng-model="fiat" autocomplete="off" ignore-mouse-wheel required> - + USD diff --git a/src/js/controllers/bitpayCard.js b/src/js/controllers/bitpayCard.js index b861275e7..d05ff4a73 100644 --- a/src/js/controllers/bitpayCard.js +++ b/src/js/controllers/bitpayCard.js @@ -9,6 +9,15 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi StatusBar.backgroundColorByHexString("#293C92"); } + $scope.$on('Wallet/Changed', function(event, w) { + if (lodash.isEmpty(w)) { + $log.debug('No wallet provided'); + return; + } + wallet = w; + $log.debug('Wallet changed: ' + w.name); + }); + var processTransactions = function(invoices, history) { for (var i = 0; i < invoices.length; i++) { var matched = false; @@ -63,7 +72,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi bitpayCardService.isAuthenticated(function(err, bpSession) { self.loadingSession = false; if (err) { - self.error = err.data.error || 'Incorrect email or password'; return; } @@ -79,7 +87,7 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi bitpayCardService.transactionHistory(dateRange, function(err, history) { $scope.loadingHistory = false; if (err) { - self.error = err.error || err; + self.error = 'Error getting transactions'; return; } @@ -98,60 +106,24 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi $scope.dateRange = 'last30Days'; $scope.network = bitpayCardService.getEnvironment(); - self.allWallets = profileService.getWallets({ + $scope.wallets = profileService.getWallets({ network: $scope.network, - n: 1, onlyComplete: true }); self.update(); - if (lodash.isEmpty(self.allWallets)) return; + wallet = $scope.wallets[0]; - wallet = self.allWallets[0]; - - if (wallet.credentials.n > 1) + if (wallet && wallet.credentials.n > 1) self.isMultisigWallet = true; - - $timeout(function() { - self.selectedWalletId = wallet.credentials.walletId; - self.selectedWalletName = wallet.credentials.walletName; - $scope.$apply(); - }, 100); - }; - - $scope.openWalletsModal = function(wallets) { - self.error = null; - - $scope.wallets = wallets; - $scope.noColor = true; - $scope.self = self; - - $ionicModal.fromTemplateUrl('views/modals/wallets.html', { - scope: $scope, - animation: 'slide-in-up' - }).then(function(modal) { - $scope.walletsModal = modal; - $scope.walletsModal.show(); - }); - - $scope.$on('walletSelected', function(ev, walletId) { - $timeout(function() { - wallet = profileService.getClient(walletId); - self.isMultisigWallet = false; - self.selectedWalletId = walletId; - self.selectedWalletName = wallet.credentials.walletName; - if (wallet.credentials.n > 1) - self.isMultisigWallet = true; - $scope.$apply(); - }, 100); - $scope.walletsModal.hide(); - }); }; this.sendFunds = function() { self.error = null; + if (lodash.isEmpty(wallet)) return; + if (!wallet.canSign() && !wallet.isPrivKeyExternal()) { $log.info('No signing proposal: No private key'); self.error = bwcError.msg('MISSING_PRIVATE_KEY'); @@ -297,8 +269,8 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi self.authenticating = true; bitpayCardService.authenticate(data, function(err, auth) { self.authenticating = false; - if (err && !err.data.error.twoFactorPending) { - self.error = 'Authentiation error'; + if (err && err.data && err.data.error && !err.data.error.twoFactorPending) { + self.error = err.statusText || err.data.error || 'Authentiation error'; return; } diff --git a/src/js/services/bitpayCardService.js b/src/js/services/bitpayCardService.js index fd122d36b..d01b1cf89 100644 --- a/src/js/services/bitpayCardService.js +++ b/src/js/services/bitpayCardService.js @@ -19,6 +19,11 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, }; }; + var _setError = function(msg, e) { + $log.error(msg); + return e; + }; + var _getUser = function(cb) { _setCredentials(); storageService.getBitpayCard(credentials.NETWORK, function(err, user) { @@ -53,8 +58,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, bpSession = data.data.data; return cb(null, bpSession); }, function(data) { - $log.error('BitPay Get Session: ERROR ' + data.data.error); - return cb(data.data.error); + return cb(_setError('BitPay Card Error: Get Session', data)); }); }; @@ -97,8 +101,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, $log.info('BitPay TopUp: SUCCESS'); return cb(null, data.data.data.invoice); }, function(data) { - $log.error('BitPay TopUp: ERROR ' + data.data.error); - return cb(data.data.error); + return cb(_setError('BitPay Card Error: TopUp', data)); }); }; @@ -113,8 +116,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, $log.info('BitPay Get Transaction History: SUCCESS'); return cb(null, data.data.data); }, function(data) { - $log.error('BitPay Get Transaction History: ERROR ' + data.data); - return cb(data.data); + return cb(_setError('BitPay Card Error: Get Transaction History', data)); }); }; @@ -123,8 +125,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, $log.info('BitPay Get Invoice History: SUCCESS'); return cb(null, data.data.data); }, function(data) { - $log.error('BitPay Get Invoice History: ERROR ' + data.data); - return cb(data.data); + return cb(_setError('BitPay Card Error: Get Invoice History', data)); }); }; @@ -133,8 +134,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, $log.info('BitPay Get Invoice: SUCCESS'); return cb(null, data.data.data); }, function(data) { - $log.error('BitPay Get Invoice: ERROR ' + data.data.error); - return cb(data.data.error); + return cb(_setError('BitPay Card Error: Get Invoice', data)); }); }; @@ -147,8 +147,8 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, return cb(null, session); }); }, function(data) { - $log.error('BitPay Authenticate: ERROR'); - if (data.data.error.twoFactorPending) { + if (data && data.data && data.data.error.twoFactorPending) { + $log.error('BitPay Card needs 2FA Authentication'); _getSession(function(err, session) { if (err) return cb(err); return cb(null, session); @@ -165,8 +165,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, $log.info('BitPay 2FA: SUCCESS'); return cb(null, data); }, function(data) { - $log.error('BitPay 2FA: ERROR'); - return cb(data); + return cb(_setError('BitPay Card Error: 2FA', data)); }); }; @@ -195,8 +194,7 @@ angular.module('copayApp.services').factory('bitpayCardService', function($http, $log.info('BitPay Logout: SUCCESS'); return cb(data); }, function(data) { - $log.error('BitPay Logout: ERROR ' + data.data.error); - return cb(data.data.error); + return cb(_setError('BitPay Card Error: Logout ', data)); }); }); }; diff --git a/src/sass/main.scss b/src/sass/main.scss index 4a8d52f4f..6d58130e7 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -426,6 +426,21 @@ ul.wallet-selection.wallets { } } +// POSTFIX + +.postfix { + position: absolute; + right: 10px; + background-color: #f8f8f8; + color: #444; + border-radius: 4px; + padding: 2px 10px; + cursor: pointer; + label &{ + top: 38px; + padding: 0 5px; + } +} // QR Code From 701d5d548bc3eb660d5d15264486228f77ed1986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Mon, 29 Aug 2016 17:42:19 -0300 Subject: [PATCH 11/15] refactor --- src/js/controllers/onboarding/collectEmail.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/js/controllers/onboarding/collectEmail.js b/src/js/controllers/onboarding/collectEmail.js index e92aa6cc9..ad9b3609e 100644 --- a/src/js/controllers/onboarding/collectEmail.js +++ b/src/js/controllers/onboarding/collectEmail.js @@ -2,8 +2,10 @@ angular.module('copayApp.controllers').controller('collectEmailController', function($scope, $state, $stateParams, profileService, walletService, platformInfo) { + var usePushNotifications = platformInfo.isCordova && !isWP; + $scope.skip = function() { - if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); + if (!usePushNotifications) $state.go('onboarding.backupRequest'); else $state.go('onboarding.notifications'); } @@ -15,7 +17,7 @@ angular.module('copayApp.controllers').controller('collectEmailController', func email: email, }, function(err) { if (err) $log.warn(err); - if (!platformInfo.isCordova) $state.go('onboarding.backupRequest'); + if (!usePushNotifications) $state.go('onboarding.backupRequest'); else $state.go('onboarding.notifications'); }); }; From aea0cb0428a37a34cc2c999a0a1bccb1e9b599ca Mon Sep 17 00:00:00 2001 From: Javier Date: Mon, 29 Aug 2016 16:48:15 -0300 Subject: [PATCH 12/15] refactor navigation parameters --- chrome-app/manifest.json | 4 ++-- package.json | 4 ++-- public/views/backup.html | 19 +++++++++---------- public/views/preferences.html | 13 +++++-------- public/views/preferencesAbout.html | 9 ++++----- public/views/preferencesAdvanced.html | 12 +++++------- public/views/preferencesAlias.html | 11 ++++------- public/views/preferencesAltCurrency.html | 11 ++++------- public/views/preferencesBwsUrl.html | 11 ++++------- public/views/preferencesColor.html | 11 ++++------- public/views/preferencesDeleteWallet.html | 11 ++++------- public/views/preferencesDeleteWords.html | 11 ++++------- public/views/preferencesEmail.html | 11 ++++------- public/views/preferencesFee.html | 11 ++++------- public/views/preferencesHistory.html | 13 +++++-------- public/views/preferencesInformation.html | 11 ++++------- public/views/preferencesLanguage.html | 11 ++++------- public/views/preferencesLogs.html | 11 ++++------- public/views/preferencesUnit.html | 13 +++++-------- public/views/termsOfUse.html | 12 +++++------- public/views/translators.html | 12 +++++------- src/js/controllers/backup.js | 11 ++++------- src/js/controllers/import.js | 6 +++++- src/js/controllers/preferences.js | 8 ++++---- src/js/controllers/preferencesAbout.js | 4 +++- src/js/controllers/preferencesAlias.js | 6 +++--- src/js/controllers/preferencesAltCurrency.js | 5 +++-- src/js/controllers/preferencesBwsUrl.js | 3 ++- src/js/controllers/preferencesColor.js | 6 +++--- src/js/controllers/preferencesDelete.js | 4 ++-- src/js/controllers/preferencesDeleteWords.js | 7 +++---- src/js/controllers/preferencesEmail.js | 6 +++--- src/js/controllers/preferencesFee.js | 4 +++- src/js/controllers/preferencesHistory.js | 4 ++-- src/js/controllers/preferencesInformation.js | 5 +++-- src/js/controllers/preferencesLanguage.js | 5 +++-- src/js/controllers/preferencesLogs.js | 3 ++- src/js/controllers/preferencesUnit.js | 5 +++-- src/js/controllers/termOfUse.js | 5 ++--- src/js/routes.js | 6 +++++- src/sass/main.scss | 11 +++++++++++ 41 files changed, 160 insertions(+), 186 deletions(-) diff --git a/chrome-app/manifest.json b/chrome-app/manifest.json index 7f7f2324b..e6320e72a 100644 --- a/chrome-app/manifest.json +++ b/chrome-app/manifest.json @@ -1,6 +1,6 @@ - { + { "//":"PLEASE! Do not edit this file directly", - "//":" Modify it at app-template/", + "//":" Modify it at app-template/", "manifest_version": 2, "name": "BitPay", diff --git a/package.json b/package.json index dbd5438d2..24776e4fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ - { + { "//":"PLEASE! Do not edit this file directly", - "//":" Modify it at app-template/", + "//":" Modify it at app-template/", "name": "bitpay", "description": "The BitPay Bitcoin Wallet", diff --git a/public/views/backup.html b/public/views/backup.html index 46cb5ce27..c4a41b2cf 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -1,16 +1,15 @@ - - - -   -   + + + + {{'Back' | translate}} + - +
-delete mnemonics. You can still export it. -
+ Wallet recovery phrase not available. You can still export it from Advanced > Export. +
+ diff --git a/public/views/preferences.html b/public/views/preferences.html index 6e761c24a..f1fc1d0a3 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -1,13 +1,10 @@ - - Wallet Settings - - - + + + {{'Back' | translate}} + - +
Preferences diff --git a/public/views/preferencesAbout.html b/public/views/preferencesAbout.html index 61da7a984..611538017 100644 --- a/public/views/preferencesAbout.html +++ b/public/views/preferencesAbout.html @@ -1,13 +1,12 @@ - - About Copay + - - +
Release information
diff --git a/public/views/preferencesAdvanced.html b/public/views/preferencesAdvanced.html index a0905df99..406ab13a1 100644 --- a/public/views/preferencesAdvanced.html +++ b/public/views/preferencesAdvanced.html @@ -1,11 +1,9 @@ - - Advanced Preferences - - - + + {{'Advanced Preferences' | translate}} + + {{'Back' | translate}} +
diff --git a/public/views/preferencesAlias.html b/public/views/preferencesAlias.html index 9bbf54198..68d8b4996 100644 --- a/public/views/preferencesAlias.html +++ b/public/views/preferencesAlias.html @@ -1,11 +1,8 @@ - - Alias - - - + + + {{'Back' | translate}} +
diff --git a/public/views/preferencesAltCurrency.html b/public/views/preferencesAltCurrency.html index 60c2cbfe6..47114b9c2 100644 --- a/public/views/preferencesAltCurrency.html +++ b/public/views/preferencesAltCurrency.html @@ -1,11 +1,8 @@ - - Alternative Currency - - - + + + {{'Back' | translate}} + - - Wallet Service URL - - - + + + {{'Back' | translate}} + diff --git a/public/views/preferencesColor.html b/public/views/preferencesColor.html index 2c12a4d3e..747c1b1e4 100644 --- a/public/views/preferencesColor.html +++ b/public/views/preferencesColor.html @@ -1,11 +1,8 @@ - - Color - - - + + + {{'Back' | translate}} + diff --git a/public/views/preferencesDeleteWallet.html b/public/views/preferencesDeleteWallet.html index 5a2ee8d3e..eb8192c16 100644 --- a/public/views/preferencesDeleteWallet.html +++ b/public/views/preferencesDeleteWallet.html @@ -1,11 +1,8 @@ - - Delete Wallet - - - + + + {{'Back' | translate}} +
Warning!
diff --git a/public/views/preferencesDeleteWords.html b/public/views/preferencesDeleteWords.html index d0810d09d..abdadd91c 100644 --- a/public/views/preferencesDeleteWords.html +++ b/public/views/preferencesDeleteWords.html @@ -1,11 +1,8 @@ - - Delete Recovery Phrase - - - + + + {{'Back' | translate}} +
diff --git a/public/views/preferencesEmail.html b/public/views/preferencesEmail.html index 59dd8ccf0..0cca13933 100644 --- a/public/views/preferencesEmail.html +++ b/public/views/preferencesEmail.html @@ -1,11 +1,8 @@ - - Email Notifications - - - + + + {{'Back' | translate}} + diff --git a/public/views/preferencesFee.html b/public/views/preferencesFee.html index 616f9ed7a..842adf979 100644 --- a/public/views/preferencesFee.html +++ b/public/views/preferencesFee.html @@ -1,11 +1,8 @@ - - Preferences fee - - - + + + {{'Back' | translate}} + diff --git a/public/views/preferencesHistory.html b/public/views/preferencesHistory.html index 88e7087ac..e8a732834 100644 --- a/public/views/preferencesHistory.html +++ b/public/views/preferencesHistory.html @@ -1,13 +1,10 @@ - - Transaction History - - - + + + {{'Back' | translate}} + - +
Export to file diff --git a/public/views/preferencesInformation.html b/public/views/preferencesInformation.html index 773821617..a15e4cb0a 100644 --- a/public/views/preferencesInformation.html +++ b/public/views/preferencesInformation.html @@ -1,11 +1,8 @@ - - Wallet Information - - - + + + {{'Back' | translate}} +
diff --git a/public/views/preferencesLanguage.html b/public/views/preferencesLanguage.html index 5d4565bb1..493fb9570 100644 --- a/public/views/preferencesLanguage.html +++ b/public/views/preferencesLanguage.html @@ -1,11 +1,8 @@ - - Languages - - - + + + {{'Back' | translate}} + - - Session log - - - + + + {{'Back' | translate}} + - - + + + {{'Back' | translate}} + + {{unit.shortName}} diff --git a/public/views/termsOfUse.html b/public/views/termsOfUse.html index 3995003f7..b1d40739b 100644 --- a/public/views/termsOfUse.html +++ b/public/views/termsOfUse.html @@ -1,12 +1,10 @@ - - Terms of Use - - - + + + {{'Back' | translate}} + +

diff --git a/public/views/translators.html b/public/views/translators.html index da8c182cd..84aabea3a 100644 --- a/public/views/translators.html +++ b/public/views/translators.html @@ -1,11 +1,9 @@ - - Translators - - - + + {{'Translators' | translate}} + + {{'Back' | translate}} +

Translation Credits

diff --git a/src/js/controllers/backup.js b/src/js/controllers/backup.js index ad8c3cd3e..f14000986 100644 --- a/src/js/controllers/backup.js +++ b/src/js/controllers/backup.js @@ -1,10 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('backupController', - function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, gettext, bwcService, walletService, ongoingProcess) { - + function($rootScope, $scope, $timeout, $log, $state, $stateParams, $ionicPopup, $ionicNavBarDelegate, gettextCatalog, uxLanguage, lodash, fingerprintService, platformInfo, configService, profileService, bwcService, walletService, ongoingProcess) { var wallet = profileService.getWallet($stateParams.walletId); - $scope.walletName = wallet.credentials.walletName; + $ionicNavBarDelegate.title(gettextCatalog.getString(wallet.credentials.walletName)); $scope.n = wallet.n; var keys; @@ -71,8 +70,7 @@ angular.module('copayApp.controllers').controller('backupController', if ($scope.step == 1) { if ($stateParams.fromOnboarding) $state.go('onboarding.backupRequest'); else $state.go('wallet.preferences'); - } - else { + } else { $scope.goToStep($scope.step - 1); } }; @@ -98,8 +96,7 @@ angular.module('copayApp.controllers').controller('backupController', confirmBackupPopup.close(); if ($stateParams.fromOnboarding) $state.go('onboarding.disclaimer'); else $state.go('tabs.home') - } - else { + } else { confirmBackupPopup.close(); $scope.goToStep(1); } diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 9f1f5cb61..6e4b4deab 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, $rootScope, $timeout, $log, $state, $stateParams, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) { + function($scope, $rootScope, $timeout, $log, $state, $stateParams, $ionicHistory, profileService, configService, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) { var isChromeApp = platformInfo.isChromeApp; var isDevel = platformInfo.isDevel; @@ -15,6 +15,10 @@ angular.module('copayApp.controllers').controller('importController', $scope.account = 1; $scope.importErr = false; + $scope.goBack = function() { + $ionicHistory.goBack(); + }; + var updateSeedSourceSelect = function() { $scope.seedOptions = []; diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index 92fb04344..65d95f618 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesController', - function($scope, $rootScope, $timeout, $log, $stateParams, configService, profileService, fingerprintService, walletService, $state) { - + function($scope, $rootScope, $timeout, $log, $stateParams, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, profileService, fingerprintService, walletService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Preferences')); var wallet = profileService.getWallet($stateParams.walletId); var walletId = wallet.credentials.walletId; $scope.wallet = wallet; @@ -10,8 +10,8 @@ angular.module('copayApp.controllers').controller('preferencesController', $scope.init = function() { $scope.externalSource = null; - if (!wallet) - return $state.go('tabs.home'); + if (!wallet) + return $ionicHistory.goBack(); var config = configService.getSync(); config.aliasFor = config.aliasFor || {}; diff --git a/src/js/controllers/preferencesAbout.js b/src/js/controllers/preferencesAbout.js index 9a88ccbb9..d410eec64 100644 --- a/src/js/controllers/preferencesAbout.js +++ b/src/js/controllers/preferencesAbout.js @@ -1,4 +1,6 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAbout', - function() {}); + function($ionicNavBarDelegate, gettextCatalog) { + $ionicNavBarDelegate.title(gettextCatalog.getString('About Copay')); + }); diff --git a/src/js/controllers/preferencesAlias.js b/src/js/controllers/preferencesAlias.js index f5537c9f7..41557fa80 100644 --- a/src/js/controllers/preferencesAlias.js +++ b/src/js/controllers/preferencesAlias.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAliasController', - function($scope, $timeout, $stateParams, $state, configService, profileService, walletService) { - + function($scope, $timeout, $stateParams, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, profileService, walletService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Alias')); var wallet = profileService.getWallet($stateParams.walletId); $scope.wallet = wallet; var walletId = wallet.credentials.walletId; @@ -20,7 +20,7 @@ angular.module('copayApp.controllers').controller('preferencesAliasController', configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('wallet.preferences') + $ionicHistory.goBack(); }); }; }); diff --git a/src/js/controllers/preferencesAltCurrency.js b/src/js/controllers/preferencesAltCurrency.js index 290e5187b..bd1aaf674 100644 --- a/src/js/controllers/preferencesAltCurrency.js +++ b/src/js/controllers/preferencesAltCurrency.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesAltCurrencyController', - function($scope, $log, $state, $timeout, configService, rateService, lodash, profileService, walletService) { + function($scope, $log, $timeout, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, configService, rateService, lodash, profileService, walletService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Alternative Currency')); var next = 10; var completeAlternativeList; @@ -42,8 +43,8 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('tabs.settings'); + $ionicHistory.goBack(); walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); }); diff --git a/src/js/controllers/preferencesBwsUrl.js b/src/js/controllers/preferencesBwsUrl.js index 3b39ee407..0c886148a 100644 --- a/src/js/controllers/preferencesBwsUrl.js +++ b/src/js/controllers/preferencesBwsUrl.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesBwsUrlController', - function($scope, $log, $stateParams, configService, applicationService, profileService, storageService) { + function($scope, $log, $stateParams, $ionicNavBarDelegate, configService, applicationService, profileService, storageService) { + $ionicNavBarDelegate.title('Wallet Service URL'); $scope.error = null; $scope.success = null; diff --git a/src/js/controllers/preferencesColor.js b/src/js/controllers/preferencesColor.js index a6ebe7ca8..fb9ecf737 100644 --- a/src/js/controllers/preferencesColor.js +++ b/src/js/controllers/preferencesColor.js @@ -1,7 +1,7 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesColorController', function($scope, $log, $stateParams, $state, configService, profileService) { - +angular.module('copayApp.controllers').controller('preferencesColorController', function($scope, $log, $stateParams, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, profileService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Color')); $scope.colorList = [ '#DD4B39', '#F38F12', @@ -35,7 +35,7 @@ angular.module('copayApp.controllers').controller('preferencesColorController', configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('wallet.preferences'); + $ionicHistory.goBack(); }); }; }); diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index 98ab2d080..fa0d3bca2 100644 --- a/src/js/controllers/preferencesDelete.js +++ b/src/js/controllers/preferencesDelete.js @@ -1,12 +1,12 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', - function($scope, $ionicPopup, $stateParams, lodash, profileService, $state, gettextCatalog, ongoingProcess) { + function($scope, $ionicPopup, $stateParams, $ionicNavBarDelegate, gettextCatalog, lodash, profileService, $state, ongoingProcess) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Delete Wallet')); var wallet = profileService.getWallet($stateParams.walletId); $scope.alias = lodash.isEqual(wallet.name, wallet.credentials.walletName) ? null : wallet.name + ' '; $scope.walletName = '[' + wallet.credentials.walletName + ']'; $scope.error = null; - var walletName = $scope.alias || $scope.walletName; $scope.showDeletePopup = function() { var popup = $ionicPopup.show({ diff --git a/src/js/controllers/preferencesDeleteWords.js b/src/js/controllers/preferencesDeleteWords.js index f64134302..8a5f777b3 100644 --- a/src/js/controllers/preferencesDeleteWords.js +++ b/src/js/controllers/preferencesDeleteWords.js @@ -1,7 +1,7 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $state, $stateParams, confirmDialog, lodash, notification, profileService, walletService, gettext) { - +angular.module('copayApp.controllers').controller('preferencesDeleteWordsController', function($scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, confirmDialog, lodash, profileService, walletService, gettext) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Delete recovery phrase')); var wallet = profileService.getWallet($stateParams.walletId); var msg = gettext('Are you sure you want to delete the recovery phrase?'); var successMsg = gettext('Recovery phrase deleted'); @@ -17,8 +17,7 @@ angular.module('copayApp.controllers').controller('preferencesDeleteWordsControl if (ok) { wallet.clearMnemonic(); profileService.updateCredentials(JSON.parse(wallet.export()), function() { - notification.success(successMsg); - $state.go('wallet.details'); + $ionicHistory.goBack(); }); } }); diff --git a/src/js/controllers/preferencesEmail.js b/src/js/controllers/preferencesEmail.js index 6e929e7f6..7d24ef4ec 100644 --- a/src/js/controllers/preferencesEmail.js +++ b/src/js/controllers/preferencesEmail.js @@ -1,7 +1,7 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesEmailController', function($rootScope, $scope, $state, $stateParams, profileService, walletService) { - +angular.module('copayApp.controllers').controller('preferencesEmailController', function($rootScope, $scope, $ionicHistory, $stateParams, $ionicNavBarDelegate, gettextCatalog, profileService, walletService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Email Notifications')); $scope.save = function(form) { var wallet = profileService.getWallet($stateParams.walletId); var email = $scope.email || ''; @@ -10,7 +10,7 @@ angular.module('copayApp.controllers').controller('preferencesEmailController', email: email, }, function(err) { if (err) $log.warn(err); - $state.go('wallet.preferences'); + $ionicHistory.goBack(); }); }; diff --git a/src/js/controllers/preferencesFee.js b/src/js/controllers/preferencesFee.js index b0591a6ce..e254f0411 100644 --- a/src/js/controllers/preferencesFee.js +++ b/src/js/controllers/preferencesFee.js @@ -1,6 +1,7 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, configService, feeService) { +angular.module('copayApp.controllers').controller('preferencesFeeController', function($scope, $timeout, $ionicHistory, $ionicNavBarDelegate, gettextCatalog, configService, feeService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Preferences fee')); $scope.init = function() { $scope.loading = true; @@ -25,6 +26,7 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu configService.set(opts, function(err) { if (err) $log.debug(err); $scope.currentFeeLevel = newFee.level; + $ionicHistory.goBack(); $timeout(function() { $scope.$apply(); }, 10); diff --git a/src/js/controllers/preferencesHistory.js b/src/js/controllers/preferencesHistory.js index 8ce711ea9..6ac41aea0 100644 --- a/src/js/controllers/preferencesHistory.js +++ b/src/js/controllers/preferencesHistory.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesHistory', - function($scope, $log, $stateParams, $timeout, storageService, $state, profileService, lodash) { - + function($scope, $log, $stateParams, $timeout, $ionicNavBarDelegate, gettextCatalog, storageService, $state, profileService, lodash) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Transaction History')); var wallet = profileService.getWallet($stateParams.walletId); var c = wallet.credentials; $scope.csvReady = false; diff --git a/src/js/controllers/preferencesInformation.js b/src/js/controllers/preferencesInformation.js index ac2f205bc..2848d95ce 100644 --- a/src/js/controllers/preferencesInformation.js +++ b/src/js/controllers/preferencesInformation.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesInformation', - function($scope, $log, $timeout, platformInfo, gettextCatalog, lodash, profileService, configService, $stateParams, walletService, $state) { + function($scope, $log, $timeout, $ionicNavBarDelegate, platformInfo, gettextCatalog, lodash, profileService, configService, $stateParams, walletService, $state) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Wallet Information')); var base = 'xpub'; var wallet = profileService.getWallet($stateParams.walletId); var walletId = wallet.id; @@ -12,7 +13,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation', config.colorFor = config.colorFor || {}; $scope.init = function() { - var c =wallet.credentials; + var c = wallet.credentials; var basePath = c.getBaseAddressDerivationPath(); $scope.wallet = wallet; diff --git a/src/js/controllers/preferencesLanguage.js b/src/js/controllers/preferencesLanguage.js index 1cd78702d..0406d3542 100644 --- a/src/js/controllers/preferencesLanguage.js +++ b/src/js/controllers/preferencesLanguage.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesLanguageController', - function($scope, $log, $state, configService, profileService, uxLanguage, walletService) { + function($scope, $log, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, configService, profileService, uxLanguage, walletService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Language')); $scope.init = function() { $scope.availableLanguages = uxLanguage.getLanguages(); @@ -20,7 +21,7 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('tabs.settings') + $ionicHistory.goBack(); uxLanguage.update(function() { walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); diff --git a/src/js/controllers/preferencesLogs.js b/src/js/controllers/preferencesLogs.js index 6db095b6e..153a279aa 100644 --- a/src/js/controllers/preferencesLogs.js +++ b/src/js/controllers/preferencesLogs.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesLogs', - function($scope, historicLog) { + function($scope, historicLog, $ionicNavBarDelegate, gettextCatalog) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Session Log')); $scope.init = function() { $scope.logs = historicLog.get(); diff --git a/src/js/controllers/preferencesUnit.js b/src/js/controllers/preferencesUnit.js index 5fdc78aba..3c3a2ddd9 100644 --- a/src/js/controllers/preferencesUnit.js +++ b/src/js/controllers/preferencesUnit.js @@ -1,6 +1,7 @@ 'use strict'; -angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, $state, walletService, profileService) { +angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, $ionicNavBarDelegate, $ionicHistory, gettextCatalog, walletService, profileService) { + $ionicNavBarDelegate.title(gettextCatalog.getString('Unit')); $scope.init = function() { var config = configService.getSync(); @@ -36,7 +37,7 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f configService.set(opts, function(err) { if (err) $log.warn(err); - $state.go('tabs.settings'); + $ionicHistory.goBack(); walletService.updateRemotePreferences(profileService.getWallets(), {}, function() { $log.debug('Remote preferences saved'); }); diff --git a/src/js/controllers/termOfUse.js b/src/js/controllers/termOfUse.js index 846272e40..c66f55b8c 100644 --- a/src/js/controllers/termOfUse.js +++ b/src/js/controllers/termOfUse.js @@ -1,8 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('termOfUseController', - function($scope, uxLanguage) { - + function($scope, uxLanguage, $ionicNavBarDelegate, gettextCatalog) { + $ionicNavBarDelegate.title(gettextCatalog.getString('About Copay')); $scope.lang = uxLanguage.currentLanguage; - }); diff --git a/src/js/routes.js b/src/js/routes.js index da4adaf89..44c63ff8e 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -29,6 +29,10 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr $ionicConfigProvider.navBar.positionPrimaryButtons('left'); $ionicConfigProvider.navBar.positionSecondaryButtons('right'); + // NAV BACK-BUTTON TEXT/ICON + $ionicConfigProvider.backButton.icon('ion-chevron-left'); + $ionicConfigProvider.backButton.previousTitleText(false); + $logProvider.debugEnabled(true); $provide.decorator('$log', ['$delegate', 'platformInfo', function($delegate, platformInfo) { @@ -95,7 +99,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr * */ - .state('unsupported', { + .state('unsupported', { url: '/unsupported', templateUrl: 'views/unsupported.html' }) diff --git a/src/sass/main.scss b/src/sass/main.scss index 4a8d52f4f..535db7a93 100644 --- a/src/sass/main.scss +++ b/src/sass/main.scss @@ -850,6 +850,7 @@ ul.wallet-selection.wallets { .no-border { border-style: none; + background-color: transparent !important; } input[type=file] { @@ -874,6 +875,16 @@ input[type=file] { .wallets { height: 90px; } + +.bar .button.back-button { + color: #444; + font-size: 14px; +} + +.bar .button.button-clear .icon:before { + font-size: 16px; +} + /* * Calculator */ From 0ad20fcc77763a037b76f363e70d51eb66b67f71 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Mon, 29 Aug 2016 18:54:14 -0300 Subject: [PATCH 13/15] Fix bitpayCard and buyAmazon --- public/views/modals/tx-status.html | 6 ++-- src/js/controllers/bitpayCard.js | 2 +- src/js/controllers/buyAmazon.js | 57 +++--------------------------- 3 files changed, 8 insertions(+), 57 deletions(-) diff --git a/public/views/modals/tx-status.html b/public/views/modals/tx-status.html index a5ca07ea5..950540001 100644 --- a/public/views/modals/tx-status.html +++ b/public/views/modals/tx-status.html @@ -13,7 +13,7 @@
-