aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2021-01-29 18:09:46 -0500
committerRussell Yanofsky <russ@yanofsky.org>2021-01-29 18:09:46 -0500
commit6158a6d3978a18d5ac4166ca2f59056d8ef71c3d (patch)
tree13a8ad94af645984bb524c0a3e0db638b10f0430 /src/rpc/util.cpp
parent80e16cadd56ca73b94b01c5cd98a325fe9d89bf3 (diff)
downloadbitcoin-6158a6d3978a18d5ac4166ca2f59056d8ef71c3d.tar.xz
refactor: Replace JSONRPCRequest fHelp field with mode field
No change in behavior
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r--src/rpc/util.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index bfdba5253c..dc57d2be07 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -476,6 +476,18 @@ std::string RPCExamples::ToDescriptionString() const
return m_examples.empty() ? m_examples : "\nExamples:\n" + m_examples;
}
+UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request)
+{
+ /*
+ * Check if the given request is valid according to this command or if
+ * the user is asking for help information, and throw help when appropriate.
+ */
+ if (request.mode == JSONRPCRequest::GET_HELP || !IsValidNumArgs(request.params.size())) {
+ throw std::runtime_error(ToString());
+ }
+ return m_fun(*this, request);
+}
+
bool RPCHelpMan::IsValidNumArgs(size_t num_args) const
{
size_t num_required_args = 0;