diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 4c5acf2bd7e65..c5c15ad665592 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -169,6 +169,15 @@ int ParseInt(const UniValue& o, std::string strKey) return v.get_int(); } +double ParseDoubleV(const UniValue& v, const std::string &strName) +{ + std::string strNum = v.getValStr(); + double num; + if (!ParseDouble(strNum, &num)) + throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be a be number (not '"+strNum+"')"); + return num; +} + bool ParseBool(const UniValue& o, std::string strKey) { const UniValue& v = find_value(o, strKey); diff --git a/src/rpc/server.h b/src/rpc/server.h index c026f9df45b18..32637bfa9a9b8 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -189,6 +189,7 @@ extern std::vector ParseHexV(const UniValue& v, std::string strNa extern std::vector ParseHexO(const UniValue& o, std::string strKey); extern int ParseInt(const UniValue& o, std::string strKey); extern bool ParseBool(const UniValue& o, std::string strKey); +extern double ParseDoubleV(const UniValue& v, const std::string &strName); extern CAmount AmountFromValue(const UniValue& value); extern UniValue ValueFromAmount(const CAmount& amount);