mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
rpc: Add CRPCCommand constructor which takes RPCHelpMan
This allows the constructor to ask the rpc manager for the name of the rpc method or the rpc argument names instead of having it manually passed in.
This commit is contained in:
@@ -418,7 +418,11 @@ struct Sections {
|
||||
};
|
||||
|
||||
RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples)
|
||||
: RPCHelpMan{std::move(name), std::move(description), std::move(args), std::move(results), std::move(examples), nullptr} {}
|
||||
|
||||
RPCHelpMan::RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples, RPCMethodImpl fun)
|
||||
: m_name{std::move(name)},
|
||||
m_fun{std::move(fun)},
|
||||
m_description{std::move(description)},
|
||||
m_args{std::move(args)},
|
||||
m_results{std::move(results)},
|
||||
@@ -467,6 +471,16 @@ bool RPCHelpMan::IsValidNumArgs(size_t num_args) const
|
||||
}
|
||||
return num_required_args <= num_args && num_args <= m_args.size();
|
||||
}
|
||||
|
||||
std::vector<std::string> RPCHelpMan::GetArgNames() const
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
for (const auto& arg : m_args) {
|
||||
ret.emplace_back(arg.m_names);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string RPCHelpMan::ToString() const
|
||||
{
|
||||
std::string ret;
|
||||
|
||||
Reference in New Issue
Block a user