Skip to content

Commit

Permalink
Merge pull request #80 from matiu/bug/rounding-errors
Browse files Browse the repository at this point in the history
fixes rounding errors in fees and valueout
  • Loading branch information
matiu committed May 17, 2014
2 parents 667c605 + f537db4 commit 8da8724
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Empty file modified insight.js
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions lib/Rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ Rpc._parseTxResult = function(info) {
var valueOutSat = 0;
info.vout.forEach( function(o) {
o.value = o.value.toFixed(8);
valueOutSat += o.value * bitcore.util.COIN;
valueOutSat += (o.value * bitcore.util.COIN).toFixed(0);
delete o.scriptPubKey.hex;
});
info.valueOut = parseInt(valueOutSat) / bitcore.util.COIN;
info.valueOut = valueOutSat / bitcore.util.COIN;
info.size = b.length;

return info;
Expand Down
2 changes: 1 addition & 1 deletion lib/TransactionDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ isspent
function() {
if (!incompleteInputs) {
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 {
info.incompleteInputs = 1;
}
Expand Down

0 comments on commit 8da8724

Please sign in to comment.