Skip to content

Commit

Permalink
history parser fix imprecise kmd rewards calc
Browse files Browse the repository at this point in the history
  • Loading branch information
pbca26 committed Mar 1, 2022
1 parent 42b5d87 commit f35494b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/history-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const parse = ([txs, addr, options]) => {

for (let i = 0; i < txs.length; i++) {
let tx = {};
let vinSum = 0, voutSum = 0;
let vinSum = 0, voutSum = 0, txVin = 0, txVout = 0;

if (options && options.hasOwnProperty('debug')) {
writeLog('--- vin -->');
Expand All @@ -24,6 +24,8 @@ const parse = ([txs, addr, options]) => {
}

for (let j = 0; j < txs[i].vin.length; j++) {
if (txs[i].vin[j].value) txVin += Number(txs[i].vin[j].value);

if (addresses.indexOf(txs[i].vin[j].addr) === -1) {
addresses.push(txs[i].vin[j].addr);
}
Expand All @@ -34,6 +36,8 @@ const parse = ([txs, addr, options]) => {
}

for (let j = 0; j < txs[i].vout.length; j++) {
if (txs[i].vout[j].value) txVout += Number(txs[i].vout[j].value);

if (addresses.indexOf(txs[i].vout[j].scriptPubKey.addresses[0]) === -1) {
addresses.push(txs[i].vout[j].scriptPubKey.addresses[0]);
}
Expand Down Expand Up @@ -64,7 +68,7 @@ const parse = ([txs, addr, options]) => {
if (options &&
options.coin &&
options.coin.toUpperCase() === 'KMD' &&
(Number(vinSum - voutSum) < 0) &&
(Number(txVin - txVout) < 0) &&
myOutAddress) {
tx.type = 'rewards';
} else if (vinSum && !voutSum) {
Expand Down

0 comments on commit f35494b

Please sign in to comment.