From 7bdeef6ae80ec41d54bf9da028bf941fba056546 Mon Sep 17 00:00:00 2001 From: Benoit Lavenier <benoit.lavenier@e-is.pro> Date: Mon, 4 Nov 2019 15:59:26 +0100 Subject: [PATCH] [fix] Fix #845 - filter sources on complex output condition [fix] Fix #819 - avoid TX to himself --- www/i18n/locale-en-GB.json | 3 ++- www/i18n/locale-en.json | 3 ++- www/i18n/locale-es-ES.json | 3 ++- www/i18n/locale-fr-FR.json | 3 ++- www/i18n/locale-it-IT.json | 3 ++- www/js/controllers/transfer-controllers.js | 3 ++- www/js/services/wallet-services.js | 18 ++++++++++++------ www/templates/wallet/item_tx.html | 6 ++---- 8 files changed, 26 insertions(+), 16 deletions(-) diff --git a/www/i18n/locale-en-GB.json b/www/i18n/locale-en-GB.json index 6749473f..60c0deb5 100644 --- a/www/i18n/locale-en-GB.json +++ b/www/i18n/locale-en-GB.json @@ -774,7 +774,8 @@ "COULD_NOT_ADD_EXISTING_WALLET": "Wallet already existing in the list.", "UNKNOWN_WALLET_ID": "Unknown secondary wallet.", "RESTORE_WALLET_LIST_FAILED": "Unable to restore the list of wallets.", - "INVALID_FILE_FORMAT": "Invalid file format." + "INVALID_FILE_FORMAT": "Invalid file format.", + "SAME_TX_RECIPIENT": "The recipient must be different from the issuer." }, "INFO": { "POPUP_TITLE": "Information", diff --git a/www/i18n/locale-en.json b/www/i18n/locale-en.json index 378db495..725db3db 100644 --- a/www/i18n/locale-en.json +++ b/www/i18n/locale-en.json @@ -774,7 +774,8 @@ "COULD_NOT_ADD_EXISTING_WALLET": "Wallet already existing in the list.", "UNKNOWN_WALLET_ID": "Unknown secondary wallet.", "RESTORE_WALLET_LIST_FAILED": "Unable to restore the list of wallets.", - "INVALID_FILE_FORMAT": "Invalid file format." + "INVALID_FILE_FORMAT": "Invalid file format.", + "SAME_TX_RECIPIENT": "The recipient must be different from the issuer." }, "INFO": { "POPUP_TITLE": "Information", diff --git a/www/i18n/locale-es-ES.json b/www/i18n/locale-es-ES.json index b0515312..b34ee808 100644 --- a/www/i18n/locale-es-ES.json +++ b/www/i18n/locale-es-ES.json @@ -713,7 +713,8 @@ "EXISTING_ACCOUNT_REQUEST": "Por favor, cambie su frase secreta para que coincida con una cuenta sin usar.", "GET_LICENSE_FILE_FAILED": "Error al obtener el archivo de licencia", "CHECK_NETWORK_CONNECTION": "Ningún nodo parece alcanzable.<br/><br/><b>Compruebe la conexión a Internet</b>.", - "INVALID_FILE_FORMAT": "Formato de archivo inválido." + "INVALID_FILE_FORMAT": "Formato de archivo inválido.", + "SAME_TX_RECIPIENT": "El destinatario debe ser diferente del emisor." }, "INFO": { "POPUP_TITLE": "Información", diff --git a/www/i18n/locale-fr-FR.json b/www/i18n/locale-fr-FR.json index 347d3750..1ba9781b 100644 --- a/www/i18n/locale-fr-FR.json +++ b/www/i18n/locale-fr-FR.json @@ -774,7 +774,8 @@ "COULD_NOT_ADD_EXISTING_WALLET": "Portefeuille déjà existant dans la liste.", "UNKNOWN_WALLET_ID": "Portefeuille secondaire inconnu.", "RESTORE_WALLET_LIST_FAILED": "Échec de la restauration des portefeuilles secondaires.", - "INVALID_FILE_FORMAT": "Format de fichier invalide." + "INVALID_FILE_FORMAT": "Format de fichier invalide.", + "SAME_TX_RECIPIENT": "Le destinataire doit être différent de l'émetteur." }, "INFO": { "POPUP_TITLE": "Information", diff --git a/www/i18n/locale-it-IT.json b/www/i18n/locale-it-IT.json index e36fab80..4d3f3407 100644 --- a/www/i18n/locale-it-IT.json +++ b/www/i18n/locale-it-IT.json @@ -737,7 +737,8 @@ "SAVE_BEFORE_LEAVE_TITLE": "Modifiche non salvate", "LOGOUT": "Sei sicuro/a di voler chiudere la sessione?", "USE_FALLBACK_NODE": "Peer <b>{{old}}</b> indisponibile o indirizzo errato.<br/><br/>Vuoi utilizzare temporanemante il <b>{{new}}</b> nodo?", - "ISSUE_524_SEND_LOG": "La transaction a été rejettée, à cause d'une anomalie connue (ticket #524) mais <b>non reproduite</b>.<br/><br/>Pour nous aider les développeurs à corriger cette erreur, <b>acceptez-vous la transmission de vos logs</b> par message ?<br/><small>(Aucune donnée confidentielle n'est envoyée)</small>." + "INVALID_FILE_FORMAT": "Formato file non valido.", + "SAME_TX_RECIPIENT": "Il destinatario deve essere diverso dall'emittente." }, "DOWNLOAD": { "POPUP_TITLE": "<b>File di cancellazione dell'identità /b>", diff --git a/www/js/controllers/transfer-controllers.js b/www/js/controllers/transfer-controllers.js index 1be2e918..61c1d16e 100644 --- a/www/js/controllers/transfer-controllers.js +++ b/www/js/controllers/transfer-controllers.js @@ -226,6 +226,7 @@ function TransferModalController($scope, $q, $translate, $timeout, $filter, $foc }; $scope.onAmountChanged = function() { + if ($scope.sending) return; // skip if sending TX var amount = $scope.formData.amount; if (amount && typeof amount === "string") { @@ -333,12 +334,12 @@ function TransferModalController($scope, $q, $translate, $timeout, $filter, $foc } }) .then(function() { - $scope.sending = false; UIUtils.loading.hide(); return $scope.closeModal(true); }) .then(function(res) { $timeout(function() { + $scope.sending = false; UIUtils.toast.show('INFO.TRANSFER_SENT'); }, 500); return res; diff --git a/www/js/services/wallet-services.js b/www/js/services/wallet-services.js index 3c363287..646d2528 100644 --- a/www/js/services/wallet-services.js +++ b/www/js/services/wallet-services.js @@ -22,11 +22,11 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se STORAGE_DATA_PREFIX: 'data-', STORAGE_SECKEY: 'seckey', /* Need for compat with old currencies (test_net and sou) */ - TX_VERSION: csConfig.compatProtocol_0_80 ? 3 : BMA.constants.PROTOCOL_VERSION, - IDTY_VERSION: csConfig.compatProtocol_0_80 ? 2 : BMA.constants.PROTOCOL_VERSION, - MS_VERSION: csConfig.compatProtocol_0_80 ? 2 : BMA.constants.PROTOCOL_VERSION, - CERT_VERSION: csConfig.compatProtocol_0_80 ? 2 : BMA.constants.PROTOCOL_VERSION, - REVOKE_VERSION: csConfig.compatProtocol_0_80 ? 2 : BMA.constants.PROTOCOL_VERSION, + TX_VERSION: BMA.constants.PROTOCOL_VERSION, + IDTY_VERSION: BMA.constants.PROTOCOL_VERSION, + MS_VERSION: BMA.constants.PROTOCOL_VERSION, + CERT_VERSION: BMA.constants.PROTOCOL_VERSION, + REVOKE_VERSION: BMA.constants.PROTOCOL_VERSION, TX_MAX_INPUTS_COUNT: 40 // Allow to get a TX with less than 100 rows (=max row count in Duniter protocol) }, data = {}, @@ -1071,7 +1071,10 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se var minBase = filterBase; var maxBase = filterBase; _.find(data.sources || [], function(source) { - if (!source.consumed && source.base == filterBase){ + if (!source.consumed && source.base === filterBase + // Filter on simple SIG output condition - fix #845 + && BMA.regexp.TX_OUTPUT_SIG.exec(source.condition) + ) { sourcesAmount += powBase(source.amount, source.base); sources.push(source); } @@ -1123,6 +1126,9 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se if (!isLogin()){ throw {message:'ERROR.NEED_LOGIN_FIRST'}; } + if (destPub === data.pubkey){ + throw {message:'ERROR.SAME_TX_RECIPIENT'}; + } if (!amount) { throw {message:'ERROR.AMOUNT_REQUIRED'}; } diff --git a/www/templates/wallet/item_tx.html b/www/templates/wallet/item_tx.html index 2e4956ed..5959b6d7 100644 --- a/www/templates/wallet/item_tx.html +++ b/www/templates/wallet/item_tx.html @@ -8,7 +8,7 @@ <a class="" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="::tx.uid"> {{::tx.name||tx.uid}} </a> - <a class="gray" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="::!tx.uid"> + <a class="gray" ui-sref="app.wot_identity({pubkey:tx.pubkey, uid:tx.uid})" ng-if="::!tx.uid && tx.pubkey"> <i class="ion-key gray"></i> {{::tx.pubkey | formatPubkey}} <span ng-if="::tx.name"> - {{::tx.name | truncText:40}}</span> @@ -38,7 +38,6 @@ <!-- not locked TX --> <span ng-if="::!tx.lockedOutputs" class="badge item-note" ng-class="{'badge-calm': tx.amount > 0}"> - <!--<span class="hidden-xs" ng-if=":rebind:tx.amount>0">+</span>--> <span ng-bind-html=":rebind:tx.amount| formatAmount:{currency:$root.currency.name}"></span> </span> @@ -47,8 +46,7 @@ class="badge item-note" ng-class="{'badge-calm': tx.amount > 0}" ng-click="showLockedOutputsPopover(tx, $event)"> - <i class="icon ion-locked" ></i> - <!--<span class="hidden-xs" ng-if=":rebind:tx.amount>0">+</span>--> + <b class="ion-locked" ></b> <span ng-bind-html=":rebind:tx.amount| formatAmount:{currency:$root.currency.name}"></span> </a> -- GitLab