Skip to content

Commit 1a468d1

Browse files
committed
[fix] add a confirmation popup to allow TX log transmission, when issue #524 occur
1 parent 20f46c5 commit 1a468d1

File tree

9 files changed

+110
-21
lines changed

9 files changed

+110
-21
lines changed

app/config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"port": "443"
3636
}
3737
],
38+
"developers": [
39+
{"name": "Benoit Lavenier", "pubkey": "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE"}
40+
],
3841
"plugins":{
3942
"es": {
4043
"enable": true,

www/i18n/locale-en-GB.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@
8686
"MENU": {
8787
"HOME": "Home",
8888
"WOT": "Registry",
89-
"MARKET": "Market place",
9089
"CURRENCY": "Currency",
91-
"CURRENCIES": "Currencies",
9290
"ACCOUNT": "My Account",
9391
"TRANSFER": "Transfer",
9492
"SCAN": "Scan",
@@ -402,7 +400,7 @@
402400
"USER": "Personal value",
403401
"N": "N (Loop):",
404402
"r": "r (RAM):",
405-
"p": "p (CPU):",
403+
"p": "p (CPU):"
406404
},
407405
"FILE": {
408406
"DATE" : "Date:",
@@ -649,7 +647,8 @@
649647
"EXISTING_ACCOUNT": "Your identifiers correspond to an already existing account, whose <a ng-click=\"showHelpModal('pubkey')\">public key</a> is:",
650648
"EXISTING_ACCOUNT_REQUEST": "Please modify your credentials so that they correspond to an unused account.",
651649
"GET_LICENSE_FILE_FAILED": "Unable to get license file",
652-
"CHECK_NETWORK_CONNECTION": "No peer appears to be accessible.<br/><br/>Please <b>check your Internet connection</b>."
650+
"CHECK_NETWORK_CONNECTION": "No peer appears to be accessible.<br/><br/>Please <b>check your Internet connection</b>.",
651+
"ISSUE_524_TX_FAILED": "Failed to transfer.<br/><br/>A message has been sent to developers to help solve the problem.<b>Thank you for your help</b>."
653652
},
654653
"INFO": {
655654
"POPUP_TITLE": "Information",
@@ -685,7 +684,8 @@
685684
"SAVE_BEFORE_LEAVE": "Do you want to <b>save your changes</b> before leaving the page?",
686685
"SAVE_BEFORE_LEAVE_TITLE": "Changes not saved",
687686
"LOGOUT": "Are you sure you want to logout?",
688-
"USE_FALLBACK_NODE": "Peer <b>{{old}}</b> unreachable or invalid address.<br/><br/>Do you want to temporarily use the <b>{{new}}</b> node?"
687+
"USE_FALLBACK_NODE": "Peer <b>{{old}}</b> unreachable or invalid address.<br/><br/>Do you want to temporarily use the <b>{{new}}</b> node?",
688+
"ISSUE_524_SEND_LOG": "The transaction was rejected because of a known problem (issue #524) but not reproduced.<br/><br/>To help developers correct this error, do you accept <b>the transmission of your logs</b> per message?<br/><small>(No confidential data is sent)</small>"
689689
},
690690
"DOWNLOAD": {
691691
"POPUP_TITLE": "<b>Revocation file</b>",

www/i18n/locale-en.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@
8686
"MENU": {
8787
"HOME": "Home",
8888
"WOT": "Registry",
89-
"MARKET": "Market place",
9089
"CURRENCY": "Currency",
91-
"CURRENCIES": "Currencies",
9290
"ACCOUNT": "My Account",
9391
"TRANSFER": "Transfer",
9492
"SCAN": "Scan",
@@ -402,7 +400,7 @@
402400
"USER": "Personal value",
403401
"N": "N (Loop):",
404402
"r": "r (RAM):",
405-
"p": "p (CPU):",
403+
"p": "p (CPU):"
406404
},
407405
"FILE": {
408406
"DATE" : "Date:",
@@ -649,7 +647,8 @@
649647
"EXISTING_ACCOUNT": "Your identifiers correspond to an already existing account, whose <a ng-click=\"showHelpModal('pubkey')\">public key</a> is:",
650648
"EXISTING_ACCOUNT_REQUEST": "Please modify your credentials so that they correspond to an unused account.",
651649
"GET_LICENSE_FILE_FAILED": "Unable to get license file",
652-
"CHECK_NETWORK_CONNECTION": "No peer appears to be accessible.<br/><br/>Please <b>check your Internet connection</b>."
650+
"CHECK_NETWORK_CONNECTION": "No peer appears to be accessible.<br/><br/>Please <b>check your Internet connection</b>.",
651+
"ISSUE_524_TX_FAILED": "Failed to transfer.<br/><br/>A message has been sent to developers to help solve the problem.<b>Thank you for your help</b>."
653652
},
654653
"INFO": {
655654
"POPUP_TITLE": "Information",
@@ -685,7 +684,8 @@
685684
"SAVE_BEFORE_LEAVE": "Do you want to <b>save your changes</b> before leaving the page?",
686685
"SAVE_BEFORE_LEAVE_TITLE": "Changes not saved",
687686
"LOGOUT": "Are you sure you want to logout?",
688-
"USE_FALLBACK_NODE": "Peer <b>{{old}}</b> unreachable or invalid address.<br/><br/>Do you want to temporarily use the <b>{{new}}</b> node?"
687+
"USE_FALLBACK_NODE": "Peer <b>{{old}}</b> unreachable or invalid address.<br/><br/>Do you want to temporarily use the <b>{{new}}</b> node?",
688+
"ISSUE_524_SEND_LOG": "The transaction was rejected because of a known problem (issue #524) but not reproduced.<br/><br/>To help developers correct this error, do you accept <b>the transmission of your logs</b> per message?<br/><small>(No confidential data is sent)</small>"
689689
},
690690
"DOWNLOAD": {
691691
"POPUP_TITLE": "<b>Revocation file</b>",

www/i18n/locale-fr-FR.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@
400400
"USER": "Sallage personnalisé",
401401
"N": "N (Loop):",
402402
"r": "r (RAM):",
403-
"p": "p (CPU):",
403+
"p": "p (CPU):"
404404
},
405405
"FILE": {
406406
"DATE" : "Date :",
@@ -647,7 +647,8 @@
647647
"EXISTING_ACCOUNT": "Vos identifiants correspondent à un compte déjà existant, dont la <a ng-click=\"showHelpModal('pubkey')\">clef publique</a> est :",
648648
"EXISTING_ACCOUNT_REQUEST": "Veuillez modifier vos identifiants afin qu'ils correspondent à un compte non utilisé.",
649649
"GET_LICENSE_FILE_FAILED": "Récupérer du fichier de licence impossible",
650-
"CHECK_NETWORK_CONNECTION": "Aucun nœud ne semble accessible.<br/><br/>Veuillez <b>vérifier votre connection Internet</b>."
650+
"CHECK_NETWORK_CONNECTION": "Aucun nœud ne semble accessible.<br/><br/>Veuillez <b>vérifier votre connection Internet</b>.",
651+
"ISSUE_524_TX_FAILED": "Echec du virement.<br/><br/>Un message a été envoyé aux développeurs pour faciliter la résolution du problème. <b>Merci de votre aide</b>."
651652
},
652653
"INFO": {
653654
"POPUP_TITLE": "Information",
@@ -683,7 +684,8 @@
683684
"SAVE_BEFORE_LEAVE": "Voulez-vous <b>sauvegarder vos modifications</b> avant de quitter la page ?",
684685
"SAVE_BEFORE_LEAVE_TITLE": "Modifications non enregistrées",
685686
"LOGOUT": "Etes-vous de vouloir vous déconnecter ?",
686-
"USE_FALLBACK_NODE": "Nœud <b>{{old}}</b> injoignable ou adresse invalide.<br/><br/>Voulez-vous temporairement utiliser le nœud <b>{{new}}</b> ?"
687+
"USE_FALLBACK_NODE": "Nœud <b>{{old}}</b> injoignable ou adresse invalide.<br/><br/>Voulez-vous temporairement utiliser le nœud <b>{{new}}</b> ?",
688+
"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>."
687689
},
688690
"DOWNLOAD": {
689691
"POPUP_TITLE": "<b>Fichier de révocation</b>",

www/js/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ angular.module("cesium.config", [])
4444
"port": "443"
4545
}
4646
],
47+
"developers": [
48+
{
49+
"name": "Benoit Lavenier",
50+
"pubkey": "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE"
51+
}
52+
],
4753
"plugins": {
4854
"es": {
4955
"enable": true,
@@ -60,7 +66,7 @@ angular.module("cesium.config", [])
6066
}
6167
},
6268
"version": "0.15.5",
63-
"build": "2017-08-08T15:24:29.307Z",
69+
"build": "2017-08-09T10:46:18.654Z",
6470
"newIssueUrl": "https://github.com/duniter/cesium/issues/new?labels=bug"
6571
})
6672

