Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
501template <typename R>502auto MaybeArg(std::string_view key) const503{504auto i{GetParamIndex(key)};505// Return optional argument (without default).506if constexpr (std::is_trivially_copyable_v<R>) {507// Return trivially copyable types by value, wrapped in optional.508return ArgValue<std::optional<R>>(i);509} else {510// Return other types by pointer.511return ArgValue<const R*>(i);512}513}514std::string ToString() const;515/** Return the named args that need to be converted from string to another JSON type */516UniValue GetArgMap() const;517/** If the supplied number of args is neither too small nor too high */518bool IsValidNumArgs(size_t num_args) const;519//! Return list of arguments and whether they are named-only.520std::vector<std::pair<std::string, bool>> GetArgNames() const;521const std::string& GetDescription() const { return m_description; }522const std::vector<RPCArg>& GetArgs() const { return m_args; }523const RPCResults& GetResults() const { return m_results; }525const std::string m_name;527private:528const RPCMethodImpl m_fun;529const std::string m_description;530const std::vector<RPCArg> m_args;531const RPCResults m_results;532const RPCExamples m_examples;533mutable const JSONRPCRequest* m_req{nullptr}; // A pointer to the request for the duration of m_fun()534template <typename R>535R ArgValue(size_t i) const;536//! Return positional index of a parameter using its name as key.537size_t GetParamIndex(std::string_view key) const;538};540/**541* Push warning messages to an RPC "warnings" field as a JSON array of strings.542*543* @param[in] warnings Warning messages to push.544* @param[out] obj UniValue object to push the warnings array object to.545*/546void PushWarnings(const UniValue& warnings, UniValue& obj);547void PushWarnings(const std::vector<bilingual_str>& warnings, UniValue& obj);549std::vector<RPCResult> ScriptPubKeyDoc();551/***552* Get the target for a given block index.553*554* @param[in] blockindex the block555* @param[in] pow_limit PoW limit (consensus parameter)556*557* @return the target558*/559uint256 GetTarget(const CBlockIndex& blockindex, uint256 pow_limit);561#endif // BITCOIN_RPC_UTIL_H