rpc: enable passing decimals to AmountFromValue, add doxygen

This commit is contained in:
Jon Atack
2021-04-27 10:54:44 +02:00
parent 8ce3ef57a3
commit 0742c7840f
2 changed files with 10 additions and 3 deletions

View File

@@ -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");