aboutsummaryrefslogtreecommitdiff
path: root/src/rpcblockchain.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2014-11-28 20:32:52 +0100
committerJonas Schnelli <jonas.schnelli@include7.ch>2014-12-09 16:05:50 +0100
commit73351c3686094158c3a61f1f11126569c5c3ed3f (patch)
treee44ae151addbc2fc2129004c1d2e64f99f9ddf21 /src/rpcblockchain.cpp
parent0a1d03ca5265293e6419b0ffb68d277da6b1d9a0 (diff)
downloadbitcoin-73351c3686094158c3a61f1f11126569c5c3ed3f.tar.xz
[REST] /rest/block response with full tx details
- rest block request returns full unfolded tx details - /rest/block/notxdetails/<HASH> returns block where transactions are only represented by its hash
Diffstat (limited to 'src/rpcblockchain.cpp')
-rw-r--r--src/rpcblockchain.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp
index 924f416904..7784387756 100644
--- a/src/rpcblockchain.cpp
+++ b/src/rpcblockchain.cpp
@@ -16,6 +16,7 @@
using namespace json_spirit;
using namespace std;
+extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);
double GetDifficulty(const CBlockIndex* blockindex)
@@ -50,7 +51,7 @@ double GetDifficulty(const CBlockIndex* blockindex)
}
-Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
+Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false)
{
Object result;
result.push_back(Pair("hash", block.GetHash().GetHex()));
@@ -65,7 +66,16 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex()));
Array txs;
BOOST_FOREACH(const CTransaction&tx, block.vtx)
- txs.push_back(tx.GetHash().GetHex());
+ {
+ if(txDetails)
+ {
+ Object objTx;
+ TxToJSON(tx, block.GetHash(), objTx);
+ txs.push_back(objTx);
+ }
+ else
+ txs.push_back(tx.GetHash().GetHex());
+ }
result.push_back(Pair("tx", txs));
result.push_back(Pair("time", block.GetBlockTime()));
result.push_back(Pair("nonce", (uint64_t)block.nNonce));