Skip to content

Commit

Permalink
rest: add verbose and mempool_sequence query params for mempool/contents
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtoth committed Oct 5, 2022
1 parent b2e6d37 commit a518fff
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,20 @@ static bool rest_mempool(const std::any& context, HTTPRequest* req, const std::s
case RESTResponseFormat::JSON: {
std::string str_json;
if (param == "contents") {
str_json = MempoolToJSON(*mempool, true).write() + "\n";
const std::string raw_verbose{req->GetQueryParameter("verbose").value_or("true")};
if (raw_verbose != "true" && raw_verbose != "false") {
return RESTERR(req, HTTP_BAD_REQUEST, "The \"verbose\" query parameter must be either \"true\" or \"false\".");
}
const std::string raw_mempool_sequence{req->GetQueryParameter("mempool_sequence").value_or("false")};
if (raw_mempool_sequence != "true" && raw_mempool_sequence != "false") {
return RESTERR(req, HTTP_BAD_REQUEST, "The \"mempool_sequence\" query parameter must be either \"true\" or \"false\".");
}
const bool verbose{raw_verbose == "true"};
const bool mempool_sequence{raw_mempool_sequence == "true"};
if (verbose && mempool_sequence) {
return RESTERR(req, HTTP_BAD_REQUEST, "Verbose results cannot contain mempool sequence values. (hint: set \"verbose=false\")");
}
str_json = MempoolToJSON(*mempool, verbose, mempool_sequence).write() + "\n";
} else {
str_json = MempoolInfoToJSON(*mempool).write() + "\n";
}
Expand Down

0 comments on commit a518fff

Please sign in to comment.