MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / RPCTypeCheckObj

Function RPCTypeCheckObj

src/rpc/server.cpp:76–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void RPCTypeCheckObj(const UniValue& o,
77 const std::map<std::string, UniValueType>& typesExpected,
78 bool fAllowNull,
79 bool fStrict)
80{
81 for (const auto& t : typesExpected) {
82 const UniValue& v = find_value(o, t.first);
83 if (!fAllowNull && v.isNull())
84 throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Missing %s", t.first));
85
86 if (!(t.second.typeAny || v.type() == t.second.type || (fAllowNull && v.isNull()))) {
87 std::string err = strprintf("Expected type %s for %s, got %s",
88 uvTypeName(t.second.type), t.first, uvTypeName(v.type()));
89 throw JSONRPCError(RPC_TYPE_ERROR, err);
90 }
91 }
92
93 if (fStrict)
94 {
95 for (const std::string& k : o.getKeys())
96 {
97 if (typesExpected.count(k) == 0)
98 {
99 std::string err = strprintf("Unexpected key %s", k);
100 throw JSONRPCError(RPC_TYPE_ERROR, err);
101 }
102 }
103 }
104}
105
106CAmount AmountFromValue(const UniValue& value)
107{

Callers 4

lockunspentFunction · 0.85
FundTransactionFunction · 0.85
bumpfeeFunction · 0.85
SignTransactionFunction · 0.85

Calls 5

JSONRPCErrorFunction · 0.85
uvTypeNameFunction · 0.85
isNullMethod · 0.80
typeMethod · 0.80
countMethod · 0.45

Tested by

no test coverage detected