check whether tx is ours. add walletconflicts if so.
This commit is contained in:
parent
e11389bb54
commit
918dc08ddc
@ -5607,6 +5607,7 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
jstx->Set(NanNew<String>("size"),
|
jstx->Set(NanNew<String>("size"),
|
||||||
NanNew<Number>((int)::GetSerializeSize(ctx, SER_NETWORK, PROTOCOL_VERSION))->ToInt32());
|
NanNew<Number>((int)::GetSerializeSize(ctx, SER_NETWORK, PROTOCOL_VERSION))->ToInt32());
|
||||||
|
|
||||||
|
bool is_mine = false;
|
||||||
Local<Array> vin = NanNew<Array>();
|
Local<Array> vin = NanNew<Array>();
|
||||||
int vi = 0;
|
int vi = 0;
|
||||||
BOOST_FOREACH(const CTxIn& txin, ctx.vin) {
|
BOOST_FOREACH(const CTxIn& txin, ctx.vin) {
|
||||||
@ -5630,6 +5631,13 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
CTxOut prev_out = prev_tx.vout[txin.prevout.n];
|
CTxOut prev_out = prev_tx.vout[txin.prevout.n];
|
||||||
ExtractDestination(prev_out.scriptPubKey, from);
|
ExtractDestination(prev_out.scriptPubKey, from);
|
||||||
CBitcoinAddress addrFrom(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<String>("address"), NanNew<String>(addrFrom.ToString()));
|
jsprev->Set(NanNew<String>("address"), NanNew<String>(addrFrom.ToString()));
|
||||||
jsprev->Set(NanNew<String>("value"), NanNew<Number>((int64_t)prev_out.nValue)->ToInteger());
|
jsprev->Set(NanNew<String>("value"), NanNew<Number>((int64_t)prev_out.nValue)->ToInteger());
|
||||||
} else {
|
} else {
|
||||||
@ -5647,7 +5655,6 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
}
|
}
|
||||||
jstx->Set(NanNew<String>("vin"), vin);
|
jstx->Set(NanNew<String>("vin"), vin);
|
||||||
|
|
||||||
//bool is_mine = false;
|
|
||||||
Local<Array> vout = NanNew<Array>();
|
Local<Array> vout = NanNew<Array>();
|
||||||
for (unsigned int vo = 0; vo < ctx.vout.size(); vo++) {
|
for (unsigned int vo = 0; vo < ctx.vout.size(); vo++) {
|
||||||
const CTxOut& txout = ctx.vout[vo];
|
const CTxOut& txout = ctx.vout[vo];
|
||||||
@ -5661,9 +5668,10 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
const CScript& scriptPubKey = txout.scriptPubKey;
|
const CScript& scriptPubKey = txout.scriptPubKey;
|
||||||
Local<Object> out = o;
|
Local<Object> out = o;
|
||||||
|
|
||||||
//if (IsMine(*pwalletMain, scriptPubKey)) {
|
// XXX Determine wether this is our transaction
|
||||||
// is_mine = true;
|
if (IsMine(*pwalletMain, scriptPubKey)) {
|
||||||
//}
|
is_mine = true;
|
||||||
|
}
|
||||||
|
|
||||||
txnouttype type;
|
txnouttype type;
|
||||||
vector<CTxDestination> addresses;
|
vector<CTxDestination> addresses;
|
||||||
@ -5690,6 +5698,11 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
}
|
}
|
||||||
jstx->Set(NanNew<String>("vout"), vout);
|
jstx->Set(NanNew<String>("vout"), vout);
|
||||||
|
|
||||||
|
//CWalletTx cwtx(pwalletMain, ctx);
|
||||||
|
//bool is_mine = cwtx.hashBlock != uint256(0);
|
||||||
|
//bool is_mine = cwtx.hashBlock != 0;
|
||||||
|
//jstx->Set(NanNew<String>("ismine"), NanNew<Boolean>(is_mine));
|
||||||
|
|
||||||
if (block_hash != 0) {
|
if (block_hash != 0) {
|
||||||
jstx->Set(NanNew<String>("blockhash"), NanNew<String>(block_hash.GetHex()));
|
jstx->Set(NanNew<String>("blockhash"), NanNew<String>(block_hash.GetHex()));
|
||||||
if (ctx.IsCoinBase()) {
|
if (ctx.IsCoinBase()) {
|
||||||
@ -5707,12 +5720,6 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
NanNew<Number>((int64_t)pindex->GetBlockTime())->ToInteger());
|
NanNew<Number>((int64_t)pindex->GetBlockTime())->ToInteger());
|
||||||
jstx->Set(NanNew<String>("timereceived"),
|
jstx->Set(NanNew<String>("timereceived"),
|
||||||
NanNew<Number>((int64_t)pindex->GetBlockTime())->ToInteger());
|
NanNew<Number>((int64_t)pindex->GetBlockTime())->ToInteger());
|
||||||
//jstx->Set(NanNew<String>("blocktime"),
|
|
||||||
// NanNew<Number>(pindex->GetBlockTime()));
|
|
||||||
//jstx->Set(NanNew<String>("time"),
|
|
||||||
// NanNew<Number>(pindex->GetBlockTime()));
|
|
||||||
//jstx->Set(NanNew<String>("timereceived"),
|
|
||||||
// NanNew<Number>(pindex->GetBlockTime()));
|
|
||||||
} else {
|
} else {
|
||||||
jstx->Set(NanNew<String>("confirmations"), NanNew<Number>(0));
|
jstx->Set(NanNew<String>("confirmations"), NanNew<Number>(0));
|
||||||
jstx->Set(NanNew<String>("blockindex"), NanNew<Number>(-1));
|
jstx->Set(NanNew<String>("blockindex"), NanNew<Number>(-1));
|
||||||
@ -5720,25 +5727,12 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
jstx->Set(NanNew<String>("time"), NanNew<Number>(0));
|
jstx->Set(NanNew<String>("time"), NanNew<Number>(0));
|
||||||
jstx->Set(NanNew<String>("timereceived"), NanNew<Number>(0));
|
jstx->Set(NanNew<String>("timereceived"), NanNew<Number>(0));
|
||||||
}
|
}
|
||||||
jstx->Set(NanNew<String>("walletconflicts"), NanNew<Array>());
|
if (!is_mine) {
|
||||||
#if 0
|
jstx->Set(NanNew<String>("walletconflicts"), NanNew<Array>());
|
||||||
if (is_mine) {
|
} else {
|
||||||
jstx->Set(NanNew<String>("blockhash"), NanNew<String>(block_hash.GetHex()));
|
// XXX If the tx is ours
|
||||||
CWalletTx cwtx(pwalletMain, ctx);
|
|
||||||
int confirms = cwtx.GetDepthInMainChain();
|
int confirms = cwtx.GetDepthInMainChain();
|
||||||
jstx->Set(NanNew<String>("confirmations"), NanNew<Number>(confirms));
|
jstx->Set(NanNew<String>("confirmations"), NanNew<Number>(confirms));
|
||||||
if (ctx.IsCoinBase()) {
|
|
||||||
jstx->Set(NanNew<String>("generated"), NanNew<Boolean>(true));
|
|
||||||
}
|
|
||||||
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>();
|
Local<Array> conflicts = NanNew<Array>();
|
||||||
int co = 0;
|
int co = 0;
|
||||||
BOOST_FOREACH(const uint256& conflict, cwtx.GetConflicts()) {
|
BOOST_FOREACH(const uint256& conflict, cwtx.GetConflicts()) {
|
||||||
@ -5748,7 +5742,6 @@ ctx_to_jstx(const CTransaction& ctx, uint256 block_hash, Local<Object> jstx) {
|
|||||||
jstx->Set(NanNew<String>("time"), NanNew<Number>(cwtx.GetTxTime()));
|
jstx->Set(NanNew<String>("time"), NanNew<Number>(cwtx.GetTxTime()));
|
||||||
jstx->Set(NanNew<String>("timereceived"), NanNew<Number>((int64_t)cwtx.nTimeReceived));
|
jstx->Set(NanNew<String>("timereceived"), NanNew<Number>((int64_t)cwtx.nTimeReceived));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
jstx->Set(NanNew<String>("blockhash"), NanNew<String>(uint256(0).GetHex()));
|
jstx->Set(NanNew<String>("blockhash"), NanNew<String>(uint256(0).GetHex()));
|
||||||
jstx->Set(NanNew<String>("confirmations"), NanNew<Number>(-1));
|
jstx->Set(NanNew<String>("confirmations"), NanNew<Number>(-1));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user