diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 17c0d998..db15fa0b 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -5609,7 +5609,6 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local jstx) { jstx->Set(NanNew("size"), NanNew((int)::GetSerializeSize(ctx, SER_NETWORK, PROTOCOL_VERSION))->ToInt32()); - bool is_mine = false; Local vin = NanNew(); int vi = 0; BOOST_FOREACH(const CTxIn& txin, ctx.vin) { @@ -5634,12 +5633,6 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local jstx) { ExtractDestination(prev_out.scriptPubKey, from); CBitcoinAddress addrFrom(from); - // XXX Determine wether this is our transaction - CTxDestination dest = addrFrom.Get(); - if (IsMine(*pwalletMain, dest)) { - is_mine = true; - } - jsprev->Set(NanNew("address"), NanNew(addrFrom.ToString())); jsprev->Set(NanNew("value"), NanNew((int64_t)prev_out.nValue)->ToInteger()); } else { @@ -5670,11 +5663,6 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local jstx) { const CScript& scriptPubKey = txout.scriptPubKey; Local out = o; - // XXX Determine wether this is our transaction - if (IsMine(*pwalletMain, scriptPubKey)) { - is_mine = true; - } - txnouttype type; vector addresses; int nRequired; @@ -5701,10 +5689,15 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local jstx) { jstx->Set(NanNew("vout"), vout); CWalletTx cwtx(pwalletMain, ctx); - //bool is_mine = cwtx.hashBlock != uint256(0); - //bool is_mine = cwtx.hashBlock != 0; + // XXX Determine wether this is our transaction + bool is_mine = cwtx.hashBlock != 0; jstx->Set(NanNew("ismine"), NanNew(is_mine)); + // Find block hash if it's in our wallet + if (block_hash == 0 && is_mine) { + block_hash = cwtx.hashBlock; + } + if (block_hash != 0) { jstx->Set(NanNew("blockhash"), NanNew(block_hash.GetHex())); if (ctx.IsCoinBase()) {