mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
rest: add verbose and mempool_sequence query params for mempool/contents
This commit is contained in:
parent
b2e6d37b51
commit
a518fff0f2
1 changed files with 14 additions and 1 deletions
15
src/rest.cpp
15
src/rest.cpp
|
@ -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";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue