27 "\"qrmzys48glkpevp2l4t24jtcltc9hyzx9cep2qffm4\"";
30 const std::map<std::string, UniValueType> &typesExpected,
31 bool fAllowNull,
bool fStrict) {
32 for (
const auto &t : typesExpected) {
34 if (!fAllowNull && v.
isNull()) {
39 if (!(t.second.typeAny || v.
type() == t.second.type ||
40 (fAllowNull && v.
isNull()))) {
41 std::string err =
strprintf(
"Expected type %s for %s, got %s",
49 for (
const std::string &k : o.
getKeys()) {
50 if (typesExpected.count(k) == 0) {
51 std::string err =
strprintf(
"Unexpected key %s", k);
77 std::string strHex(v.
get_str());
78 if (64 != strHex.length()) {
81 strprintf(
"%s must be of length %d (not %d, for '%s')", strName, 64,
82 strHex.length(), strHex));
87 strName +
" must be hexadecimal string (not '" +
102 if (!
IsHex(strHex)) {
104 strName +
" must be hexadecimal string (not '" +
122std::string ShellQuote(
const std::string &s) {
124 result.reserve(s.size() * 2);
125 for (
const char ch : s) {
132 return "'" + result +
"'";
141std::string ShellQuoteIfNeeded(
const std::string &s) {
142 for (
const char ch : s) {
143 if (ch ==
' ' || ch ==
'\'' || ch ==
'"') {
144 return ShellQuote(s);
154 const std::string &args) {
155 return "> bitcoin-cli " + methodname +
" " + args +
"\n";
160 std::string result =
"> bitcoin-cli -named " + methodname;
161 for (
const auto &argpair : args) {
162 const auto &value = argpair.second.isStr() ? argpair.second.get_str()
163 : argpair.second.write();
164 result +=
" " + argpair.first +
"=" + ShellQuoteIfNeeded(value);
171 const std::string &args) {
172 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", "
173 "\"id\": \"curltest\", "
175 methodname +
"\", \"params\": [" + args +
176 "]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
182 for (
const auto ¶m : args) {
183 params.
pushKV(param.first, param.second);
186 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", "
187 "\"id\": \"curltest\", "
189 methodname +
"\", \"params\": " + params.
write() +
190 "}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
195 if (!
IsHex(hex_in)) {
197 "Invalid public key: " + hex_in);
202 "Invalid public key: " + hex_in);
210 const std::string &addr_in) {
214 "Invalid address: " + addr_in);
219 strprintf(
"%s does not refer to a key", addr_in));
222 if (!keystore.
GetPubKey(key, vchPubKey)) {
225 strprintf(
"no full public key for address %s", addr_in));
229 "Wallet contains an invalid public key");
237 const std::vector<CPubKey> &pubkeys,
240 CScript &script_out) {
245 "a multisignature address must require at least one key to redeem");
247 if ((
int)pubkeys.size() < required) {
249 strprintf(
"not enough keys supplied (got %u keys, "
250 "but need at least %d to redeem)",
251 pubkeys.size(), required));
253 if (pubkeys.size() > 16) {
255 "Number of keys involved in the multisignature "
256 "address creation > 16\nReduce the number");
264 (
strprintf(
"redeemScript exceeds size limit: %d > %d",
269 for (
const CPubKey &pk : pubkeys) {
270 if (!pk.IsCompressed()) {
293 obj.
pushKV(
"isscript",
false);
299 obj.
pushKV(
"isscript",
true);
309 std::vector<std::string> ret;
310 using U = std::underlying_type<TxoutType>::type;
314 return Join(ret,
", ");
337 const std::string &err_string) {
338 if (err_string.length() > 0) {
351 Section(
const std::string &left,
const std::string &right)
373 void Push(
const RPCArg &arg,
const size_t current_indent = 5,
375 const auto indent = std::string(current_indent,
' ');
376 const auto indent_next = std::string(current_indent + 2,
' ');
391 if (is_top_level_arg) {
414 {indent + (push_name ?
"\"" + arg.
GetName() +
"\": " :
"") +
417 for (
const auto &arg_inner : arg.
m_inner) {
423 PushSection({indent +
"}" + (is_top_level_arg ?
"" :
","),
""});
428 left += push_name ?
"\"" + arg.
GetName() +
"\": " :
"";
435 for (
const auto &arg_inner : arg.
m_inner) {
439 PushSection({indent +
"]" + (is_top_level_arg ?
"" :
","),
""});
456 if (s.m_right.empty()) {
462 std::string left = s.m_left;
463 left.resize(pad,
' ');
469 size_t new_line_pos = s.m_right.find_first_of(
'\n');
471 right += s.m_right.substr(begin, new_line_pos - begin);
472 if (new_line_pos == std::string::npos) {
476 right +=
"\n" + std::string(pad,
' ');
477 begin = s.m_right.find_first_not_of(
' ', new_line_pos + 1);
478 if (begin == std::string::npos) {
481 new_line_pos = s.m_right.find_first_of(
'\n', begin + 1);
494 std::move(results),
std::move(examples), nullptr} {}
499 : m_name{
std::move(name_)}, m_fun{
std::move(fun)},
500 m_description{
std::move(description)}, m_args{
std::move(args)},
501 m_results{
std::move(results)}, m_examples{
std::move(examples)} {
505 enum ParamType { POSITIONAL = 1, NAMED = 2, NAMED_ONLY = 4 };
506 std::map<std::string, int> param_names;
508 for (
const auto &arg :
m_args) {
509 std::vector<std::string> names =
SplitString(arg.m_names,
'|');
511 for (
const std::string &
name : names) {
512 auto ¶m_type = param_names[
name];
515 param_type |= POSITIONAL;
518 for (
const auto &inner : arg.m_inner) {
519 std::vector<std::string> inner_names =
521 for (
const std::string &inner_name : inner_names) {
522 auto ¶m_type = param_names[inner_name];
524 inner.m_opts.also_positional);
528 inner.m_opts.also_positional ? NAMED : NAMED_ONLY;
533 if (arg.m_fallback.index() == 2) {
535 switch (std::get<RPCArg::Default>(arg.m_fallback).getType()) {
574 if (r.m_cond.empty()) {
575 result +=
"\nResult:\n";
577 result +=
"\nResult (" + r.m_cond +
"):\n";
580 r.ToSections(sections);
601 throw std::runtime_error(
ToString());
604 for (
size_t i{0}; i <
m_args.size(); ++i) {
605 const auto &arg{
m_args.at(i)};
607 if (!match.isTrue()) {
609 strprintf(
"Position %s (%s)", i + 1, arg.m_names),
613 if (!arg_mismatch.empty()) {
615 arg_mismatch.write(4)));
624 UniValue match{res.MatchesType(ret)};
625 if (match.isTrue()) {
629 mismatch.push_back(match);
631 if (!mismatch.isNull()) {
632 std::string explain{mismatch.empty() ?
"no possible results defined"
633 : mismatch.size() == 1 ? mismatch[0].write(4)
634 : mismatch.write(4)};
636 "Internal bug detected: RPC call \"%s\" returned incorrect "
637 "type:\n%s\n%s %s\nPlease report this issue here: %s\n",
647 const std::vector<RPCArg> ¶ms,
651 const RPCArg ¶m{params.at(i)};
659 if (!std::holds_alternative<RPCArg::Default>(param.m_fallback)) {
662 return &std::get<RPCArg::Default>(param.m_fallback);
668 std::holds_alternative<RPCArg::Optional>(param.
m_fallback) &&
673 std::holds_alternative<RPCArg::Default>(param.
m_fallback));
676#define TMPL_INST(check_param, ret_type, return_code) \
677 template <> ret_type RPCHelpMan::ArgValue<ret_type>(size_t i) const { \
678 const UniValue *maybe_arg{ \
679 DetailMaybeArg(check_param, m_args, m_req, i), \
683 void force_semicolon(ret_type)
688 maybe_arg ? std::optional{maybe_arg->get_real()} : std::nullopt;);
690 maybe_arg ? std::optional{maybe_arg->get_bool()} : std::nullopt;);
692 maybe_arg ? &maybe_arg->get_str() :
nullptr;);
704 size_t num_required_args = 0;
705 for (
size_t n =
m_args.size(); n > 0; --n) {
706 if (!
m_args.at(n - 1).IsOptional()) {
707 num_required_args = n;
711 return num_required_args <= num_args && num_args <=
m_args.size();
715 std::vector<std::pair<std::string, bool>> ret;
716 ret.reserve(
m_args.size());
717 for (
const auto &arg :
m_args) {
719 for (
const auto &inner : arg.m_inner) {
720 ret.emplace_back(inner.m_names,
true);
723 ret.emplace_back(arg.m_names,
false);
729 auto it{std::find_if(
m_args.begin(),
m_args.end(), [&key](
const auto &arg) {
730 return arg.GetName() == key;
735 return std::distance(
m_args.begin(), it);
743 bool was_optional{
false};
744 for (
const auto &arg :
m_args) {
745 if (arg.m_opts.hidden) {
749 const bool optional = arg.IsOptional();
760 was_optional =
false;
762 ret += arg.ToString(
true);
775 for (
size_t i{0}; i <
m_args.size(); ++i) {
776 const auto &arg =
m_args.at(i);
777 if (arg.m_opts.hidden) {
784 ::ToString(i + 1) +
". " + arg.GetFirstName(),
785 arg.ToDescriptionString(
true));
794 for (
const auto &arg_inner : arg.m_inner) {
796 {arg_inner.GetFirstName(),
797 arg_inner.ToDescriptionString(
true)});
798 named_only_sections.
Push(arg_inner);
804 ret +=
"\nArguments:\n";
807 if (!named_only_sections.
m_sections.empty()) {
808 ret +=
"\nNamed Arguments:\n";
810 ret += named_only_sections.
ToString();
824 auto push_back_arg_info = [&arr](
const std::string &rpc_name,
int pos,
825 const std::string &arg_name,
828 map.push_back(rpc_name);
830 map.push_back(arg_name);
836 for (
int i{0}; i < int(
m_args.size()); ++i) {
837 const auto &arg =
m_args.at(i);
838 std::vector<std::string> arg_names =
SplitString(arg.m_names,
'|');
839 for (
const auto &arg_name : arg_names) {
840 push_back_arg_info(
m_name, i, arg_name, arg.m_type);
842 for (
const auto &inner : arg.m_inner) {
843 std::vector<std::string> inner_names =
845 for (
const std::string &inner_name : inner_names) {
846 push_back_arg_info(
m_name, i, inner_name, inner.m_type);
877 case Type::OBJ_NAMED_PARAMS:
878 case Type::OBJ_USER_KEYS: {
901 if (*exp_type != request.
getType()) {
902 return strprintf(
"JSON value of type %s is not of expected type %s",
942 ret +=
"numeric or string";
946 ret +=
"numeric or array";
956 ret +=
"json object";
967 ", optional, default=" + std::get<RPCArg::DefaultHint>(
m_fallback);
969 ret +=
", optional, default=" +
970 std::get<RPCArg::Default>(
m_fallback).write();
972 switch (std::get<RPCArg::Optional>(
m_fallback)) {
989 ret +=
" Options object that can be used to pass named arguments, "
997 const int current_indent)
const {
999 const std::string indent(current_indent,
' ');
1000 const std::string indent_next(current_indent + 2,
' ');
1004 const std::string maybe_separator{outer_type !=
OuterType::NONE ?
"," :
""};
1007 const std::string maybe_key{
1011 const auto Description = [&](
const std::string &type) {
1012 return "(" + type + (this->
m_optional ?
", optional" :
"") +
")" +
1029 {indent +
"null" + maybe_separator, Description(
"json null")});
1034 {indent + maybe_key +
"\"str\"" + maybe_separator,
1035 Description(
"string")});
1039 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator,
1040 Description(
"numeric")});
1045 {indent + maybe_key +
"\"hex\"" + maybe_separator,
1046 Description(
"string")});
1050 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator,
1051 Description(
"numeric")});
1055 sections.
PushSection({indent + maybe_key +
"xxx" + maybe_separator,
1056 Description(
"numeric")});
1061 {indent + maybe_key +
"true|false" + maybe_separator,
1062 Description(
"boolean")});
1068 {indent + maybe_key +
"[", Description(
"json array")});
1069 for (
const auto &i :
m_inner) {
1077 sections.
m_sections.back().m_left.pop_back();
1079 sections.
PushSection({indent +
"]" + maybe_separator,
""});
1086 Description(
"empty JSON object")});
1090 {indent + maybe_key +
"{", Description(
"json object")});
1091 for (
const auto &i :
m_inner) {
1101 sections.
m_sections.back().m_left.pop_back();
1103 sections.
PushSection({indent +
"}" + maybe_separator,
""});
1115 return std::nullopt;
1121 case Type::STR_HEX: {
1125 case Type::STR_AMOUNT:
1126 case Type::NUM_TIME: {
1132 case Type::ARR_FIXED:
1155 if (*exp_type != result.
getType()) {
1156 return strprintf(
"returned type is %s, but declared as %s in doc",
1162 for (
size_t i{0}; i < result.
get_array().size(); ++i) {
1168 if (!match.isTrue()) {
1172 if (errors.
empty()) {
1187 for (
size_t i{0}; i < result.
get_obj().size(); ++i) {
1189 if (!match.isTrue()) {
1193 if (errors.
empty()) {
1199 std::set<std::string> doc_keys;
1200 for (
const auto &doc_entry :
m_inner) {
1201 doc_keys.insert(doc_entry.m_key_name);
1203 std::map<std::string, UniValue> result_obj;
1205 for (
const auto &result_entry : result_obj) {
1206 if (doc_keys.find(result_entry.first) == doc_keys.end()) {
1207 errors.
pushKV(result_entry.first,
1208 "key returned that was not in doc");
1212 for (
const auto &doc_entry :
m_inner) {
1213 const auto result_it{result_obj.find(doc_entry.m_key_name)};
1214 if (result_it == result_obj.end()) {
1215 if (!doc_entry.m_optional) {
1217 doc_entry.m_key_name,
1218 "key missing, despite not being optional in doc");
1222 UniValue match{doc_entry.MatchesType(result_it->second)};
1223 if (!match.isTrue()) {
1224 errors.
pushKV(doc_entry.m_key_name, match);
1227 if (errors.
empty()) {
1258 return res +
"\"str\"";
1260 return res +
"\"hex\"";
1264 return res +
"n or [n,n]";
1266 return res +
"amount";
1268 return res +
"bool";
1271 for (
const auto &i :
m_inner) {
1272 res += i.ToString(oneline) +
",";
1274 return res +
"...]";
1284 return res +
"unknown";
1310 return "{" + res +
"}";
1312 return "{" + res +
",...}";
1317 for (
const auto &i :
m_inner) {
1318 res += i.ToString(oneline) +
",";
1320 return "[" + res +
"...]";
1327 if (value.
isNum()) {
1328 return {0, value.
getInt<int64_t>()};
1332 int64_t low = value[0].
getInt<int64_t>();
1333 int64_t high = value[1].
getInt<int64_t>();
1337 "Range specified as [begin,end] must not have begin after end");
1342 "Range must be specified as end or as [begin,end]");
1350 "Range should be greater or equal than 0");
1352 if ((high >> 31) != 0) {
1355 if (high >= low + 1000000) {
1364 std::string desc_str;
1365 std::pair<int64_t, int64_t> range = {0, 1000};
1366 if (scanobject.
isStr()) {
1367 desc_str = scanobject.
get_str();
1368 }
else if (scanobject.
isObject()) {
1370 if (desc_uni.isNull()) {
1373 "Descriptor needs to be provided in scan object");
1375 desc_str = desc_uni.get_str();
1377 if (!range_uni.isNull()) {
1383 "Scan object needs to be either a string or an object");
1387 auto desc =
Parse(desc_str, provider,
error);
1391 if (!desc->IsRange()) {
1395 std::vector<CScript> ret;
1396 for (
int i = range.first; i <= range.second; ++i) {
1397 std::vector<CScript> scripts;
1398 if (!desc->Expand(i, provider, scripts, provider)) {
1401 strprintf(
"Cannot derive script without private keys: '%s'",
1404 std::move(scripts.begin(), scripts.end(), std::back_inserter(ret));
1416 return servicesNames;
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())
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
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
std::string FormatFullVersion()
bilingual_str TransactionErrorString(const TransactionError error)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
bool error(const char *fmt, const Args &...args)
Implement std::hash so RCUPtr can be used as a key for maps or sets.
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.
@ RPC_CLIENT_P2P_DISABLED
No valid connection manager instance found.
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)
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)
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.
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.
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::vector< std::string > SplitString(std::string_view str, char sep)
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(const char *str)
uint256 from const char *.
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.