RPCMethod::Arg

Helper to get a required or default-valued request argument.

Synopsis

Declared in <rpc/util.h>

template<typename R>
auto
Arg(std::string_view key) const;

Description

Use this function when the argument is required or when it has a default value. If the argument is optional and may not be provided, use MaybeArg instead.

This function only works during m_fun(), i.e., it should only be used in RPC method implementations. It internally checks whether the user-passed argument isNull() and parses (from JSON) and returns the user-passed argument, or the default value derived from the RPCArg documentation.

The instantiation of this helper for type R must match the corresponding RPCArg::Type.

Return Value

The value of the RPC argument (or the default value) cast to type R.

Parameters

NameDescription
keyThe name of the argument to fetch.

See Also

MaybeArg for handling optional arguments without default values.