Merge adf7843410 into merged_master (Bitcoin PR bitcoin/bitcoin#21786)

This commit is contained in:
Andrew Poelstra 2021-07-08 02:57:17 +00:00
commit 9c4837db05
9 changed files with 129 additions and 41 deletions

View file

@ -79,12 +79,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");