5 #if defined(HAVE_CONFIG_H)
27 #include <string_view>
31 const std::string
EXAMPLE_ADDRESS[2] = {
"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl",
"bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3"};
35 std::vector<std::string>
ret;
36 using U = std::underlying_type<TxoutType>::type;
44 const std::map<std::string, UniValueType>& typesExpected,
48 for (
const auto&
t : typesExpected) {
50 if (!fAllowNull && v.
isNull())
53 if (!(
t.second.typeAny || v.
type() ==
t.second.type || (fAllowNull && v.
isNull())))
59 for (
const std::string&
k : o.
getKeys())
61 if (typesExpected.count(
k) == 0)
63 std::string err =
strprintf(
"Unexpected key %s",
k);
91 const std::string& strHex(v.
get_str());
92 if (64 != strHex.length())
123 std::string ShellQuote(
const std::string& s)
126 result.reserve(s.size() * 2);
127 for (
const char ch: s) {
134 return "'" + result +
"'";
142 std::string ShellQuoteIfNeeded(
const std::string& s)
144 for (
const char ch: s) {
145 if (ch ==
' ' || ch ==
'\'' || ch ==
'"') {
146 return ShellQuote(s);
157 return "> bitcoin-cli " + methodname +
" " +
args +
"\n";
162 std::string result =
"> bitcoin-cli -named " + methodname;
163 for (
const auto& argpair:
args) {
164 const auto& value = argpair.second.isStr()
165 ? argpair.second.get_str()
166 : argpair.second.write();
167 result +=
" " + argpair.first +
"=" + ShellQuoteIfNeeded(value);
175 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", "
176 "\"method\": \"" + methodname +
"\", \"params\": [" +
args +
"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
182 for (
const auto& param:
args) {
183 params.
pushKV(param.first, param.second);
186 return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", "
187 "\"method\": \"" + methodname +
"\", \"params\": " + params.
write() +
"}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
193 if (!
IsHex(hex_in)) {
215 if (!keystore.
GetPubKey(key, vchPubKey)) {
231 if ((
int)pubkeys.size() < required) {
242 if (!
pk.IsCompressed()) {
276 obj.
pushKV(
"isscript",
false);
277 obj.
pushKV(
"iswitness",
false);
284 obj.
pushKV(
"isscript",
true);
285 obj.
pushKV(
"iswitness",
false);
292 obj.
pushKV(
"isscript",
false);
293 obj.
pushKV(
"iswitness",
true);
294 obj.
pushKV(
"witness_version", 0);
302 obj.
pushKV(
"isscript",
true);
303 obj.
pushKV(
"iswitness",
true);
304 obj.
pushKV(
"witness_version", 0);
312 obj.
pushKV(
"isscript",
true);
313 obj.
pushKV(
"iswitness",
true);
314 obj.
pushKV(
"witness_version", 1);
322 obj.
pushKV(
"iswitness",
true);
323 obj.
pushKV(
"witness_version",
id.GetWitnessVersion());
324 obj.
pushKV(
"witness_program",
HexStr(
id.GetWitnessProgram()));
348 return result.value();
353 const int target{value.
getInt<
int>()};
354 const unsigned int unsigned_target{
static_cast<unsigned int>(target)};
355 if (target < 1 || unsigned_target > max_target) {
358 return unsigned_target;
382 if (err_string.length() > 0) {
394 Section(
const std::string& left,
const std::string& right)
420 const auto indent = std::string(current_indent,
' ');
421 const auto indent_next = std::string(current_indent + 2,
' ');
433 if (is_top_level_arg)
return;
447 PushSection({indent + (push_name ?
"\"" + arg.
GetName() +
"\": " :
"") +
"{", right});
448 for (
const auto& arg_inner : arg.
m_inner) {
454 PushSection({indent +
"}" + (is_top_level_arg ?
"" :
","),
""});
459 left += push_name ?
"\"" + arg.
GetName() +
"\": " :
"";
463 for (
const auto& arg_inner : arg.
m_inner) {
467 PushSection({indent +
"]" + (is_top_level_arg ?
"" :
","),
""});
484 if (s.m_right.empty()) {
490 std::string left = s.m_left;
491 left.resize(pad,
' ');
497 size_t new_line_pos = s.m_right.find_first_of(
'\n');
499 right += s.m_right.substr(begin, new_line_pos - begin);
500 if (new_line_pos == std::string::npos) {
503 right +=
"\n" + std::string(pad,
' ');
504 begin = s.m_right.find_first_not_of(
' ', new_line_pos + 1);
505 if (begin == std::string::npos) {
508 new_line_pos = s.m_right.find_first_of(
'\n', begin + 1);
522 m_fun{
std::move(fun)},
523 m_description{
std::move(description)},
525 m_results{
std::move(results)},
526 m_examples{
std::move(examples)}
531 enum ParamType { POSITIONAL = 1, NAMED = 2, NAMED_ONLY = 4 };
532 std::map<std::string, int> param_names;
534 for (
const auto& arg :
m_args) {
535 std::vector<std::string> names =
SplitString(arg.m_names,
'|');
537 for (
const std::string&
name : names) {
538 auto& param_type = param_names[
name];
541 param_type |= POSITIONAL;
544 for (
const auto& inner : arg.m_inner) {
545 std::vector<std::string> inner_names =
SplitString(inner.m_names,
'|');
546 for (
const std::string& inner_name : inner_names) {
547 auto& param_type = param_names[inner_name];
548 CHECK_NONFATAL(!(param_type & POSITIONAL) || inner.m_opts.also_positional);
551 param_type |= inner.m_opts.also_positional ? NAMED : NAMED_ONLY;
556 if (arg.m_fallback.index() == 2) {
558 switch (std::get<RPCArg::Default>(arg.m_fallback).getType()) {
590 if (r.m_cond.empty()) {
591 result +=
"\nResult:\n";
593 result +=
"\nResult (" + r.m_cond +
"):\n";
596 r.ToSections(sections);
617 throw std::runtime_error(
ToString());
620 for (
size_t i{0}; i <
m_args.size(); ++i) {
621 const auto& arg{
m_args.at(i)};
623 if (!match.isTrue()) {
624 arg_mismatch.
pushKV(
strprintf(
"Position %s (%s)", i + 1, arg.m_names), std::move(match));
627 if (!arg_mismatch.empty()) {
638 if (match.isTrue()) {
642 mismatch.push_back(match);
644 if (!mismatch.isNull()) {
646 mismatch.empty() ?
"no possible results defined" :
647 mismatch.size() == 1 ? mismatch[0].write(4) :
649 throw std::runtime_error{
650 strprintf(
"Internal bug detected: RPC call \"%s\" returned incorrect type:\n%s\n%s %s\nPlease report this issue here: %s\n",
664 const RPCArg& param{params.at(i)};
665 if (check) check(param);
667 if (!arg.isNull())
return &arg;
668 if (!std::holds_alternative<RPCArg::Default>(param.m_fallback))
return nullptr;
669 return &std::get<RPCArg::Default>(param.m_fallback);
681 #define TMPL_INST(check_param, ret_type, return_code) \
683 ret_type RPCHelpMan::ArgValue<ret_type>(size_t i) const \
685 const UniValue* maybe_arg{ \
686 DetailMaybeArg(check_param, m_args, m_req, i), \
690 void force_semicolon(ret_type)
694 TMPL_INST(
nullptr, std::optional<double>, maybe_arg ? std::optional{maybe_arg->get_real()} : std::nullopt;);
695 TMPL_INST(
nullptr, std::optional<bool>, maybe_arg ? std::optional{maybe_arg->get_bool()} : std::nullopt;);
696 TMPL_INST(
nullptr,
const std::string*, maybe_arg ? &maybe_arg->get_str() :
nullptr;);
707 size_t num_required_args = 0;
708 for (
size_t n =
m_args.size(); n > 0; --n) {
709 if (!
m_args.at(n - 1).IsOptional()) {
710 num_required_args = n;
714 return num_required_args <= num_args && num_args <=
m_args.size();
719 std::vector<std::pair<std::string, bool>>
ret;
721 for (
const auto& arg :
m_args) {
723 for (
const auto& inner : arg.m_inner) {
724 ret.emplace_back(inner.m_names,
true);
727 ret.emplace_back(arg.m_names,
false);
738 bool was_optional{
false};
739 for (
const auto& arg :
m_args) {
740 if (arg.m_opts.hidden)
break;
741 const bool optional = arg.IsOptional();
744 if (!was_optional)
ret +=
"( ";
747 if (was_optional)
ret +=
") ";
748 was_optional =
false;
750 ret += arg.ToString(
true);
752 if (was_optional)
ret +=
" )";
760 for (
size_t i{0}; i <
m_args.size(); ++i) {
761 const auto& arg =
m_args.at(i);
762 if (arg.m_opts.hidden)
break;
765 sections.
m_sections.emplace_back(::
ToString(i + 1) +
". " + arg.GetFirstName(), arg.ToDescriptionString(
true));
773 for (
const auto& arg_inner : arg.m_inner) {
774 named_only_sections.
PushSection({arg_inner.GetFirstName(), arg_inner.ToDescriptionString(
true)});
775 named_only_sections.
Push(arg_inner);
782 if (!named_only_sections.
m_sections.empty())
ret +=
"\nNamed Arguments:\n";
798 auto push_back_arg_info = [&arr](
const std::string& rpc_name,
int pos,
const std::string& arg_name,
const RPCArg::Type& type) {
800 map.push_back(rpc_name);
802 map.push_back(arg_name);
808 for (
int i{0}; i < int(
m_args.size()); ++i) {
809 const auto& arg =
m_args.at(i);
810 std::vector<std::string> arg_names =
SplitString(arg.m_names,
'|');
811 for (
const auto& arg_name : arg_names) {
812 push_back_arg_info(
m_name, i, arg_name, arg.m_type);
814 for (
const auto& inner : arg.m_inner) {
815 std::vector<std::string> inner_names =
SplitString(inner.m_names,
'|');
816 for (
const std::string& inner_name : inner_names) {
817 push_back_arg_info(
m_name, i, inner_name, inner.m_type);
849 case Type::OBJ_NAMED_PARAMS:
850 case Type::OBJ_USER_KEYS: {
865 if (!exp_type)
return true;
867 if (*exp_type != request.
getType()) {
911 ret +=
"numeric or string";
915 ret +=
"numeric or array";
925 ret +=
"json object";
935 ret +=
", optional, default=" + std::get<RPCArg::DefaultHint>(
m_fallback);
937 ret +=
", optional, default=" + std::get<RPCArg::Default>(
m_fallback).write();
939 switch (std::get<RPCArg::Optional>(
m_fallback)) {
941 if (is_named_arg)
ret +=
", optional";
961 const std::string indent(current_indent,
' ');
962 const std::string indent_next(current_indent + 2,
' ');
965 const std::string maybe_separator{outer_type !=
OuterType::NONE ?
"," :
""};
968 const std::string maybe_key{
974 const auto Description = [&](
const std::string& type) {
975 return "(" + type + (this->
m_optional ?
", optional" :
"") +
")" +
989 sections.
PushSection({indent +
"null" + maybe_separator, Description(
"json null")});
993 sections.
PushSection({indent + maybe_key +
"\"str\"" + maybe_separator, Description(
"string")});
997 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator, Description(
"numeric")});
1001 sections.
PushSection({indent + maybe_key +
"\"hex\"" + maybe_separator, Description(
"string")});
1005 sections.
PushSection({indent + maybe_key +
"n" + maybe_separator, Description(
"numeric")});
1009 sections.
PushSection({indent + maybe_key +
"xxx" + maybe_separator, Description(
"numeric")});
1013 sections.
PushSection({indent + maybe_key +
"true|false" + maybe_separator, Description(
"boolean")});
1018 sections.
PushSection({indent + maybe_key +
"[", Description(
"json array")});
1019 for (
const auto& i :
m_inner) {
1027 sections.
m_sections.back().m_left.pop_back();
1029 sections.
PushSection({indent +
"]" + maybe_separator,
""});
1035 sections.
PushSection({indent + maybe_key +
"{}", Description(
"empty JSON object")});
1038 sections.
PushSection({indent + maybe_key +
"{", Description(
"json object")});
1039 for (
const auto& i :
m_inner) {
1047 sections.
m_sections.back().m_left.pop_back();
1049 sections.
PushSection({indent +
"}" + maybe_separator,
""});
1062 return std::nullopt;
1068 case Type::STR_HEX: {
1072 case Type::STR_AMOUNT:
1073 case Type::NUM_TIME: {
1079 case Type::ARR_FIXED:
1099 if (!exp_type)
return true;
1101 if (*exp_type != result.
getType()) {
1107 for (
size_t i{0}; i < result.
get_array().size(); ++i) {
1113 if (errors.
empty())
return true;
1122 for (
size_t i{0}; i < result.
get_obj().size(); ++i) {
1124 if (!match.isTrue()) errors.
pushKV(result.
getKeys()[i], match);
1126 if (errors.
empty())
return true;
1129 std::set<std::string> doc_keys;
1130 for (
const auto& doc_entry :
m_inner) {
1131 doc_keys.insert(doc_entry.m_key_name);
1133 std::map<std::string, UniValue> result_obj;
1135 for (
const auto& result_entry : result_obj) {
1136 if (doc_keys.find(result_entry.first) == doc_keys.end()) {
1137 errors.
pushKV(result_entry.first,
"key returned that was not in doc");
1141 for (
const auto& doc_entry :
m_inner) {
1142 const auto result_it{result_obj.find(doc_entry.m_key_name)};
1143 if (result_it == result_obj.end()) {
1144 if (!doc_entry.m_optional) {
1145 errors.
pushKV(doc_entry.m_key_name,
"key missing, despite not being optional in doc");
1149 UniValue match{doc_entry.MatchesType(result_it->second)};
1150 if (!match.isTrue()) errors.
pushKV(doc_entry.m_key_name, match);
1152 if (errors.
empty())
return true;
1183 return res +
"\"str\"";
1185 return res +
"\"hex\"";
1189 return res +
"n or [n,n]";
1191 return res +
"amount";
1193 return res +
"bool";
1196 for (
const auto& i :
m_inner) {
1197 res += i.ToString(oneline) +
",";
1199 return res +
"...]";
1214 throw std::runtime_error{
1239 return "{" + res +
"}";
1241 return "{" + res +
",...}";
1246 for (
const auto& i :
m_inner) {
1247 res += i.ToString(oneline) +
",";
1249 return "[" + res +
"...]";
1257 if (value.
isNum()) {
1258 return {0, value.
getInt<int64_t>()};
1261 int64_t low = value[0].
getInt<int64_t>();
1262 int64_t high = value[1].
getInt<int64_t>();
1276 if ((high >> 31) != 0) {
1279 if (high >= low + 1000000) {
1287 std::string desc_str;
1288 std::pair<int64_t, int64_t> range = {0, 1000};
1289 if (scanobject.
isStr()) {
1290 desc_str = scanobject.
get_str();
1291 }
else if (scanobject.
isObject()) {
1294 desc_str = desc_uni.get_str();
1296 if (!range_uni.isNull()) {
1304 auto desc =
Parse(desc_str, provider, error);
1308 if (!desc->IsRange()) {
1312 std::vector<CScript>
ret;
1313 for (
int i = range.first; i <= range.second; ++i) {
1314 std::vector<CScript> scripts;
1315 if (!desc->Expand(i, provider, scripts, provider)) {
1319 desc->ExpandPrivate(i, provider, provider);
1321 std::move(scripts.begin(), scripts.end(), std::back_inserter(
ret));
1331 for (
const auto& s : bilingual_strings) {
1332 result.push_back(s.original);
1339 if (warnings.
empty())
return;
1340 obj.
pushKV(
"warnings", warnings);
1345 if (warnings.empty())
return;
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
#define PACKAGE_BUGREPORT
#define CHECK_NONFATAL(condition)
Identity function.
#define NONFATAL_UNREACHABLE()
NONFATAL_UNREACHABLE() is a macro that is used to mark unreachable code.
#define STR_INTERNAL_BUG(msg)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
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())
Serialized script, used inside transaction inputs and outputs.
UniValue operator()(const WitnessUnknown &id) const
UniValue operator()(const WitnessV0KeyHash &id) const
UniValue operator()(const WitnessV0ScriptHash &id) const
DescribeAddressVisitor()=default
UniValue operator()(const CNoDestination &dest) const
UniValue operator()(const PubKeyDestination &dest) const
UniValue operator()(const WitnessV1Taproot &tap) 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
std::function< UniValue(const RPCHelpMan &, const JSONRPCRequest &)> RPCMethodImpl
const RPCExamples m_examples
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.
const RPCMethodImpl m_fun
const RPCResults m_results
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
UniValue HandleRequest(const JSONRPCRequest &request) const
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 UniValue & get_obj() const
const std::string & getValStr() 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()
util::Result< int > SighashFromStr(const std::string &sighash)
bilingual_str TransactionErrorString(const TransactionError err)
@ SIGHASH_DEFAULT
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
char const * json() noexcept
Template to generate JSON data.
bilingual_str ErrorString(const Result< T > &result)
CTxDestination AddAndGetDestinationForScript(FillableSigningProvider &keystore, const CScript &script, OutputType type)
Get a destination of the requested type (if possible) to the specified script.
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.
std::pair< int64_t, int64_t > ParseDescriptorRange(const UniValue &value)
Parse a JSON range specified as int64, or [int64, int64].
void(const RPCArg &) CheckFn
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
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)
CAmount AmountFromValue(const UniValue &value, int decimals)
Validate and return a CAmount from a UniValue number or string.
static UniValue BilingualStringsToUniValue(const std::vector< bilingual_str > &bilingual_strings)
Convert a vector of bilingual strings to a UniValue::VARR containing their original untranslated valu...
static std::optional< UniValue::VType > ExpectedType(RPCArg::Type type)
void PushWarnings(const UniValue &warnings, UniValue &obj)
Push warning messages to an RPC "warnings" field as a JSON array of strings.
int ParseSighashString(const UniValue &sighash)
Returns a sighash value corresponding to the passed in argument.
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
#define TMPL_INST(check_param, ret_type, return_code)
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
static const UniValue * DetailMaybeArg(CheckFn *check, const std::vector< RPCArg > ¶ms, const JSONRPCRequest *req, size_t i)
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string_view strKey)
CFeeRate ParseFeeRate(const UniValue &json)
Parse a json number or string, denoting BTC/kvB, into a CFeeRate (sat/kvB).
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string_view name)
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()
Gets all existing output types formatted for RPC help sections.
CPubKey HexToPubKey(const std::string &hex_in)
std::vector< CScript > EvalDescriptorStringOrObject(const UniValue &scanobject, FlatSigningProvider &provider, const bool expand_priv)
Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range ...
const std::string EXAMPLE_ADDRESS[2]
Example bech32 addresses for the RPCExamples help documentation.
uint256 ParseHashO(const UniValue &o, std::string_view strKey)
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
static std::pair< int64_t, int64_t > ParseRange(const UniValue &value)
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
uint256 ParseHashV(const UniValue &v, std::string_view name)
Utilities: convert hex-encoded Values (throws error if not hex).
static void CheckRequiredOrDefault(const RPCArg ¶m)
CPubKey AddrToPubKey(const FillableSigningProvider &keystore, const std::string &addr_in)
UniValue DescribeAddress(const CTxDestination &dest)
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
static const int MAX_PUBKEYS_PER_MULTISIG
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.
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
std::string TrimString(std::string_view str, std::string_view pattern=" \f\n\r\t\v")
std::vector< std::string > SplitString(std::string_view str, char sep)
auto Join(const C &container, const S &separator, UnaryOp unary_op)
Join all container items.
@ RANGE
Special type that is a NUM or [NUM,NUM].
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e....
@ 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.
CTxDestination subtype to encode any future Witness version.
uint256 uint256S(const char *str)
const char * uvTypeName(UniValue::VType t)
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
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)