From 2c0010a31fa3ffaedaabfffda034e4941bc27ddf Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 14 Nov 2014 14:59:51 -0800 Subject: [PATCH] fix error. fix parent block. --- src/bitcoindjs.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index dd12fe4f..91e23d8c 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -5738,10 +5738,14 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local jstx, boo jstx->Set(NanNew("time"), NanNew(cwtx.GetTxTime())); jstx->Set(NanNew("timereceived"), NanNew((int64_t)cwtx.nTimeReceived)); if (!parent) { - CBlock cblock = mapBlockIndex[cwtx.hashBlock]; - Local jsblock = NanNew(); - cblock_to_jsblock(cblock, block_index, jsblock, false); - jstx->Set(NanNew("_block"), jsblock); + CBlock cblock; + //CBlockIndex *cblock_index = mapBlockIndex[cwtx.hashBlock]; + CBlockIndex *cblock_index = mapBlockIndex[block_hash]; + if (ReadBlockFromDisk(cblock, cblock_index)) { + Local jsblock = NanNew(); + cblock_to_jsblock(cblock, cblock_index, jsblock, false); + jstx->Set(NanNew("_block"), jsblock); + } } } else { jstx->Set(NanNew("blockhash"), NanNew(uint256(0).GetHex())); @@ -5811,7 +5815,8 @@ jstx_to_ctx(const Local jstx, CTransaction& ctx_) { try { ssData >> ctx_; } catch (std::exception &e) { - return NanThrowError("Bad TX decode"); + NanThrowError("Bad TX decode"); + return; } return;