diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 51ac2adfe0dac..8b688648ed083 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -188,7 +188,7 @@ bool ParseBool(const UniValue& o, std::string strKey) * Note: This interface may still be subject to change. */ -std::string CRPCTable::help(std::string strCommand) const +std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& helpreq) const { std::string strRet; std::string category; @@ -199,14 +199,17 @@ std::string CRPCTable::help(std::string strCommand) const vCommands.emplace_back(entry.second->category + entry.first, entry.second); std::sort(vCommands.begin(), vCommands.end()); + JSONRPCRequest jreq(helpreq); + jreq.fHelp = true; + jreq.params = UniValue(); + for (const std::pair& command : vCommands) { const CRPCCommand* pcmd = command.second; std::string strMethod = pcmd->name; if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand) continue; + jreq.strMethod = strMethod; try { - JSONRPCRequest jreq; - jreq.fHelp = true; rpcfn_type pfn = pcmd->actor; if (setDone.insert(pfn).second) (*pfn)(jreq); @@ -248,7 +251,7 @@ UniValue help(const JSONRPCRequest& jsonRequest) if (jsonRequest.params.size() > 0) strCommand = jsonRequest.params[0].get_str(); - return tableRPC.help(strCommand); + return tableRPC.help(strCommand, jsonRequest); } diff --git a/src/rpc/server.h b/src/rpc/server.h index abb69c38fa217..9bbeb38f0a43e 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -151,7 +151,7 @@ class CRPCTable public: CRPCTable(); const CRPCCommand* operator[](const std::string& name) const; - std::string help(std::string name) const; + std::string help(const std::string& name, const JSONRPCRequest& helpreq) const; /** * Execute a method.