mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Remove pointer cast in CRPCTable::dumpArgMap
CRPCTable::dumpArgMap currently works by casting RPC command unique_id integer field to a function pointer, and then calling the function. The unique_id field wasn't supposed to be used this way (it's meant to be used to detect RPC aliases), and this code segfaults in the rpc_help.py test in multiprocess PR https://github.com/bitcoin/bitcoin/pull/10102 because wallet RPC functions aren't directly accessible from the node process. Fix this by adding a new GET_ARGS request mode to retrieve argument information similar to the way the GET_HELP mode retrieves help information.
This commit is contained in:
@@ -478,6 +478,9 @@ std::string RPCExamples::ToDescriptionString() const
|
||||
|
||||
UniValue RPCHelpMan::HandleRequest(const JSONRPCRequest& request)
|
||||
{
|
||||
if (request.mode == JSONRPCRequest::GET_ARGS) {
|
||||
return GetArgMap();
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
@@ -561,8 +564,9 @@ std::string RPCHelpMan::ToString() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RPCHelpMan::AppendArgMap(UniValue& arr) const
|
||||
UniValue RPCHelpMan::GetArgMap() const
|
||||
{
|
||||
UniValue arr{UniValue::VARR};
|
||||
for (int i{0}; i < int(m_args.size()); ++i) {
|
||||
const auto& arg = m_args.at(i);
|
||||
std::vector<std::string> arg_names;
|
||||
@@ -577,6 +581,7 @@ void RPCHelpMan::AppendArgMap(UniValue& arr) const
|
||||
arr.push_back(map);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
std::string RPCArg::GetFirstName() const
|
||||
|
||||
Reference in New Issue
Block a user