fixes rounding errors in fees and valueout

This commit is contained in:
Matias Alejo Garcia 2014-05-17 13:45:23 -03:00
parent 00b2abd2ac
commit f537db469e
3 changed files with 3 additions and 3 deletions

0
insight.js Normal file → Executable file
View File

View File

@ -31,10 +31,10 @@ Rpc._parseTxResult = function(info) {
var valueOutSat = 0; var valueOutSat = 0;
info.vout.forEach( function(o) { info.vout.forEach( function(o) {
o.value = o.value.toFixed(8); o.value = o.value.toFixed(8);
valueOutSat += o.value * bitcore.util.COIN; valueOutSat += (o.value * bitcore.util.COIN).toFixed(0);
delete o.scriptPubKey.hex; delete o.scriptPubKey.hex;
}); });
info.valueOut = parseInt(valueOutSat) / bitcore.util.COIN; info.valueOut = valueOutSat / bitcore.util.COIN;
info.size = b.length; info.size = b.length;
return info; return info;

View File

@ -241,7 +241,7 @@ isspent
function() { function() {
if (!incompleteInputs) { if (!incompleteInputs) {
info.valueIn = valueIn / util.COIN; info.valueIn = valueIn / util.COIN;
info.fees = (valueIn - parseInt(info.valueOut * util.COIN)) / util.COIN; info.fees = (valueIn - (info.valueOut * util.COIN)).toFixed(0) / util.COIN;
} else { } else {
info.incompleteInputs = 1; info.incompleteInputs = 1;
} }