www/js/services/bma-services.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ angular.module('cesium.bma.services', ['ngApi', 'cesium.http.services', 'cesium.
4343
MEMBERSHIP_ALREADY_SEND: 2007,
4444
NO_CURRENT_BLOCK: 2010,
4545
BLOCK_NOT_FOUND: 2011,
46+
TX_INPUTS_OUTPUTS_NOT_EQUAL: 2024,
47+
TX_OUTPUT_SUM_NOT_EQUALS_PREV_DELTAS: 2025,
4648
TX_ALREADY_PROCESSED: 2030
4749
},
4850
constants = {

www/js/services/utils-services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ angular.module('cesium.utils.services', [])
108108
cancelText: translations[options.cancelText],
109109
cancelType: options.cancelType,
110110
okText: translations[options.okText],
111-
okType: options.okType,
111+
okType: options.okType
112112
});
113113
});
114114
}

www/js/services/wallet-services.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,9 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
841841
sources : []
842842
};
843843

844+
var logs = [];
845+
logs.push("[wallet] amount=" + amount);
846+
844847
// Get inputs, starting to use current base sources
845848
var amountBase = 0;
846849
while (inputs.amount < amount && amountBase <= block.unitbase) {
@@ -851,6 +854,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
851854
amountBase++;
852855
if (amountBase <= block.unitbase) {
853856
amount = truncBase(amount, amountBase);
857+
logs.push("[wallet] inputs not found. Retrying with amount =" + amount + " be compatible with amountBase=" + amountBase);
854858
}
855859
}
856860
}
@@ -891,13 +895,15 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
891895
if (amountBase < inputs.minBase && !isBase(amount, inputs.minBase)) {
892896
amount = truncBaseOrMinBase(amount, inputs.minBase);
893897
console.debug("[wallet] Amount has been truncate to " + amount);
898+
logs.push("[wallet] Amount has been truncate to " + amount);
894899
}
895900
else if (amountBase > 0) {
896901
console.debug("[wallet] Amount has been truncate to " + amount);
902+
logs.push("[wallet] Will use amount truncated to " + amount + " (amountBase="+amountBase+")");
897903
}
898904

