From 99b519418cde04b6a8c8d386a4d5a4dbfa9a0b0b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 22 Sep 2014 15:42:30 -0700 Subject: [PATCH] cleanup object creation for GetBlock and GetTx. --- src/bitcoindjs.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bitcoindjs.cc b/src/bitcoindjs.cc index 4bc05697..37dd35f6 100644 --- a/src/bitcoindjs.cc +++ b/src/bitcoindjs.cc @@ -756,7 +756,12 @@ async_get_block_after(uv_work_t *req) { int ti = 0; BOOST_FOREACH(const CTransaction& tx, block.vtx) { Local entry = NanNew(); - // TODO: entry->Set(NanNew("hex"), NanNew(__HEXSTR_HERE__)); + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + string strHex = HexStr(ssTx.begin(), ssTx.end()); + entry->Set(NanNew("hex"), NanNew(strHex)); + entry->Set(NanNew("txid"), NanNew(tx.GetHash().GetHex())); entry->Set(NanNew("version"), NanNew(tx.nVersion)); entry->Set(NanNew("locktime"), NanNew(tx.nLockTime)); @@ -785,17 +790,15 @@ async_get_block_after(uv_work_t *req) { for (unsigned int vo = 0; vo < tx.vout.size(); vo++) { const CTxOut& txout = tx.vout[vo]; Local out = NanNew(); - //out->Set(NanNew("value"), NanNew(ValueFromAmount(txout.nValue))); out->Set(NanNew("value"), NanNew(txout.nValue)); out->Set(NanNew("n"), NanNew((boost::int64_t)vo)); - // ScriptPubKeyToJSON(txout.scriptPubKey, o, true); Local o = NanNew(); { const CScript& scriptPubKey = txout.scriptPubKey; Local out = o; bool fIncludeHex = true; - // --- + txnouttype type; vector addresses; int nRequired; @@ -823,7 +826,6 @@ async_get_block_after(uv_work_t *req) { } entry->Set(NanNew("vout"), vout); - // TxToJSON(tx, hashBlock, result); { const uint256 hashBlock = block.GetHash(); if (hashBlock != 0) { @@ -1006,17 +1008,15 @@ async_get_tx_after(uv_work_t *req) { for (unsigned int vo = 0; vo < tx.vout.size(); vo++) { const CTxOut& txout = tx.vout[vo]; Local out = NanNew(); - //out->Set(NanNew("value"), NanNew(ValueFromAmount(txout.nValue))); out->Set(NanNew("value"), NanNew(txout.nValue)); out->Set(NanNew("n"), NanNew((boost::int64_t)vo)); - // ScriptPubKeyToJSON(txout.scriptPubKey, o, true); Local o = NanNew(); { const CScript& scriptPubKey = txout.scriptPubKey; Local out = o; bool fIncludeHex = true; - // --- + txnouttype type; vector addresses; int nRequired;