38 "\"qrmzys48glkpevp2l4t24jtcltc9hyzx9cep2qffm4\"";
41 const std::map<std::string, UniValueType> &typesExpected,
42 bool fAllowNull,
bool fStrict) {
43 for (
const auto &t : typesExpected) {
45 if (!fAllowNull && v.
isNull()) {
50 if (!(t.second.typeAny || v.
type() == t.second.type ||
51 (fAllowNull && v.
isNull()))) {
52 std::string err =
strprintf(
"Expected type %s for %s, got %s",
60 for (
const std::string &k : o.
getKeys()) {
61 if (typesExpected.count(k) == 0) {
62 std::string err =
strprintf(
"Unexpected key %s", k);
88 const std::string &strHex(v.
get_str());
89 if (64 != strHex.length()) {
92 strprintf(
"%s must be of length %d (not %d, for '%s')", strName, 64,
93 strHex.length(), strHex));
98 strName +
" must be hexadecimal string (not '" +
113 if (!
IsHex(strHex)) {
115 strName +
" must be hexadecimal string (not '" +
133std::string ShellQuote(
const std::string &s) {
135 result.reserve(s.size() * 2);
136 for (
const char ch : s) {
143 return "'" + result +
"'";
152std::string ShellQuoteIfNeeded(
const std::string &s) {
153 for (
const char ch : s) {
154 if (ch ==
' ' || ch ==
'\'' || ch ==
'"') {
155 return ShellQuote(s);
165 const std::string &args) {
166 return "> bitcoin-cli " + methodname +
" " + args +
"\n";
171 std::string result =
"> bitcoin-cli -named " + methodname;
172 for (
const auto &argpair : args) {
173 const auto &value = argpair.second.isStr() ? argpair.second.get_str()
174 : argpair.second.write();
175 result +=
" " + argpair.first +
"=" + ShellQuoteIfNeeded(value);
182 const std::string &args) {
183 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", "
184 "\"id\": \"curltest\", "
186 methodname +
"\", \"params\": [" + args +
187 "]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
193 for (
const auto ¶m : args) {
194 params.
pushKV(param.first, param.second);
197 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", "
198 "\"id\": \"curltest\", "
200 methodname +
"\", \"params\": " + params.
write() +
201 "}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
206 if (!
IsHex(hex_in)) {
208 "Invalid public key: " + hex_in);
213 "Invalid public key: " + hex_in);
221 const std::string &addr_in) {
225 "Invalid address: " + addr_in);
230 strprintf(
"%s does not refer to a key", addr_in));
233 if (!keystore.
GetPubKey(key, vchPubKey)) {
236 strprintf(
"no full public key for address %s", addr_in));
240 "Wallet contains an invalid public key");
248 const std::vector<CPubKey> &pubkeys,
251 CScript &script_out) {
256 "a multisignature address must require at least one key to redeem");
258 if ((
int)pubkeys.size() < required) {
260 strprintf(
"not enough keys supplied (got %u keys, "
261 "but need at least %d to redeem)",
262 pubkeys.size(), required));
264 if (pubkeys.size() > 16) {
266 "Number of keys involved in the multisignature "
267 "address creation > 16\nReduce the number");
275 (
strprintf(
"redeemScript exceeds size limit: %d > %d",
281 if (!
pk.IsCompressed()) {
304 obj.
pushKV(
"isscript",
false);
310 obj.
pushKV(
"isscript",
true);
320 std::vector<std::string> ret;
321 using U = std::underlying_type<TxoutType>::type;
325 return Join(ret,
", ");
330 case PSBTError::UNSUPPORTED:
332 case PSBTError::SIGHASH_MISMATCH:
342 case TransactionError::MEMPOOL_REJECTED:
344 case TransactionError::ALREADY_IN_CHAIN:
358 const std::string &err_string) {
359 if (err_string.length() > 0) {
372 Section(
const std::string &left,
const std::string &right)
394 void Push(
const RPCArg &arg,
const size_t current_indent = 5,
396 const auto indent = std::string(current_indent,
' ');
397 const auto indent_next = std::string(current_indent + 2,
' ');
412 if (is_top_level_arg) {
435 {indent + (push_name ?
"\"" + arg.
GetName() +
"\": " :
"") +
438 for (
const auto &arg_inner : arg.
m_inner) {
444 PushSection({indent +
"}" + (is_top_level_arg ?
"" :
","),
""});
449 left += push_name ?
"\"" + arg.
GetName() +
"\": " :
"";
456 for (
const auto &arg_inner : arg.
m_inner) {
460 PushSection({indent +
"]" + (is_top_level_arg ?
"" :
","),
""});
477 if (s.m_right.empty()) {
483 std::string left = s.m_left;
484 left.resize(pad,
' ');
490 size_t new_line_pos = s.m_right.find_first_of(
'\n');
492 right += s.m_right.substr(begin, new_line_pos - begin);
493 if (new_line_pos == std::string::npos) {
497 right +=
"\n" + std::string(pad,
' ');
498 begin = s.m_right.find_first_not_of(
' ', new_line_pos + 1);
499 if (begin == std::string::npos) {
502 new_line_pos = s.m_right.find_first_of(
'\n', begin + 1);
515 std::move(results),
std::move(examples), nullptr} {}
520 : m_name{
std::move(name_)}, m_fun{
std::move(fun)},
521 m_description{
std::move(description)}, m_args{
std::move(args)},
522 m_results{
std::move(results)}, m_examples{
std::move(examples)} {
526 enum ParamType { POSITIONAL = 1, NAMED = 2, NAMED_ONLY = 4 };
527 std::map<std::string, int> param_names;
529 for (
const auto &arg :
m_args) {
530 std::vector<std::string> names =
SplitString(arg.m_names,
'|');
532 for (
const std::string &
name : names) {
533 auto ¶m_type = param_names[
name];
536 param_type |= POSITIONAL;
539 for (
const auto &inner : arg.m_inner) {
540 std::vector<std::string> inner_names =
542 for (
const std::string &inner_name : inner_names) {
543 auto ¶m_type = param_names[inner_name];
545 inner.m_opts.also_positional);
549 inner.m_opts.also_positional ? NAMED : NAMED_ONLY;
554 if (arg.m_fallback.index() == 2) {
556 switch (std::get<RPCArg::Default>(arg.m_fallback).getType()) {
595 if (r.m_cond.empty()) {
596 result +=
"\nResult:\n";
598 result +=
"\nResult (" + r.m_cond +
"):\n";
601 r.ToSections(sections);
622 throw std::runtime_error(
ToString());
625 for (
size_t i{0}; i <
m_args.size(); ++i) {
626 const auto &arg{
m_args.at(i)};
628 if (!match.isTrue()) {
630 strprintf(
"Position %s (%s)", i + 1, arg.m_names),
634 if (!arg_mismatch.empty()) {
636 arg_mismatch.write(4)));
645 UniValue match{res.MatchesType(ret)};
646 if (match.isTrue()) {
650 mismatch.push_back(std::move(match));
652 if (!mismatch.isNull()) {
653 std::string explain{mismatch.empty() ?
"no possible results defined"
654 : mismatch.size() == 1 ? mismatch[0].write(4)
655 : mismatch.write(4)};
657 "Internal bug detected: RPC call \"%s\" returned incorrect "
658 "type:\n%s\n%s %s\nPlease report this issue here: %s\n",
668 const std::vector<RPCArg> ¶ms,
672 const RPCArg ¶m{params.at(i)};
680 if (!std::holds_alternative<RPCArg::Default>(param.m_fallback)) {
683 return &std::get<RPCArg::Default>(param.m_fallback);
689 std::holds_alternative<RPCArg::Optional>(param.
m_fallback) &&
694 std::holds_alternative<RPCArg::Default>(param.
m_fallback));
697#define TMPL_INST(check_param, ret_type, return_code) \
698 template <> ret_type RPCHelpMan::ArgValue<ret_type>(size_t i) const { \
699 const UniValue *maybe_arg{ \
700 DetailMaybeArg(check_param, m_args, m_req, i), \
704 void force_semicolon(ret_type)
709 maybe_arg ? std::optional{maybe_arg->get_real()} : std::nullopt;);
711 maybe_arg ? std::optional{maybe_arg->get_bool()} : std::nullopt;);
713 maybe_arg ? &maybe_arg->get_str() :
nullptr;);
725 size_t num_required_args = 0;
726 for (
size_t n =
m_args.size(); n > 0; --n) {
727 if (!
m_args.at(n - 1).IsOptional()) {
728 num_required_args = n;
732 return num_required_args <= num_args && num_args <=
m_args.size();
736 std::vector<std::pair<std::string, bool>> ret;
737 ret.reserve(
m_args.size());
738 for (
const auto &arg :
m_args) {
740 for (
const auto &inner : arg.m_inner) {
741 ret.emplace_back(inner.m_names,
true);
744 ret.emplace_back(arg.m_names,
false);
750 auto it{std::find_if(
m_args.begin(),
m_args.end(), [&key](
const auto &arg) {
751 return arg.GetName() == key;
756 return std::distance(
m_args.begin(), it);
764 bool was_optional{
false};
765 for (
const auto &arg :
m_args) {
766 if (arg.m_opts.hidden) {
770 const bool optional = arg.IsOptional();
781 was_optional =
false;
783 ret += arg.ToString(
true);
796 for (
size_t i{0}; i <
m_args.size(); ++i) {
797 const auto &arg =
m_args.at(i);
798 if (arg.m_opts.hidden) {
806 arg.ToDescriptionString(
true));
815 for (
const auto &arg_inner : arg.m_inner) {
817 {arg_inner.GetFirstName(),
818 arg_inner.ToDescriptionString(
true)});
819 named_only_sections.
Push(arg_inner);
825 ret +=
"\nArguments:\n";
828 if (!named_only_sections.
m_sections.empty()) {
829 ret +=
"\nNamed Arguments:\n";
831 ret += named_only_sections.
ToString();
845 auto push_back_arg_info = [&arr](
const std::string &rpc_name,
int pos,
846 const std::string &arg_name,
849 map.push_back(rpc_name);
851 map.push_back(arg_name);
854 arr.push_back(std::move(map));
857 for (
int i{0}; i < int(
m_args.size()); ++i) {
858 const auto &arg =
m_args.at(i);
859 std::vector<std::string> arg_names =
SplitString(arg.m_names,
'|');
860 for (
const auto &arg_name : arg_names) {
861 push_back_arg_info(
m_name, i, arg_name, arg.m_type);
863 for (
const auto &inner : arg.m_inner) {
864 std::vector<std::string> inner_names =
866 for (
const std::string &inner_name : inner_names) {
867 push_back_arg_info(
m_name, i, inner_name, inner.m_type);
898 case Type::OBJ_NAMED_PARAMS:
899 case Type::OBJ_USER_KEYS: {
922 if (*exp_type != request.
getType()) {
923 return strprintf(
"JSON value of type %s is not of expected type %s",
963 ret +=
"numeric or string";
967 ret +=
"numeric or array";
977 ret +=
"json object";
988 ", optional, default=" + std::get<RPCArg::DefaultHint>(
m_fallback);
990 ret +=
", optional, default=" +
991 std::get<RPCArg::Default>(
m_fallback).write();
993 switch (std::get<RPCArg::Optional>(
m_fallback)) {
1003 ret +=
", required";
1010 ret +=
" Options object that can be used to pass named arguments, "
1018 const int current_indent)
const {
1020 const std::string indent(current_indent,
' ');
1021 const std::string indent_next(current_indent + 2,
' ');
1025 const std::string maybe_separator{outer_type !=
OuterType::NONE ?
"," :
""};
1028 const std::string maybe_key{
1032 const auto Description = [&](
const std::string &type) {
1033 return "(" + type + (this->
m_optional ?
", optional" :
"") +
")" +
1050 {indent +
"null" + maybe_separator, Description(
"json null")});
1055 {indent + maybe_key +
"\"str\"" + maybe_separator,
1056 Description(
"string")});
1060 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator,
1061 Description(
"numeric")});
1066 {indent + maybe_key +
"\"hex\"" + maybe_separator,
1067 Description(
"string")});
1071 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator,
1072 Description(
"numeric")});
1076 sections.
PushSection({indent + maybe_key +
"xxx" + maybe_separator,
1077 Description(
"numeric")});
1082 {indent + maybe_key +
"true|false" + maybe_separator,
1083 Description(
"boolean")});
1089 {indent + maybe_key +
"[", Description(
"json array")});
1090 for (
const auto &i :
m_inner) {
1098 sections.
m_sections.back().m_left.pop_back();
1100 sections.
PushSection({indent +
"]" + maybe_separator,
""});
1107 Description(
"empty JSON object")});
1111 {indent + maybe_key +
"{", Description(
"json object")});
1112 for (
const auto &i :
m_inner) {
1122 sections.
m_sections.back().m_left.pop_back();
1124 sections.
PushSection({indent +
"}" + maybe_separator,
""});
1136 return std::nullopt;
1142 case Type::STR_HEX: {
1146 case Type::STR_AMOUNT:
1147 case Type::NUM_TIME: {
1153 case Type::ARR_FIXED:
1176 if (*exp_type != result.
getType()) {
1177 return strprintf(
"returned type is %s, but declared as %s in doc",
1183 for (
size_t i{0}; i < result.
get_array().size(); ++i) {
1189 if (!match.isTrue()) {
1193 if (errors.
empty()) {
1208 for (
size_t i{0}; i < result.
get_obj().size(); ++i) {
1210 if (!match.isTrue()) {
1214 if (errors.
empty()) {
1220 std::set<std::string> doc_keys;
1221 for (
const auto &doc_entry :
m_inner) {
1222 doc_keys.insert(doc_entry.m_key_name);
1224 std::map<std::string, UniValue> result_obj;
1226 for (
const auto &result_entry : result_obj) {
1227 if (doc_keys.find(result_entry.first) == doc_keys.end()) {
1228 errors.
pushKV(result_entry.first,
1229 "key returned that was not in doc");
1233 for (
const auto &doc_entry :
m_inner) {
1234 const auto result_it{result_obj.find(doc_entry.m_key_name)};
1235 if (result_it == result_obj.end()) {
1236 if (!doc_entry.m_optional) {
1238 doc_entry.m_key_name,
1239 "key missing, despite not being optional in doc");
1243 UniValue match{doc_entry.MatchesType(result_it->second)};
1244 if (!match.isTrue()) {
1245 errors.
pushKV(doc_entry.m_key_name, std::move(match));
1248 if (errors.
empty()) {
1279 return res +
"\"str\"";
1281 return res +
"\"hex\"";
1285 return res +
"n or [n,n]";
1287 return res +
"amount";
1289 return res +
"bool";
1292 for (
const auto &i :
m_inner) {
1293 res += i.ToString(oneline) +
",";
1295 return res +
"...]";
1305 return res +
"unknown";
1331 return "{" + res +
"}";
1333 return "{" + res +
",...}";
1338 for (
const auto &i :
m_inner) {
1339 res += i.ToString(oneline) +
",";
1341 return "[" + res +
"...]";
1348 if (value.
isNum()) {
1349 return {0, value.
getInt<int64_t>()};
1353 int64_t low = value[0].
getInt<int64_t>();
1354 int64_t high = value[1].
getInt<int64_t>();
1358 "Range specified as [begin,end] must not have begin after end");
1363 "Range must be specified as end or as [begin,end]");
1371 "Range should be greater or equal than 0");
1373 if ((high >> 31) != 0) {
1376 if (high >= low + 1000000) {
1385 std::string desc_str;
1386 std::pair<int64_t, int64_t> range = {0, 1000};
1387 if (scanobject.
isStr()) {
1388 desc_str = scanobject.
get_str();
1389 }
else if (scanobject.
isObject()) {
1391 if (desc_uni.isNull()) {
1394 "Descriptor needs to be provided in scan object");
1396 desc_str = desc_uni.get_str();
1398 if (!range_uni.isNull()) {
1404 "Scan object needs to be either a string or an object");
1408 auto desc =
Parse(desc_str, provider, error);
1412 if (!desc->IsRange()) {
1416 std::vector<CScript> ret;
1417 for (
int i = range.first; i <= range.second; ++i) {
1418 std::vector<CScript> scripts;
1419 if (!desc->Expand(i, provider, scripts, provider)) {
1422 strprintf(
"Cannot derive script without private keys: '%s'",
1425 std::move(scripts.begin(), scripts.end(), std::back_inserter(ret));
1437 return servicesNames;
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
bool MoneyRange(const Amount nValue)
static constexpr Amount SATOSHI
#define CHECK_NONFATAL(condition)
Identity function.
#define NONFATAL_UNREACHABLE()
NONFATAL_UNREACHABLE() is a macro that is used to mark unreachable code.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
DescribeAddressVisitor()=default
UniValue operator()(const CNoDestination &dest) const
UniValue operator()(const ScriptHash &scriptID) const
UniValue operator()(const PKHash &keyID) const
Fillable signing provider that keeps keys in an address->secret map.
virtual bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
enum JSONRPCRequest::Mode mode
const RPCExamples m_examples
size_t GetParamIndex(std::string_view key) const
Return positional index of a parameter using its name as key.
RPCHelpMan(std::string name, std::string description, std::vector< RPCArg > args, RPCResults results, RPCExamples examples)
const std::string m_description
bool IsValidNumArgs(size_t num_args) const
If the supplied number of args is neither too small nor too high.
std::function< UniValue(const RPCHelpMan &, const Config &config, const JSONRPCRequest &)> RPCMethodImpl
const RPCMethodImpl m_fun
const RPCResults m_results
UniValue HandleRequest(const Config &config, const JSONRPCRequest &request) const
const std::vector< RPCArg > m_args
std::string ToString() const
UniValue GetArgMap() const
Return the named args that need to be converted from string to another JSON type.
std::vector< std::pair< std::string, bool > > GetArgNames() const
Return list of arguments and whether they are named-only.
const JSONRPCRequest * m_req
A pointer to the request for the duration of m_fun()
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
enum VType getType() const
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
const std::string & getValStr() const
const UniValue & get_obj() const
const std::vector< std::string > & getKeys() const
const UniValue & get_array() const
void pushKV(std::string key, UniValue val)
void getObjMap(std::map< std::string, UniValue > &kv) const
constexpr bool IsNull() const
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
std::string FormatFullVersion()
is a home for simple enum and struct type definitions that can be used internally by functions in the...
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
bilingual_str PSBTErrorString(PSBTError err)
bilingual_str TransactionErrorString(const TransactionError error)
Implement std::hash so RCUPtr can be used as a key for maps or sets.
std::vector< std::string > SplitString(std::string_view str, char sep)
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
is a home for public enum and struct type definitions that are used by internally by node code,...
CTxDestination AddAndGetDestinationForScript(FillableSigningProvider &keystore, const CScript &script, OutputType type)
Get a destination of the requested type (if possible) to the specified script.
std::vector< std::string > serviceFlagsToStr(const uint64_t flags)
Convert service flags (a bitmask of NODE_*) to human readable strings.
ServiceFlags
nServices flags.
UniValue JSONRPCError(int code, const std::string &message)
RPCErrorCode
Bitcoin RPC error codes.
@ RPC_TRANSACTION_ALREADY_IN_CHAIN
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
@ RPC_TRANSACTION_REJECTED
@ RPC_TRANSACTION_ERROR
Aliases for backward compatibility.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
static const UniValue * DetailMaybeArg(CheckFn *check, const std::vector< RPCArg > ¶ms, const JSONRPCRequest *req, size_t i)
std::pair< int64_t, int64_t > ParseDescriptorRange(const UniValue &value)
Parse a JSON range specified as int64, or [int64, int64].
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
UniValue GetServicesNames(ServiceFlags services)
Returns, given services flags, a list of humanly readable (known) network services.
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
RPCErrorCode RPCErrorFromPSBTError(PSBTError err)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
Amount AmountFromValue(const UniValue &value)
#define TMPL_INST(check_param, ret_type, return_code)
std::vector< uint8_t > ParseHexV(const UniValue &v, std::string strName)
UniValue JSONRPCPSBTError(PSBTError err)
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
void(const RPCArg &) CheckFn
const std::string EXAMPLE_ADDRESS
Example CashAddr address used in multiple RPCExamples.
static std::optional< UniValue::VType > ExpectedType(RPCArg::Type type)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::vector< CScript > EvalDescriptorStringOrObject(const UniValue &scanobject, FlatSigningProvider &provider)
Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range ...
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
std::string GetAllOutputTypes()
CPubKey HexToPubKey(const std::string &hex_in)
CPubKey AddrToPubKey(const CChainParams &chainparams, const FillableSigningProvider &keystore, const std::string &addr_in)
uint256 ParseHashO(const UniValue &o, std::string strKey)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
static std::pair< int64_t, int64_t > ParseRange(const UniValue &value)
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Check for expected keys/value types in an Object.
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
static void CheckRequiredOrDefault(const RPCArg ¶m)
UniValue DescribeAddress(const CTxDestination &dest)
std::vector< uint8_t > ParseHexO(const UniValue &o, std::string strKey)
std::vector< std::pair< std::string, UniValue > > RPCArgList
static constexpr bool DEFAULT_RPC_DOC_CHECK
OuterType
Serializing JSON objects depends on the outer type.
static const unsigned int MAX_SCRIPT_ELEMENT_SIZE
CKeyID GetKeyForDestination(const SigningProvider &store, const CTxDestination &dest)
Return the CKeyID of the key involved in a script (if there is a unique one).
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
static const Currency & get()
@ RANGE
Special type that is a NUM or [NUM,NUM].
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g.
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
@ OBJ_NAMED_PARAMS
Special type that behaves almost exactly like OBJ, defining an options object with a list of pre-defi...
const std::vector< RPCArg > m_inner
Only used for arrays or dicts.
const RPCArgOptions m_opts
const std::string m_names
The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for nam...
const Fallback m_fallback
std::string ToString(bool oneline) const
Return the type string of the argument.
UniValue MatchesType(const UniValue &request) const
Check whether the request JSON type matches.
const std::string m_description
std::string ToDescriptionString(bool is_named_arg) const
Return the description string, including the argument type and whether the argument is required.
std::string GetName() const
Return the name, throws when there are aliases.
std::string GetFirstName() const
Return the first of all aliases.
std::string ToStringObj(bool oneline) const
Return the type string of the argument when it is in an object (dict).
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
std::vector< std::string > type_str
Should be empty unless it is supposed to override the auto-generated type strings.
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
std::string ToDescriptionString() const
const std::string m_examples
const std::string m_description
void ToSections(Sections §ions, OuterType outer_type=OuterType::NONE, const int current_indent=0) const
Append the sections of the result.
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ANY
Special type to disable type checks (for testing only)
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
const std::vector< RPCResult > m_inner
Only used for arrays or dicts.
UniValue MatchesType(const UniValue &result) const
Check whether the result JSON type matches.
void CheckInnerDoc() const
const std::string m_key_name
Only used for dicts.
const bool m_skip_type_check
std::string ToDescriptionString() const
Return the description string.
const std::vector< RPCResult > m_results
A pair of strings that can be aligned (through padding) with other Sections later on.
Section(const std::string &left, const std::string &right)
const std::string m_right
Keeps track of RPCArgs by transforming them into sections for the purpose of serializing everything t...
void PushSection(const Section &s)
std::vector< Section > m_sections
void Push(const RPCArg &arg, const size_t current_indent=5, const OuterType outer_type=OuterType::NONE)
Recursive helper to translate an RPCArg into sections.
std::string ToString() const
Concatenate all sections with proper padding.
uint256 uint256S(std::string_view str)
DEPRECATED.
const char * uvTypeName(UniValue::VType t)
template std::vector< std::byte > ParseHex(std::string_view)
bool ParseFixedPoint(std::string_view val, int decimals, int64_t *amount_out)
Parse number as fixed point according to JSON number syntax.
bool IsHex(std::string_view str)
Returns true if each character in str is a hex character, and has an even number of hex digits.