From f537db469eec9b6f72d529a5654d5ac0fba338a5 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sat, 17 May 2014 13:45:23 -0300 Subject: [PATCH] fixes rounding errors in fees and valueout --- insight.js | 0 lib/Rpc.js | 4 ++-- lib/TransactionDb.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 insight.js diff --git a/insight.js b/insight.js old mode 100644 new mode 100755 diff --git a/lib/Rpc.js b/lib/Rpc.js index 9f78c8d..3d8f3e0 100644 --- a/lib/Rpc.js +++ b/lib/Rpc.js @@ -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; diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index bbc5622..b063011 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -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; }