File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -74,12 +74,12 @@ void RPCTypeCheckObj(const UniValue& o,
74
74
}
75
75
}
76
76
77
- CAmount AmountFromValue (const UniValue& value)
77
+ CAmount AmountFromValue (const UniValue& value, int decimals )
78
78
{
79
79
if (!value.isNum () && !value.isStr ())
80
80
throw JSONRPCError (RPC_TYPE_ERROR, " Amount is not a number or string" );
81
81
CAmount amount;
82
- if (!ParseFixedPoint (value.getValStr (), 8 , &amount))
82
+ if (!ParseFixedPoint (value.getValStr (), decimals , &amount))
83
83
throw JSONRPCError (RPC_TYPE_ERROR, " Invalid amount" );
84
84
if (!MoneyRange (amount))
85
85
throw JSONRPCError (RPC_TYPE_ERROR, " Amount out of range" );
Original file line number Diff line number Diff line change @@ -77,7 +77,14 @@ extern uint256 ParseHashO(const UniValue& o, std::string strKey);
77
77
extern std::vector<unsigned char > ParseHexV (const UniValue& v, std::string strName);
78
78
extern std::vector<unsigned char > ParseHexO (const UniValue& o, std::string strKey);
79
79
80
- extern CAmount AmountFromValue (const UniValue& value);
80
+ /* *
81
+ * Validate and return a CAmount from a UniValue number or string.
82
+ *
83
+ * @param[in] value UniValue number or string to parse.
84
+ * @param[in] decimals Number of significant digits (default: 8).
85
+ * @returns a CAmount if the various checks pass.
86
+ */
87
+ extern CAmount AmountFromValue (const UniValue& value, int decimals = 8 );
81
88
82
89
using RPCArgList = std::vector<std::pair<std::string, UniValue>>;
83
90
extern std::string HelpExampleCli (const std::string& methodname, const std::string& args);
You can’t perform that action at this time.
0 commit comments