aboutsummaryrefslogtreecommitdiff
path: root/src/rest.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/rest.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/rest.cpp')
-rw-r--r--src/rest.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/rest.cpp b/src/rest.cpp
index 6285784af5..6329b44c53 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -42,7 +42,7 @@ public:
};
extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry);
-extern Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex);
+extern Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false);
static RestErr RESTERR(enum HTTPStatusCode status, string message)
{
@@ -92,7 +92,8 @@ static bool ParseHashStr(const string& strReq, uint256& v)
static bool rest_block(AcceptedConnection* conn,
string& strReq,
map<string, string>& mapHeaders,
- bool fRun)
+ bool fRun,
+ bool showTxDetails)
{
vector<string> params;
enum RetFormat rf = ParseDataFormat(params, strReq);
@@ -131,7 +132,7 @@ static bool rest_block(AcceptedConnection* conn,
}
case RF_JSON: {
- Object objBlock = blockToJSON(block, pblockindex);
+ Object objBlock = blockToJSON(block, pblockindex, showTxDetails);
string strJSON = write_string(Value(objBlock), false) + "\n";
conn->stream() << HTTPReply(HTTP_OK, strJSON, fRun) << std::flush;
return true;
@@ -146,6 +147,22 @@ static bool rest_block(AcceptedConnection* conn,
return true; // continue to process further HTTP reqs on this cxn
}
+static bool rest_block_extended(AcceptedConnection* conn,
+ string& strReq,
+ map<string, string>& mapHeaders,
+ bool fRun)
+{
+ return rest_block(conn, strReq, mapHeaders, fRun, true);
+}
+
+static bool rest_block_notxdetails(AcceptedConnection* conn,
+ string& strReq,
+ map<string, string>& mapHeaders,
+ bool fRun)
+{
+ return rest_block(conn, strReq, mapHeaders, fRun, false);
+}
+
static bool rest_tx(AcceptedConnection* conn,
string& strReq,
map<string, string>& mapHeaders,
@@ -205,7 +222,8 @@ static const struct {
bool fRun);
} uri_prefixes[] = {
{"/rest/tx/", rest_tx},
- {"/rest/block/", rest_block},
+ {"/rest/block/notxdetails/", rest_block_notxdetails},
+ {"/rest/block/", rest_block_extended},
};
bool HTTPReq_REST(AcceptedConnection* conn,