37 "\"qrmzys48glkpevp2l4t24jtcltc9hyzx9cep2qffm4\"";
40 const std::map<std::string, UniValueType> &typesExpected,
41 bool fAllowNull,
bool fStrict) {
42 for (
const auto &t : typesExpected) {
44 if (!fAllowNull && v.
isNull()) {
49 if (!(t.second.typeAny || v.
type() == t.second.type ||
50 (fAllowNull && v.
isNull()))) {
51 std::string err =
strprintf(
"Expected type %s for %s, got %s",
59 for (
const std::string &k : o.
getKeys()) {
60 if (typesExpected.count(k) == 0) {
61 std::string err =
strprintf(
"Unexpected key %s", k);
87 const std::string &strHex(v.
get_str());
88 if (64 != strHex.length()) {
91 strprintf(
"%s must be of length %d (not %d, for '%s')", strName, 64,
92 strHex.length(), strHex));
97 strName +
" must be hexadecimal string (not '" +
112 if (!
IsHex(strHex)) {
114 strName +
" must be hexadecimal string (not '" +
132std::string ShellQuote(
const std::string &s) {
134 result.reserve(s.size() * 2);
135 for (
const char ch : s) {
142 return "'" + result +
"'";
151std::string ShellQuoteIfNeeded(
const std::string &s) {
152 for (
const char ch : s) {
153 if (ch ==
' ' || ch ==
'\'' || ch ==
'"') {
154 return ShellQuote(s);
164 const std::string &args) {
165 return "> bitcoin-cli " + methodname +
" " + args +
"\n";
170 std::string result =
"> bitcoin-cli -named " + methodname;
171 for (
const auto &argpair : args) {
172 const auto &value = argpair.second.isStr() ? argpair.second.get_str()
173 : argpair.second.write();
174 result +=
" " + argpair.first +
"=" + ShellQuoteIfNeeded(value);
181 const std::string &args) {
182 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", "
183 "\"id\": \"curltest\", "
185 methodname +
"\", \"params\": [" + args +
186 "]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
192 for (
const auto ¶m : args) {
193 params.
pushKV(param.first, param.second);
196 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", "
197 "\"id\": \"curltest\", "
199 methodname +
"\", \"params\": " + params.
write() +
200 "}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
205 if (!
IsHex(hex_in)) {
207 "Invalid public key: " + hex_in);
212 "Invalid public key: " + hex_in);
220 const std::string &addr_in) {
224 "Invalid address: " + addr_in);
229 strprintf(
"%s does not refer to a key", addr_in));
232 if (!keystore.
GetPubKey(key, vchPubKey)) {
235 strprintf(
"no full public key for address %s", addr_in));
239 "Wallet contains an invalid public key");
247 const std::vector<CPubKey> &pubkeys,
250 CScript &script_out) {
255 "a multisignature address must require at least one key to redeem");
257 if ((
int)pubkeys.size() < required) {
259 strprintf(
"not enough keys supplied (got %u keys, "
260 "but need at least %d to redeem)",
261 pubkeys.size(), required));
263 if (pubkeys.size() > 16) {
265 "Number of keys involved in the multisignature "
266 "address creation > 16\nReduce the number");
274 (
strprintf(
"redeemScript exceeds size limit: %d > %d",
279 for (
const CPubKey &pk : pubkeys) {
280 if (!pk.IsCompressed()) {
303 obj.
pushKV(
"isscript",
false);
309 obj.
pushKV(
"isscript",
true);
319 std::vector<std::string> ret;
320 using U = std::underlying_type<TxoutType>::type;
324 return Join(ret,
", ");
329 case PSBTError::UNSUPPORTED:
331 case PSBTError::SIGHASH_MISMATCH:
341 case TransactionError::MEMPOOL_REJECTED:
343 case TransactionError::ALREADY_IN_CHAIN:
357 const std::string &err_string) {
358 if (err_string.length() > 0) {
371 Section(
const std::string &left,
const std::string &right)
393 void Push(
const RPCArg &arg,
const size_t current_indent = 5,
395 const auto indent = std::string(current_indent,
' ');
396 const auto indent_next = std::string(current_indent + 2,
' ');
411 if (is_top_level_arg) {
434 {indent + (push_name ?
"\"" + arg.
GetName() +
"\": " :
"") +
437 for (
const auto &arg_inner : arg.
m_inner) {
443 PushSection({indent +
"}" + (is_top_level_arg ?
"" :
","),
""});
448 left += push_name ?
"\"" + arg.
GetName() +
"\": " :
"";
455 for (
const auto &arg_inner : arg.
m_inner) {
459 PushSection({indent +
"]" + (is_top_level_arg ?
"" :
","),
""});
476 if (s.m_right.empty()) {
482 std::string left = s.m_left;
483 left.resize(pad,
' ');
489 size_t new_line_pos = s.m_right.find_first_of(
'\n');
491 right += s.m_right.substr(begin, new_line_pos - begin);
492 if (new_line_pos == std::string::npos) {
496 right +=
"\n" + std::string(pad,
' ');
497 begin = s.m_right.find_first_not_of(
' ', new_line_pos + 1);
498 if (begin == std::string::npos) {
501 new_line_pos = s.m_right.find_first_of(
'\n', begin + 1);
514 std::move(results),
std::move(examples), nullptr} {}
519 : m_name{
std::move(name_)}, m_fun{
std::move(fun)},
520 m_description{
std::move(description)}, m_args{
std::move(args)},
521 m_results{
std::move(results)}, m_examples{
std::move(examples)} {
525 enum ParamType { POSITIONAL = 1, NAMED = 2, NAMED_ONLY = 4 };
526 std::map<std::string, int> param_names;
528 for (
const auto &arg :
m_args) {
529 std::vector<std::string> names =
SplitString(arg.m_names,
'|');
531 for (
const std::string &
name : names) {
532 auto ¶m_type = param_names[
name];
535 param_type |= POSITIONAL;
538 for (
const auto &inner : arg.m_inner) {
539 std::vector<std::string> inner_names =
541 for (
const std::string &inner_name : inner_names) {
542 auto ¶m_type = param_names[inner_name];
544 inner.m_opts.also_positional);
548 inner.m_opts.also_positional ? NAMED : NAMED_ONLY;
553 if (arg.m_fallback.index() == 2) {
555 switch (std::get<RPCArg::Default>(arg.m_fallback).getType()) {
594 if (r.m_cond.empty()) {
595 result +=
"\nResult:\n";
597 result +=
"\nResult (" + r.m_cond +
"):\n";
600 r.ToSections(sections);
621 throw std::runtime_error(
ToString());
624 for (
size_t i{0}; i <
m_args.size(); ++i) {
625 const auto &arg{
m_args.at(i)};
627 if (!match.isTrue()) {
629 strprintf(
"Position %s (%s)", i + 1, arg.m_names),
633 if (!arg_mismatch.empty()) {
635 arg_mismatch.write(4)));
644 UniValue match{res.MatchesType(ret)};
645 if (match.isTrue()) {
649 mismatch.push_back(std::move(match));
651 if (!mismatch.isNull()) {
652 std::string explain{mismatch.empty() ?
"no possible results defined"
653 : mismatch.size() == 1 ? mismatch[0].write(4)
654 : mismatch.write(4)};
656 "Internal bug detected: RPC call \"%s\" returned incorrect "
657 "type:\n%s\n%s %s\nPlease report this issue here: %s\n",
667 const std::vector<RPCArg> ¶ms,
671 const RPCArg ¶m{params.at(i)};
679 if (!std::holds_alternative<RPCArg::Default>(param.m_fallback)) {
682 return &std::get<RPCArg::Default>(param.m_fallback);
688 std::holds_alternative<RPCArg::Optional>(param.
m_fallback) &&
693 std::holds_alternative<RPCArg::Default>(param.
m_fallback));
696#define TMPL_INST(check_param, ret_type, return_code) \
697 template <> ret_type RPCHelpMan::ArgValue<ret_type>(size_t i) const { \
698 const UniValue *maybe_arg{ \
699 DetailMaybeArg(check_param, m_args, m_req, i), \
703 void force_semicolon(ret_type)
708 maybe_arg ? std::optional{maybe_arg->get_real()} : std::nullopt;);
710 maybe_arg ? std::optional{maybe_arg->get_bool()} : std::nullopt;);
712 maybe_arg ? &maybe_arg->get_str() :
nullptr;);
724 size_t num_required_args = 0;
725 for (
size_t n =
m_args.size(); n > 0; --n) {
726 if (!
m_args.at(n - 1).IsOptional()) {
727 num_required_args = n;
731 return num_required_args <= num_args && num_args <=
m_args.size();
735 std::vector<std::pair<std::string, bool>> ret;
736 ret.reserve(
m_args.size());
737 for (
const auto &arg :
m_args) {
739 for (
const auto &inner : arg.m_inner) {
740 ret.emplace_back(inner.m_names,
true);
743 ret.emplace_back(arg.m_names,
false);
749 auto it{std::find_if(
m_args.begin(),
m_args.end(), [&key](
const auto &arg) {
750 return arg.GetName() == key;
755 return std::distance(
m_args.begin(), it);
763 bool was_optional{
false};
764 for (
const auto &arg :
m_args) {
765 if (arg.m_opts.hidden) {
769 const bool optional = arg.IsOptional();
780 was_optional =
false;
782 ret += arg.ToString(
true);
795 for (
size_t i{0}; i <
m_args.size(); ++i) {
796 const auto &arg =
m_args.at(i);
797 if (arg.m_opts.hidden) {
805 arg.ToDescriptionString(
true));
814 for (
const auto &arg_inner : arg.m_inner) {
816 {arg_inner.GetFirstName(),
817 arg_inner.ToDescriptionString(
true)});
818 named_only_sections.
Push(arg_inner);
824 ret +=
"\nArguments:\n";
827 if (!named_only_sections.
m_sections.empty()) {
828 ret +=
"\nNamed Arguments:\n";
830 ret += named_only_sections.
ToString();
844 auto push_back_arg_info = [&arr](
const std::string &rpc_name,
int pos,
845 const std::string &arg_name,
848 map.push_back(rpc_name);
850 map.push_back(arg_name);
853 arr.push_back(std::move(map));
856 for (
int i{0}; i < int(
m_args.size()); ++i) {
857 const auto &arg =
m_args.at(i);
858 std::vector<std::string> arg_names =
SplitString(arg.m_names,
'|');
859 for (
const auto &arg_name : arg_names) {
860 push_back_arg_info(
m_name, i, arg_name, arg.m_type);
862 for (
const auto &inner : arg.m_inner) {
863 std::vector<std::string> inner_names =
865 for (
const std::string &inner_name : inner_names) {
866 push_back_arg_info(
m_name, i, inner_name, inner.m_type);
897 case Type::OBJ_NAMED_PARAMS:
898 case Type::OBJ_USER_KEYS: {
921 if (*exp_type != request.
getType()) {
922 return strprintf(
"JSON value of type %s is not of expected type %s",
962 ret +=
"numeric or string";
966 ret +=
"numeric or array";
976 ret +=
"json object";
987 ", optional, default=" + std::get<RPCArg::DefaultHint>(
m_fallback);
989 ret +=
", optional, default=" +
990 std::get<RPCArg::Default>(
m_fallback).write();
992 switch (std::get<RPCArg::Optional>(
m_fallback)) {
1002 ret +=
", required";
1009 ret +=
" Options object that can be used to pass named arguments, "
1017 const int current_indent)
const {
1019 const std::string indent(current_indent,
' ');
1020 const std::string indent_next(current_indent + 2,
' ');
1024 const std::string maybe_separator{outer_type !=
OuterType::NONE ?
"," :
""};
1027 const std::string maybe_key{
1031 const auto Description = [&](
const std::string &type) {
1032 return "(" + type + (this->
m_optional ?
", optional" :
"") +
")" +
1049 {indent +
"null" + maybe_separator, Description(
"json null")});
1054 {indent + maybe_key +
"\"str\"" + maybe_separator,
1055 Description(
"string")});
1059 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator,
1060 Description(
"numeric")});
1065 {indent + maybe_key +
"\"hex\"" + maybe_separator,
1066 Description(
"string")});
1070 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator,
1071 Description(
"numeric")});
1075 sections.
PushSection({indent + maybe_key +
"xxx" + maybe_separator,
1076 Description(
"numeric")});
1081 {indent + maybe_key +
"true|false" + maybe_separator,
1082 Description(
"boolean")});
1088 {indent + maybe_key +
"[", Description(
"json array")});
1089 for (
const auto &i :
m_inner) {
1097 sections.
m_sections.back().m_left.pop_back();
1099 sections.
PushSection({indent +
"]" + maybe_separator,
""});
1106 Description(
"empty JSON object")});
1110 {indent + maybe_key +
"{", Description(
"json object")});
1111 for (
const auto &i :
m_inner) {
1121 sections.
m_sections.back().m_left.pop_back();
1123 sections.
PushSection({indent +
"}" + maybe_separator,
""});
1135 return std::nullopt;
1141 case Type::STR_HEX: {
1145 case Type::STR_AMOUNT:
1146 case Type::NUM_TIME: {
1152 case Type::ARR_FIXED:
1175 if (*exp_type != result.
getType()) {
1176 return strprintf(
"returned type is %s, but declared as %s in doc",
1182 for (
size_t i{0}; i < result.
get_array().size(); ++i) {
1188 if (!match.isTrue()) {
1192 if (errors.
empty()) {
1207 for (
size_t i{0}; i < result.
get_obj().size(); ++i) {
1209 if (!match.isTrue()) {
1213 if (errors.
empty()) {
1219 std::set<std::string> doc_keys;
1220 for (
const auto &doc_entry :
m_inner) {
1221 doc_keys.insert(doc_entry.m_key_name);
1223 std::map<std::string, UniValue> result_obj;
1225 for (
const auto &result_entry : result_obj) {
1226 if (doc_keys.find(result_entry.first) == doc_keys.end()) {
1227 errors.
pushKV(result_entry.first,
1228 "key returned that was not in doc");
1232 for (
const auto &doc_entry :
m_inner) {
1233 const auto result_it{result_obj.find(doc_entry.m_key_name)};
1234 if (result_it == result_obj.end()) {
1235 if (!doc_entry.m_optional) {
1237 doc_entry.m_key_name,
1238 "key missing, despite not being optional in doc");
1242 UniValue match{doc_entry.MatchesType(result_it->second)};
1243 if (!match.isTrue()) {
1244 errors.
pushKV(doc_entry.m_key_name, std::move(match));
1247 if (errors.
empty()) {
1278 return res +
"\"str\"";
1280 return res +
"\"hex\"";
1284 return res +
"n or [n,n]";
1286 return res +
"amount";
1288 return res +
"bool";
1291 for (
const auto &i :
m_inner) {
1292 res += i.ToString(oneline) +
",";
1294 return res +
"...]";
1304 return res +
"unknown";
1330 return "{" + res +
"}";
1332 return "{" + res +
",...}";
1337 for (
const auto &i :
m_inner) {
1338 res += i.ToString(oneline) +
",";
1340 return "[" + res +
"...]";
1347 if (value.
isNum()) {
1348 return {0, value.
getInt<int64_t>()};
1352 int64_t low = value[0].
getInt<int64_t>();
1353 int64_t high = value[1].
getInt<int64_t>();
1357 "Range specified as [begin,end] must not have begin after end");
1362 "Range must be specified as end or as [begin,end]");
1370 "Range should be greater or equal than 0");
1372 if ((high >> 31) != 0) {
1375 if (high >= low + 1000000) {
1384 std::string desc_str;
1385 std::pair<int64_t, int64_t> range = {0, 1000};
1386 if (scanobject.
isStr()) {
1387 desc_str = scanobject.
get_str();
1388 }
else if (scanobject.
isObject()) {
1390 if (desc_uni.isNull()) {
1393 "Descriptor needs to be provided in scan object");
1395 desc_str = desc_uni.get_str();
1397 if (!range_uni.isNull()) {
1403 "Scan object needs to be either a string or an object");
1407 auto desc =
Parse(desc_str, provider, error);
1411 if (!desc->IsRange()) {
1415 std::vector<CScript> ret;
1416 for (
int i = range.first; i <= range.second; ++i) {
1417 std::vector<CScript> scripts;
1418 if (!desc->Expand(i, provider, scripts, provider)) {
1421 strprintf(
"Cannot derive script without private keys: '%s'",
1424 std::move(scripts.begin(), scripts.end(), std::back_inserter(ret));
1436 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())
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
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.
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.
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.