check IsMine for tx conversions.

This commit is contained in:
Christopher Jeffrey 2014-11-18 15:42:15 -08:00
parent d8701332c0
commit d50c103c00
1 changed files with 33 additions and 22 deletions

View File

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