899905
// Send tx
900-
return createAndSendTx(currency, block, keypair, destPub, amount, inputs, comments)
906+
return createAndSendTx(currency, block, keypair, destPub, amount, inputs, comments, logs)
901907
.then(function(res) {
902908
data.balance -= amount;
903909
_.forEach(inputs.sources, function(source) {
@@ -928,6 +934,35 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
928934
api.data.raise.balanceChanged(data);
929935
api.data.raise.newTx(data);
930936
});
937+
})
938+
.catch(function(err) {
939+
if (err && err.ucode === BMA.errorCodes.TX_INPUTS_OUTPUTS_NOT_EQUAL) {
940+
// Send log message for debugging - issue #524 - https://github.com/duniter/cesium/issues/524
941+
var esEnable = csSettings.data.plugins && csSettings.data.plugins.es && csSettings.data.plugins.es.enable;
942+
if (esEnable) {
943+
UIUtils.loading.hide();
944+
return UIUtils.alert.confirm('CONFIRM.ISSUE_524_SEND_LOG', 'ERROR.POPUP_TITLE', {
945+
cssClass: 'warning',
946+
okText: 'COMMON.BTN_OK',
947+
cancelText: 'COMMON.BTN_NO'
948+
})
949+
.then(function(confirm) {
950+
if (confirm) {
951+
api.error.raise.send({
952+
title: 'Issue #524 logs',
953+
content: 'App version: ' +csConfig.version+'\n'+
954+
'App build: ' +csConfig.build+'\n'+
955+
'Logs:\n\n' + logs.join('\n')
956+
});
957+
return $timeout(function() {
958+
throw {message: 'ERROR.ISSUE_524_TX_FAILED'};
959+
}, 1500);
960+
}
961+
throw {message: 'ERROR.SEND_TX_FAILED'};
962+
});
963+
}
964+
}
965+
throw err;
931966
});
932967
});
933968
},
@@ -941,7 +976,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
941976
* @param comments
942977
* @return the hash of the sent TX
943978
*/
944-
createAndSendTx = function(currency, block, keypair, destPub, amount, inputs, comments) {
979+
createAndSendTx = function(currency, block, keypair, destPub, amount, inputs, comments, logs) {
945980

946981
// Make sure a TX in compact mode has no more than 100 lines (fix #118)
947982
// (If more than 100 lines, send to TX to himself first, then its result as sources for the final TX)
@@ -962,7 +997,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
962997
});
963998

