Skip to content

Commit a518fff

Browse files
committed
rest: add verbose and mempool_sequence query params for mempool/contents
1 parent b2e6d37 commit a518fff

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/rest.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,20 @@ static bool rest_mempool(const std::any& context, HTTPRequest* req, const std::s
608608
case RESTResponseFormat::JSON: {
609609
std::string str_json;
610610
if (param == "contents") {
611-
str_json = MempoolToJSON(*mempool, true).write() + "\n";
611+
const std::string raw_verbose{req->GetQueryParameter("verbose").value_or("true")};
612+
if (raw_verbose != "true" && raw_verbose != "false") {
613+
return RESTERR(req, HTTP_BAD_REQUEST, "The \"verbose\" query parameter must be either \"true\" or \"false\".");
614+
}
615+
const std::string raw_mempool_sequence{req->GetQueryParameter("mempool_sequence").value_or("false")};
616+
if (raw_mempool_sequence != "true" && raw_mempool_sequence != "false") {
617+
return RESTERR(req, HTTP_BAD_REQUEST, "The \"mempool_sequence\" query parameter must be either \"true\" or \"false\".");
618+
}
619+
const bool verbose{raw_verbose == "true"};
620+
const bool mempool_sequence{raw_mempool_sequence == "true"};
621+
if (verbose && mempool_sequence) {
622+
return RESTERR(req, HTTP_BAD_REQUEST, "Verbose results cannot contain mempool sequence values. (hint: set \"verbose=false\")");
623+
}
624+
str_json = MempoolToJSON(*mempool, verbose, mempool_sequence).write() + "\n";
612625
} else {
613626
str_json = MempoolInfoToJSON(*mempool).write() + "\n";
614627
}

0 commit comments

Comments
 (0)