![]() |
Bitcoin Core 31.1.0
P2P Digital Currency
|
#include <util.h>
Public Types | |
| using | RPCMethodImpl = std::function<UniValue(const RPCHelpMan&, const JSONRPCRequest&)> |
Public Member Functions | |
| RPCHelpMan (std::string name, std::string description, std::vector< RPCArg > args, RPCResults results, RPCExamples examples) | |
| RPCHelpMan (std::string name, std::string description, std::vector< RPCArg > args, RPCResults results, RPCExamples examples, RPCMethodImpl fun) | |
| UniValue | HandleRequest (const JSONRPCRequest &request) const |
| template<typename R> | |
| auto | Arg (std::string_view key) const |
| Helper to get a required or default-valued request argument. | |
| template<typename R> | |
| auto | MaybeArg (std::string_view key) const |
| Helper to get an optional request argument. | |
| std::string | ToString () const |
| UniValue | GetArgMap () const |
| Return the named args that need to be converted from string to another JSON type. | |
| bool | IsValidNumArgs (size_t num_args) const |
| If the supplied number of args is neither too small nor too high. | |
| std::vector< std::pair< std::string, bool > > | GetArgNames () const |
| Return list of arguments and whether they are named-only. | |
Public Attributes | |
| const std::string | m_name |
Private Member Functions | |
| template<typename R> | |
| R | ArgValue (size_t i) const |
| size_t | GetParamIndex (std::string_view key) const |
| Return positional index of a parameter using its name as key. | |
Private Attributes | |
| const RPCMethodImpl | m_fun |
| const std::string | m_description |
| const std::vector< RPCArg > | m_args |
| const RPCResults | m_results |
| const RPCExamples | m_examples |
| const JSONRPCRequest * | m_req {nullptr} |
| using RPCHelpMan::RPCMethodImpl = std::function<UniValue(const RPCHelpMan&, const JSONRPCRequest&)> |
| RPCHelpMan::RPCHelpMan | ( | std::string | name, |
| std::string | description, | ||
| std::vector< RPCArg > | args, | ||
| RPCResults | results, | ||
| RPCExamples | examples ) |
| RPCHelpMan::RPCHelpMan | ( | std::string | name, |
| std::string | description, | ||
| std::vector< RPCArg > | args, | ||
| RPCResults | results, | ||
| RPCExamples | examples, | ||
| RPCMethodImpl | fun ) |
|
inline |
Helper to get a required or default-valued request argument.
Use this function when the argument is required or when it has a default value. If the argument is optional and may not be provided, use MaybeArg instead.
This function only works during m_fun(), i.e., it should only be used in RPC method implementations. It internally checks whether the user-passed argument isNull() and parses (from JSON) and returns the user-passed argument, or the default value derived from the RPCArg documentation.
The instantiation of this helper for type R must match the corresponding RPCArg::Type.
Definition at line 444 of file util.h.
|
private |
| UniValue RPCHelpMan::GetArgMap | ( | ) | const |
| std::vector< std::pair< std::string, bool > > RPCHelpMan::GetArgNames | ( | ) | const |
|
private |
| UniValue RPCHelpMan::HandleRequest | ( | const JSONRPCRequest & | request | ) | const |
| bool RPCHelpMan::IsValidNumArgs | ( | size_t | num_args | ) | const |
|
inline |
Helper to get an optional request argument.
Use this function when the argument is optional and does not have a default value. If the argument is required or has a default value, use Arg instead.
This function only works during m_fun(), i.e., it should only be used in RPC method implementations. It internally checks whether the user-passed argument isNull() and parses (from JSON) and returns the user-passed argument, or a falsy value if no argument was passed.
The instantiation of this helper for type R must match the corresponding RPCArg::Type.
Definition at line 476 of file util.h.
| std::string RPCHelpMan::ToString | ( | ) | const |
|
private |
|
private |
|
mutableprivate |
|
private |