From 46c9027bdb438a78af28906a71ef390f7bef2247 Mon Sep 17 00:00:00 2001 From: tenthirtyone Date: Thu, 10 Aug 2017 17:56:21 -0400 Subject: [PATCH] Fixed tx value out on home page --- lib/api/transaction.js | 1 + lib/parser/transaction.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/api/transaction.js b/lib/api/transaction.js index 846e974..15ac88a 100644 --- a/lib/api/transaction.js +++ b/lib/api/transaction.js @@ -111,6 +111,7 @@ module.exports = function transactionAPI(router) { coinbase: input.script, sequence: input.sequence, n: 0, + addr: input.address, })), vout: tx.outputs.map(output => ({ value: output.value / 1e8, diff --git a/lib/parser/transaction.js b/lib/parser/transaction.js index a875bda..557e4d0 100644 --- a/lib/parser/transaction.js +++ b/lib/parser/transaction.js @@ -16,18 +16,19 @@ function parse(entry, txs) { counter++; if (counter % socketThrottle === 0) { + io.sockets.emit('tx', { txid: txJSON.hash, - valueOut: tx.outputs.reduce((a, b) => { - a = a.toJSON(); - b = b.toJSON(); + valueOut: tx.outputs.reduce((sum, tx) => { + tx = tx.toJSON(); - const valA = (a.value || a.valueOut.value || 0) / 1e8; - const valB = (b.value || b.valueOut.value || 0) / 1e8; + const valB = (tx.value || tx.valueOut.value || 0) / 1e8; - return valA + valB; - }), - }, 0); + console.log(valB) + + return sum + valB; + }, 0), + }); } const t = new TxModel({