rpc: Run type check against RPCArgs

This commit is contained in:
MarcoFalke
2022-12-12 14:30:14 +01:00
parent faf96721a6
commit fa9f6d7bcd
12 changed files with 83 additions and 153 deletions

View File

@@ -62,13 +62,6 @@ struct UniValueType {
UniValue::VType type;
};
/**
* Type-check arguments; throws JSONRPCError if wrong type given. Does not check that
* the right number of arguments are passed, just that any passed are the correct type.
*/
void RPCTypeCheck(const UniValue& params,
const std::list<UniValueType>& typesExpected, bool fAllowNull=false);
/**
* Type-check one argument; throws JSONRPCError if wrong type given.
*/
@@ -138,6 +131,7 @@ enum class OuterType {
};
struct RPCArgOptions {
bool skip_type_check{false};
std::string oneline_description{}; //!< Should be empty unless it is supposed to override the auto-generated summary line
std::vector<std::string> type_str{}; //!< Should be empty unless it is supposed to override the auto-generated type strings. Vector length is either 0 or 2, m_opts.type_str.at(0) will override the type of the value in a key-value pair, m_opts.type_str.at(1) will override the type in the argument description.
bool hidden{false}; //!< For testing only
@@ -217,6 +211,9 @@ struct RPCArg {
bool IsOptional() const;
/** Check whether the request JSON type matches. */
void MatchesType(const UniValue& request) const;
/** Return the first of all aliases */
std::string GetFirstName() const;