 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
5 #ifndef BITCOIN_RPC_UTIL_H
6 #define BITCOIN_RPC_UTIL_H
56 const std::list<UniValueType>& typesExpected,
bool fAllowNull=
false);
67 const std::map<std::string, UniValueType>& typesExpected,
68 bool fAllowNull =
false,
69 bool fStrict =
false);
89 using RPCArgList = std::vector<std::pair<std::string, UniValue>>;
168 const std::string
name,
171 const std::string description,
172 const std::string oneline_description =
"",
173 const std::vector<std::string> type_str = {},
174 const bool hidden =
false)
187 const std::string
name,
190 const std::string description,
191 const std::vector<RPCArg> inner,
192 const std::string oneline_description =
"",
193 const std::vector<std::string> type_str = {})
218 std::string
ToString(
bool oneline)
const;
256 const std::string cond,
260 const std::string description,
261 const std::vector<RPCResult> inner = {})
262 :
m_type{std::move(type)},
274 const std::string cond,
277 const std::string description,
278 const std::vector<RPCResult> inner = {})
285 const std::string description,
286 const std::vector<RPCResult> inner = {})
287 :
m_type{std::move(type)},
300 const std::string description,
301 const std::vector<RPCResult> inner = {})
339 std::string examples)
371 #endif // BITCOIN_RPC_UTIL_H
std::string ToDescriptionString() const
Return the description string, including the result type.
const RPCMethodImpl m_fun
RPCErrorCode RPCErrorFromTransactionError(TransactionError terr)
CPubKey HexToPubKey(const std::string &hex_in)
@ ELISION
Special type to denote elision (...)
std::string ToStringObj(bool oneline) const
Return the type string of the argument when it is in an object (dict).
UniValueType(UniValue::VType _type)
RPCResult(const Type type, const std::string m_key_name, const std::string description, const std::vector< RPCResult > inner={})
const std::string m_oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
void CheckInnerDoc() const
const RPCResults m_results
const std::string EXAMPLE_ADDRESS[2]
Example bech32 addresses for the RPCExamples help documentation.
Fillable signing provider that keeps keys in an address->secret map.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
RPCResults(RPCResult result)
std::function< UniValue(const RPCHelpMan &, const JSONRPCRequest &)> RPCMethodImpl
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
const Fallback m_fallback
const std::string m_key_name
Only used for dicts.
ServiceFlags
nServices flags
RPCResult(const std::string cond, const Type type, const std::string m_key_name, const bool optional, const std::string description, const std::vector< RPCResult > inner={})
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 m_examples
std::pair< int64_t, int64_t > ParseDescriptorRange(const UniValue &value)
Parse a JSON range specified as int64, or [int64, int64].
const std::vector< RPCArg > m_inner
Only used for arrays or dicts.
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e....
const std::vector< RPCResult > m_inner
Only used for arrays or dicts.
UniValue GetServicesNames(ServiceFlags services)
Returns, given services flags, a list of humanly readable (known) network services.
const std::vector< RPCArg > m_args
RPCArg(const std::string name, const Type type, const Fallback fallback, const std::string description, const std::string oneline_description="", const std::vector< std::string > type_str={}, const bool hidden=false)
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
OuterType
Serializing JSON objects depends on the outer type.
void ToSections(Sections §ions, OuterType outer_type=OuterType::NONE, const int current_indent=0) const
Append the sections of the result.
@ ARR_FIXED
Special array that has a fixed number of entries.
RPCResult(const Type type, const std::string m_key_name, const bool optional, const std::string description, const std::vector< RPCResult > inner={})
const RPCExamples m_examples
UniValue GetArgMap() const
Return the named args that need to be converted from string to another JSON type.
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull=false)
Type-check arguments; throws JSONRPCError if wrong type given.
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull=false, bool fStrict=false)
RPCExamples(std::string examples)
std::string ToString() const
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool IsValidNumArgs(size_t num_args) const
If the supplied number of args is neither too small nor too high.
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
std::string ToStringObj() const
Return the type string of the result when it is in an object (dict).
@ STR_HEX
Special type that is a STR with only hex chars.
UniValue HandleRequest(const JSONRPCRequest &request) const
const std::string m_description
std::string ToDescriptionString() const
Return the description string.
const std::string m_description
Keeps track of RPCArgs by transforming them into sections for the purpose of serializing everything t...
@ STR_HEX
Special string with only hex chars.
int64_t CAmount
Amount in satoshis (Can be negative)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
bool MatchesType(const UniValue &result) const
Check whether the result JSON type matches.
RPCResult(const std::string cond, const Type type, const std::string m_key_name, const std::string description, const std::vector< RPCResult > inner={})
RPCHelpMan(std::string name, std::string description, std::vector< RPCArg > args, RPCResults results, RPCExamples examples)
std::string ToDescriptionString() const
@ NUM_TIME
Special numeric to denote unix epoch time.
uint256 ParseHashO(const UniValue &o, std::string strKey)
const std::string m_names
The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for nam...
std::string GetName() const
Return the name, throws when there are aliases.
@ ANY
Special type to disable type checks (for testing only)
Serialized script, used inside transaction inputs and outputs.
const std::vector< std::string > m_type_str
Should be empty unless it is supposed to override the auto-generated type strings....
@ RANGE
Special type that is a NUM or [NUM,NUM].
std::string GetFirstName() const
Return the first of all aliases.
std::vector< std::string > GetArgNames() const
CAmount AmountFromValue(const UniValue &value, int decimals=8)
Validate and return a CAmount from a UniValue number or string.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
An encapsulated public key.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::vector< std::pair< std::string, UniValue > > RPCArgList
std::variant< Optional, DefaultHint, Default > Fallback
RPCErrorCode
Bitcoin RPC error codes.
UniValue DescribeAddress(const CTxDestination &dest)
const std::vector< RPCResult > m_results
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
std::string ToDescriptionString() const
Return the description string, including the argument type and whether the argument is required.
RPCArg(const std::string name, const Type type, const Fallback fallback, const std::string description, const std::vector< RPCArg > inner, const std::string oneline_description="", const std::vector< std::string > type_str={})
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
std::string ToString(bool oneline) const
Return the type string of the argument.
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string="")
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string strKey)
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
@ STR_AMOUNT
Special string to represent a floating point amount.
const std::string m_description
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
CPubKey AddrToPubKey(const FillableSigningProvider &keystore, const std::string &addr_in)
RPCResults(std::initializer_list< RPCResult > results)