[rpc] fundrawtransaction feeRate: Use BTC/kB

Also introduce UniValueType

UniValueType is a wrapper for UniValue::VType which allows setting
a typeAny flag. This flag indicates the type does not matter.

(Used by RPCTypeCheckObj)
This commit is contained in:
MarcoFalke
2016-06-06 17:50:50 +02:00
parent faf82e8fc8
commit fa7f4f577c
5 changed files with 50 additions and 20 deletions

View File

@@ -88,20 +88,18 @@ void RPCTypeCheck(const UniValue& params,
}
void RPCTypeCheckObj(const UniValue& o,
const map<string, UniValue::VType>& typesExpected,
bool fAllowNull,
bool fStrict)
const map<string, UniValueType>& typesExpected,
bool fAllowNull,
bool fStrict)
{
BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected)
{
for (const auto& t : typesExpected) {
const UniValue& v = find_value(o, t.first);
if (!fAllowNull && v.isNull())
throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
if (!((v.type() == t.second) || (fAllowNull && (v.isNull()))))
{
if (!(t.second.typeAny || v.type() == t.second.type || (fAllowNull && v.isNull()))) {
string err = strprintf("Expected type %s for %s, got %s",
uvTypeName(t.second), t.first, uvTypeName(v.type()));
uvTypeName(t.second.type), t.first, uvTypeName(v.type()));
throw JSONRPCError(RPC_TYPE_ERROR, err);
}
}