diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 0fa054fd..53063bcb 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -5699,30 +5699,41 @@ ctx_to_jstx(const CTransaction& ctx, uint256& block_hash, Local jstx) { jstx->Set(NanNew("timereceived"), NanNew((uint32_t)mapBlockIndex[block_hash]->GetBlockTime())->ToUint32()); #if 0 - jstx->Set(NanNew("blockhash"), NanNew(block_hash.GetHex())); - CWalletTx cwtx(pwalletMain, ctx); - int confirms = cwtx.GetDepthInMainChain(); - jstx->Set(NanNew("confirmations"), NanNew(confirms)); - if (ctx.IsCoinBase()) { - jstx->Set(NanNew("generated"), NanNew(true)); + bool is_mine = false; + for (unsigned int vo = 0; vo < ctx.vout.size(); vo++) { + const CTxOut& txout = ctx.vout[vo]; + const CScript& scriptPubKey = txout.scriptPubKey; + if (IsMine(*pwalletMain, scriptPubKey)) { + is_mine = true; + break; + } } - if (confirms > 0) { - jstx->Set(NanNew("blockhash"), NanNew(cwtx.hashBlock.GetHex())); - jstx->Set(NanNew("blockindex"), NanNew(cwtx.nIndex)); - jstx->Set(NanNew("blocktime"), NanNew(mapBlockIndex[cwtx.hashBlock]->GetBlockTime())); - } else { - jstx->Set(NanNew("blockhash"), NanNew(uint256(0).GetHex())); - jstx->Set(NanNew("blockindex"), NanNew(-1)); - jstx->Set(NanNew("blocktime"), NanNew(0)); + if (is_mine) { + jstx->Set(NanNew("blockhash"), NanNew(block_hash.GetHex())); + CWalletTx cwtx(pwalletMain, ctx); + int confirms = cwtx.GetDepthInMainChain(); + jstx->Set(NanNew("confirmations"), NanNew(confirms)); + if (ctx.IsCoinBase()) { + jstx->Set(NanNew("generated"), NanNew(true)); + } + if (confirms > 0) { + jstx->Set(NanNew("blockhash"), NanNew(cwtx.hashBlock.GetHex())); + jstx->Set(NanNew("blockindex"), NanNew(cwtx.nIndex)); + jstx->Set(NanNew("blocktime"), NanNew(mapBlockIndex[cwtx.hashBlock]->GetBlockTime())); + } else { + jstx->Set(NanNew("blockhash"), NanNew(uint256(0).GetHex())); + jstx->Set(NanNew("blockindex"), NanNew(-1)); + jstx->Set(NanNew("blocktime"), NanNew(0)); + } + Local conflicts = NanNew(); + int co = 0; + BOOST_FOREACH(const uint256& conflict, cwtx.GetConflicts()) { + conflicts->Set(co++, NanNew(conflict.GetHex())); + } + jstx->Set(NanNew("walletconflicts"), conflicts); + jstx->Set(NanNew("time"), NanNew(cwtx.GetTxTime())); + jstx->Set(NanNew("timereceived"), NanNew((int64_t)cwtx.nTimeReceived)); } - Local conflicts = NanNew(); - int co = 0; - BOOST_FOREACH(const uint256& conflict, cwtx.GetConflicts()) { - conflicts->Set(co++, NanNew(conflict.GetHex())); - } - jstx->Set(NanNew("walletconflicts"), conflicts); - jstx->Set(NanNew("time"), NanNew(cwtx.GetTxTime())); - jstx->Set(NanNew("timereceived"), NanNew((int64_t)cwtx.nTimeReceived)); #endif } else { jstx->Set(NanNew("blockhash"), NanNew(uint256(0).GetHex()));