From 75b4f5e098ba9aaa843e49265491199626c6d86e Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 14 Feb 2014 18:02:57 -0300 Subject: [PATCH] fix historic sync --- lib/TransactionDb.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/TransactionDb.js b/lib/TransactionDb.js index 16284e88..b9829ed1 100644 --- a/lib/TransactionDb.js +++ b/lib/TransactionDb.js @@ -468,23 +468,25 @@ function spec(b) { // adapt bitcore TX object to bitcoind JSON response txInfo.txid = txInfo.hash; - - var to=0; - var tx = txInfo; - tx.outs.forEach( function(o) { - var s = new Script(o.s); - var addrs = self.getAddrStr(s); - // support only for p2pubkey p2pubkeyhash and p2sh - if (addrs.length === 1) { - tx.out[to].addrStr = addrs[0]; - tx.out[to].n = to; - } - to++; - }); + var to = 0; + var tx = txInfo; + if (tx.outs) { + tx.outs.forEach(function(o) { + var s = new Script(o.s); + var addrs = self.getAddrStr(s); + + // support only for p2pubkey p2pubkeyhash and p2sh + if (addrs.length === 1) { + tx.out[to].addrStr = addrs[0]; + tx.out[to].n = to; + } + to++; + }); + } var count = 0; - txInfo.vin = txInfo.in.map(function(txin) { + txInfo.vin = txInfo. in .map(function(txin) { var i = {}; if (txin.coinbase) {