964999
// Send inputs first slice
965-
return createAndSendTx(currency, block, keypair, data.pubkey/*to himself*/, firstSlice.amount, firstSlice) // comment not need
1000+
return createAndSendTx(currency, block, keypair, data.pubkey/*to himself*/, firstSlice.amount, firstSlice, undefined/*comment not need*/, logs)
9661001
.then(function(res) {
9671002
_.forEach(firstSlice.sources, function(source) {
9681003
source.consumed=true;
@@ -982,7 +1017,7 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
9821017
});
9831018

9841019
// Send inputs second slice (recursive call)
985-
return createAndSendTx(currency, block, keypair, destPub, amount, secondSlice, comments);
1020+
return createAndSendTx(currency, block, keypair, destPub, amount, secondSlice, comments, logs);
9861021
});
9871022
}
9881023

@@ -1049,6 +1084,20 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
10491084

10501085
tx += "Comment: "+ (comments||"") + "\n";
10511086

1087+
// Append to logs (need to resolve issue #524)
1088+
if (logs) {
1089+
if (destPub == data.pubkey) {
1090+
logs.push('[wallet] Creating new TX, using inputs:\n - minBase: '+inputs.minBase+'\n - maxBase: '+inputs.maxBase);
1091+
}
1092+
else {
1093+
logs.push('[wallet] Creating new TX, using inputs:\n - minBase: '+inputs.minBase+'\n - maxBase: '+inputs.maxBase + '\n - sources (=TX inputs):');
1094+
}
1095+
_.forEach(inputs.sources, function(source) {
1096+
logs.push([source.amount, source.base, source.type, source.identifier,source.noffset].join(':'));
1097+
});
1098+
logs.push("\n[wallet] generated TX document (without signature) :\n------ START ------\n" + tx + "------ END ------\n");
1099+
}
1100+
10521101
return CryptoUtils.sign(tx, keypair)
10531102
.then(function(signature) {
10541103
var signedTx = tx + signature + "\n";
@@ -1632,6 +1681,8 @@ angular.module('cesium.wallet.services', ['ngApi', 'ngFileSaver', 'cesium.bma.se
16321681
api.registerEvent('data', 'logout');
16331682
api.registerEvent('data', 'reset');
16341683

1684+
api.registerEvent('error', 'send');
1685+
16351686
// Data changed : balance changed, new TX
16361687
api.registerEvent('data', 'balanceChanged');
16371688
api.registerEvent('data', 'newTx');

www/plugins/es/js/services/message-services.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform',
1111

1212
})
1313

14-
.factory('esMessage', function($q, $rootScope, Api, CryptoUtils, csPlatform, csSettings, esHttp, csWallet, esWallet, csWot, esNotification) {
14+
.factory('esMessage', function($q, $rootScope, $timeout, UIUtils, Api, CryptoUtils,
15+
csPlatform, csConfig, csSettings, esHttp, csWallet, esWallet, csWot, esNotification) {
1516
'ngInject';
1617

1718
var
@@ -444,6 +445,28 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform',
444445
});
445446
}
446447

448+
// Send message to developers - need for issue #524
449+
function onSendError(message) {
450+
var developers = csConfig.developers || [{pubkey: '38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE'/*kimamila*/}];
451+
if(!message || !message.content || !developers || !developers.length) return;
452+
453+
console.info("[ES] [message] Sending logs to developers...");
454+
message.issuer = csWallet.data.pubkey;
455+
message.title = message.title || 'Sending log';
456+
message.time = esHttp.date.now();
457+
458+
csWallet.getKeypair()
459+
.then(function(keypair) {
460+
return $q.all(developers.reduce(function(res, developer){
461+
return !developer.pubkey ? res :
462+
res.concat(sendMessage(angular.merge({recipient: developer.pubkey}, message), keypair));
463+
}, []));
464+
})
465+
.then(function(res) {
466+
console.info("[ES] [message] Logs sent to {0} developers".format(res.length));
467+
});
468+
}
469+
447470
function removeListeners() {
448471
_.forEach(listeners, function(remove){
449472
remove();
@@ -457,7 +480,9 @@ angular.module('cesium.es.message.services', ['ngResource', 'cesium.platform',
457480
csWallet.api.data.on.login($rootScope, onWalletLogin, this),
458481
csWallet.api.data.on.init($rootScope, onWalletInit, this),
459482
csWallet.api.data.on.reset($rootScope, onWalletReset, this),
460-
esNotification.api.event.on.newMessage($rootScope, onNewMessageEvent, this)
483+
esNotification.api.event.on.newMessage($rootScope, onNewMessageEvent, this),
484+
// for issue #524
485+
csWallet.api.error.on.send($rootScope, onSendError, this)
461486
];
462487
}
463488

0 commit comments

Comments
 (0)