Merge pull request #80 from matiu/bug/rounding-errors
fixes rounding errors in fees and valueout
This commit is contained in:
commit
8da8724e9a
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue