Commit 7bdeef6a authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Fix #845 - filter sources on complex output condition

[fix] Fix #819 - avoid TX to himself
parent a62ba99a
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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",
......
......@@ -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>",
......
......@@ -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;
......
......@@ -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'};
}
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment