Skip to content

Commit 687c2fd

Browse files
luke-jrrandom-zebra
authored andcommitted
RPC: Pass on JSONRPCRequest metadata (URI/user/etc) for "help" method
1 parent cc965fe commit 687c2fd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/rpc/server.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ bool ParseBool(const UniValue& o, std::string strKey)
188188
* Note: This interface may still be subject to change.
189189
*/
190190

191-
std::string CRPCTable::help(std::string strCommand) const
191+
std::string CRPCTable::help(const std::string& strCommand, const JSONRPCRequest& helpreq) const
192192
{
193193
std::string strRet;
194194
std::string category;
@@ -199,14 +199,17 @@ std::string CRPCTable::help(std::string strCommand) const
199199
vCommands.emplace_back(entry.second->category + entry.first, entry.second);
200200
std::sort(vCommands.begin(), vCommands.end());
201201

202+
JSONRPCRequest jreq(helpreq);
203+
jreq.fHelp = true;
204+
jreq.params = UniValue();
205+
202206
for (const std::pair<std::string, const CRPCCommand*>& command : vCommands) {
203207
const CRPCCommand* pcmd = command.second;
204208
std::string strMethod = pcmd->name;
205209
if ((strCommand != "" || pcmd->category == "hidden") && strMethod != strCommand)
206210
continue;
211+
jreq.strMethod = strMethod;
207212
try {
208-
JSONRPCRequest jreq;
209-
jreq.fHelp = true;
210213
rpcfn_type pfn = pcmd->actor;
211214
if (setDone.insert(pfn).second)
212215
(*pfn)(jreq);
@@ -248,7 +251,7 @@ UniValue help(const JSONRPCRequest& jsonRequest)
248251
if (jsonRequest.params.size() > 0)
249252
strCommand = jsonRequest.params[0].get_str();
250253

251-
return tableRPC.help(strCommand);
254+
return tableRPC.help(strCommand, jsonRequest);
252255
}
253256

254257

src/rpc/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class CRPCTable
151151
public:
152152
CRPCTable();
153153
const CRPCCommand* operator[](const std::string& name) const;
154-
std::string help(std::string name) const;
154+
std::string help(const std::string& name, const JSONRPCRequest& helpreq) const;
155155

156156
/**
157157
* Execute a method.

0 commit comments

Comments
 (0)