mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
rpc: enable passing decimals to AmountFromValue, add doxygen
This commit is contained in:
parent
8ce3ef57a3
commit
0742c7840f
2 changed files with 10 additions and 3 deletions
|
@ -74,12 +74,12 @@ void RPCTypeCheckObj(const UniValue& o,
|
|||
}
|
||||
}
|
||||
|
||||
CAmount AmountFromValue(const UniValue& value)
|
||||
CAmount AmountFromValue(const UniValue& value, int decimals)
|
||||
{
|
||||
if (!value.isNum() && !value.isStr())
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string");
|
||||
CAmount amount;
|
||||
if (!ParseFixedPoint(value.getValStr(), 8, &amount))
|
||||
if (!ParseFixedPoint(value.getValStr(), decimals, &amount))
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
|
||||
if (!MoneyRange(amount))
|
||||
throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range");
|
||||
|
|
|
@ -77,7 +77,14 @@ extern uint256 ParseHashO(const UniValue& o, std::string strKey);
|
|||
extern std::vector<unsigned char> ParseHexV(const UniValue& v, std::string strName);
|
||||
extern std::vector<unsigned char> ParseHexO(const UniValue& o, std::string strKey);
|
||||
|
||||
extern CAmount AmountFromValue(const UniValue& value);
|
||||
/**
|
||||
* Validate and return a CAmount from a UniValue number or string.
|
||||
*
|
||||
* @param[in] value UniValue number or string to parse.
|
||||
* @param[in] decimals Number of significant digits (default: 8).
|
||||
* @returns a CAmount if the various checks pass.
|
||||
*/
|
||||
extern CAmount AmountFromValue(const UniValue& value, int decimals = 8);
|
||||
|
||||
using RPCArgList = std::vector<std::pair<std::string, UniValue>>;
|
||||
extern std::string HelpExampleCli(const std::string& methodname, const std::string& args);
|
||||
|
|
Loading…
Add table
Reference in a new issue