diff --git a/bower.json b/bower.json index 572438ec3..93266daf7 100644 --- a/bower.json +++ b/bower.json @@ -17,7 +17,7 @@ "ng-lodash": "~0.2.0", "angular-moment": "~0.10.1", "moment": "~2.10.3", - "angular-bitcore-wallet-client": "^0.0.28", + "angular-bitcore-wallet-client": "^0.1.1", "angular-ui-router": "~0.2.13", "qrcode-decoder-js": "*", "fastclick": "*", diff --git a/i18n/po/template.pot b/i18n/po/template.pot index 7c4e1ecaa..9b384c51c 100644 --- a/i18n/po/template.pot +++ b/i18n/po/template.pot @@ -468,6 +468,10 @@ msgstr "" msgid "Fee Policy" msgstr "" +#: public/views/walletHome.html +msgid "Fee policy for this transaction" +msgstr "" + #. Get information of payment if using Payment Protocol #: src/js/controllers/walletHome.js msgid "Fetching Payment Information" @@ -524,7 +528,8 @@ msgstr "" #: public/views/backup.html #: public/views/create.html #: public/views/join.html -msgid "Hide Advanced options" +#: public/views/walletHome.html +msgid "Hide advanced options" msgstr "" #: src/js/controllers/index.js @@ -689,6 +694,7 @@ msgstr "" #: public/views/walletHome.html #: public/views/includes/output.html +#: public/views/modals/tx-details.html msgid "Note" msgstr "" @@ -1012,7 +1018,8 @@ msgstr "" #: public/views/backup.html #: public/views/create.html #: public/views/join.html -msgid "Show Advanced options" +#: public/views/walletHome.html +msgid "Show advanced options" msgstr "" #: src/js/controllers/walletHome.js @@ -1148,6 +1155,15 @@ msgstr "" msgid "Updating Wallet..." msgstr "" +#: public/views/preferences.html +#: public/views/walletHome.html +msgid "Use Unconfirmed Funds" +msgstr "" + +#: public/views/modals/txp-details.html +msgid "Uses unconfirmed funds" +msgstr "" + #: public/views/preferencesAbout.html msgid "Version" msgstr "" diff --git a/public/views/backup.html b/public/views/backup.html index d3cb3387b..f0f0d7a22 100644 --- a/public/views/backup.html +++ b/public/views/backup.html @@ -38,8 +38,8 @@
- Show Advanced options - Hide Advanced options + Show advanced options + Hide advanced options diff --git a/public/views/create.html b/public/views/create.html index d721f7b13..83f02975d 100644 --- a/public/views/create.html +++ b/public/views/create.html @@ -81,8 +81,8 @@
- Show Advanced options - Hide Advanced options + Show advanced options + Hide advanced options diff --git a/public/views/includes/output.html b/public/views/includes/output.html index d217412b2..2fb157df1 100644 --- a/public/views/includes/output.html +++ b/public/views/includes/output.html @@ -1,4 +1,4 @@ -
+
  • Recipients: {{output.recipientCount}} diff --git a/public/views/join.html b/public/views/join.html index c18aed109..7c4a19f8a 100644 --- a/public/views/join.html +++ b/public/views/join.html @@ -66,8 +66,8 @@ - Show Advanced options - Hide Advanced options + Show advanced options + Hide advanced options diff --git a/public/views/modals/txp-details.html b/public/views/modals/txp-details.html index 783668dae..6460111a2 100644 --- a/public/views/modals/txp-details.html +++ b/public/views/modals/txp-details.html @@ -30,6 +30,10 @@ Fee: {{feeStr}}
  • +
  • + Uses unconfirmed funds: + {{(tx.excludeUnconfirmedUtxos ? 'No' : 'Yes')|translate}} +
  • Time: diff --git a/public/views/preferences.html b/public/views/preferences.html index c5f31797e..3f1e1d0cf 100644 --- a/public/views/preferences.html +++ b/public/views/preferences.html @@ -77,13 +77,18 @@ {{preferences.selectedAlternative.name}}
  • -
  • +
  • Bitcoin Network Fee Policy - {{index.feeOpts[index.currentFeeLevel]|translate}} + {{index.feeOpts[index.currentFeeLevel]|translate}}
  • +
  • + Use Unconfirmed Funds + +
  • Bitcore Wallet Service diff --git a/public/views/preferencesFee.html b/public/views/preferencesFee.html index 425164145..7eb64566d 100644 --- a/public/views/preferencesFee.html +++ b/public/views/preferencesFee.html @@ -7,7 +7,7 @@
    • - {{index.feeOpts[fee.level]|translate}} + {{index.feeOpts[fee.level]|translate}}
    diff --git a/public/views/walletHome.html b/public/views/walletHome.html index 69df80a74..a9353d02c 100644 --- a/public/views/walletHome.html +++ b/public/views/walletHome.html @@ -418,6 +418,35 @@
  • +
    + + + Show advanced options + Hide advanced options + + + +
    +
    +

    Fee policy for this transaction

    +
      +
    • + {{index.feeOpts[fee.level]|translate}} + +
    • +
    +
    +

     

    +
    + Use Unconfirmed Funds + +
    +
    +
    + +
    Cancel diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index 775acfcdc..e8a820836 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService) { +angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp) { var self = this; self.isCordova = isCordova; self.onGoingProcess = {}; @@ -279,6 +279,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r $log.debug('Wallet Status:', walletStatus); self.setPendingTxps(walletStatus.pendingTxps); self.setFees(); + self.setSpendUnconfirmed(); // Status Shortcuts self.walletName = walletStatus.wallet.name; @@ -306,6 +307,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); }; + self.setSpendUnconfirmed = function() { + self.spendUnconfirmed = configService.getSync().wallet.spendUnconfirmed; + }; + self.setCurrentFeeLevel = function(level) { self.currentFeeLevel = level || configService.getSync().wallet.settings.feeLevel || 'priority'; }; @@ -395,9 +400,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.handleError = function(err) { $log.warn('Client ERROR:', err); - if (err.code === 'NOTAUTHORIZED') { + if (err.code === 'NOT_AUTHORIZED') { $scope.$emit('Local/NotAuthorized'); - } else if (err.code === 'NOTFOUND') { + } else if (err.code === 'NOT_FOUND') { $scope.$emit('Local/BWSNotFound'); } else { $scope.$emit('Local/ClientError', (err.error ? err.error : err)); @@ -747,7 +752,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r 'Wallet Server Error', ['OK'] ); } else { - alert(err); + if (!isChromeApp) { + alert(err); + } } }; @@ -759,7 +766,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r 'Device Error', ['OK'] ); } else { - alert(err); + if (!isChromeApp) { + alert(err); + } } }; @@ -855,6 +864,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); }); + $rootScope.$on('Local/SpendUnconfirmedUpdated', function(event) { + self.setSpendUnconfirmed(); + }); + $rootScope.$on('Local/FeeLevelUpdated', function(event, level) { self.setCurrentFeeLevel(level); }); @@ -951,12 +964,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r }); $rootScope.$on('Local/ClientError', function(event, err) { - if (err.code && err.code === 'NOTAUTHORIZED') { + if (err.code && err.code === 'NOT_AUTHORIZED') { // Show not error, just redirect to home (where the recreate option is shown) go.walletHome(); } else if (err && err.cors == 'rejected') { $log.debug('CORS error:', err); - } else if (err.code === 'ETIMEDOUT' || err.code === 'CONNERROR') { + } else if (err.code === 'ETIMEDOUT' || err.code === 'CONNECTION_ERROR') { $log.debug('Time out:', err); } else { var msg = 'Error at Wallet Service: '; diff --git a/src/js/controllers/preferences.js b/src/js/controllers/preferences.js index 742db5a84..c562785bb 100644 --- a/src/js/controllers/preferences.js +++ b/src/js/controllers/preferences.js @@ -9,10 +9,25 @@ angular.module('copayApp.controllers').controller('preferencesController', name: config.wallet.settings.alternativeName, isoCode: config.wallet.settings.alternativeIsoCode }; + $scope.spendUnconfirmed = config.wallet.spendUnconfirmed; var fc = profileService.focusedClient; if (fc) $scope.encrypt = fc.hasPrivKeyEncrypted(); + var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) { + if (newVal == oldVal) return; + var opts = { + wallet: { + spendUnconfirmed: newVal + } + }; + $rootScope.$emit('Local/SpendUnconfirmedUpdated'); + + configService.set(opts, function(err) { + if (err) $log.debug(err); + }); + }); + var unwatch = $scope.$watch('encrypt', function(val) { var fc = profileService.focusedClient; if (!fc) return; @@ -49,5 +64,6 @@ angular.module('copayApp.controllers').controller('preferencesController', $scope.$on('$destroy', function() { unwatch(); + unwatchSpendUnconfirmed(); }); }); diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index efa6e28f7..ec96ba394 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -5,6 +5,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi var self = this; $rootScope.hideMenuBar = false; $rootScope.wpInputFocused = false; + $scope.currentSpendUnconfirmed = configService.getSync().wallet.spendUnconfirmed; // INIT var config = configService.getSync().wallet.settings; @@ -538,6 +539,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi // Send + var unwatchSpendUnconfirmed = $scope.$watch('currentSpendUnconfirmed', function(newVal, oldVal) { + if (newVal == oldVal) return; + $scope.currentSpendUnconfirmed = newVal; + }); + + $scope.$on('$destroy', function() { + unwatchSpendUnconfirmed(); + }); + this.canShowAlternative = function() { return $scope.showAlternative; }; @@ -736,7 +746,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi address = form.address.$modelValue; amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0)); - feeService.getCurrentFeeValue(function(err, feePerKb) { + feeService.getCurrentFeeValue(self.currentSendFeeLevel, function(err, feePerKb) { if (err) $log.debug(err); fc.sendTxProposal({ toAddress: address, @@ -744,6 +754,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi message: comment, payProUrl: paypro ? paypro.url : null, feePerKb: feePerKb, + excludeUnconfirmedUtxos: $scope.currentSpendUnconfirmed ? false : true }, function(err, txp) { if (err) { self.setOngoingProcess(); @@ -848,6 +859,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi this.lockAddress = false; this.lockAmount = false; + this.currentSendFeeLevel = null; + this.hideAdvSend = true; + $scope.currentSpendUnconfirmed = configService.getSync().wallet.spendUnconfirmed; this._amount = this._address = null; @@ -985,36 +999,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi } }; - // Advanced SEND: set temporary fee policy for each transaction - this.openAdvancedSendModal = function(feeLevels, currentFeeLevel) { - var fc = profileService.focusedClient; - - var ModalInstanceCtrl = function($scope, $modalInstance) { - $scope.feeLevels = feeLevels; - $scope.currentFeeLevel = currentFeeLevel - $scope.network = fc.credentials.network; - $scope.color = fc.backgroundColor; - $scope.save = function(level) { - $scope.currentFeeLevel = level; - }; - - $scope.cancel = function() { - $modalInstance.dismiss('cancel'); - }; - }; - var modalInstance = $modal.open({ - templateUrl: 'views/modals/advancedSend.html', - windowClass: 'full animated slideInUp', - controller: ModalInstanceCtrl - }); - - modalInstance.result.finally(function() { - var m = angular.element(document.getElementsByClassName('reveal-modal')); - m.addClass('slideOutDown'); - }); - }; - - // History function strip(number) { diff --git a/src/js/services/feeService.js b/src/js/services/feeService.js index 99dde9bff..3b7f810ce 100644 --- a/src/js/services/feeService.js +++ b/src/js/services/feeService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('feeService', function($log, profileService, configService, gettextCatalog) { +angular.module('copayApp.services').factory('feeService', function($log, profileService, configService, gettextCatalog, lodash) { var root = {}; // Constant fee options to translate @@ -10,10 +10,10 @@ angular.module('copayApp.services').factory('feeService', function($log, profile economy: gettextCatalog.getString('Economy') }; - root.getCurrentFeeValue = function(cb) { + root.getCurrentFeeValue = function(currentSendFeeLevel, cb) { var fc = profileService.focusedClient; var config = configService.getSync().wallet.settings; - var feeLevel = config.feeLevel || 'normal'; + var feeLevel = currentSendFeeLevel || config.feeLevel || 'normal'; // static fee var fee = 10000; fc.getFeeLevels(fc.credentials.network, function(err, levels) { @@ -21,11 +21,7 @@ angular.module('copayApp.services').factory('feeService', function($log, profile return cb({message: 'Could not get dynamic fee. Using static 10000sat'}, fee); } else { - for (var i = 0; i < 3; i++) { - if (levels[i].level == feeLevel) { - fee = levels[i].feePerKB; - } - } + fee = lodash.find(levels, { level: feeLevel }).feePerKB; $log.debug('Dynamic fee for ' + feeLevel + ': ' + fee); return cb(null, fee); }