diff options
| author | Wladimir J. van der Laan <[email protected]> | 2016-04-15 16:23:16 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2016-04-15 16:24:02 +0200 |
| commit | be14ca5e8c0f0e8cd8ef511ccb9c41f245d62fbf (patch) | |
| tree | dc4ecb77376030b326930abc247133766aee5e9b /src/rpc | |
| parent | Merge #7870: [contrib] Add MarcoFalke key and move all keys to contrib/gitian... (diff) | |
| parent | Add lockUnspents option to fundrawtransaction (diff) | |
| download | discoin-be14ca5e8c0f0e8cd8ef511ccb9c41f245d62fbf.tar.xz discoin-be14ca5e8c0f0e8cd8ef511ccb9c41f245d62fbf.zip | |
Merge #7518: Add multiple options to fundrawtransaction
f2d0944 Add lockUnspents option to fundrawtransaction (João Barbosa)
af4fe7f Add change options to fundrawtransaction (João Barbosa)
41e835d Add strict flag to RPCTypeCheckObj (João Barbosa)
Diffstat (limited to 'src/rpc')
| -rw-r--r-- | src/rpc/server.cpp | 15 | ||||
| -rw-r--r-- | src/rpc/server.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 8326fe14d..d06a9142b 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -89,7 +89,8 @@ void RPCTypeCheck(const UniValue& params, void RPCTypeCheckObj(const UniValue& o, const map<string, UniValue::VType>& typesExpected, - bool fAllowNull) + bool fAllowNull, + bool fStrict) { BOOST_FOREACH(const PAIRTYPE(string, UniValue::VType)& t, typesExpected) { @@ -104,6 +105,18 @@ void RPCTypeCheckObj(const UniValue& o, throw JSONRPCError(RPC_TYPE_ERROR, err); } } + + if (fStrict) + { + BOOST_FOREACH(const string& k, o.getKeys()) + { + if (typesExpected.count(k) == 0) + { + string err = strprintf("Unexpected key %s", k); + throw JSONRPCError(RPC_TYPE_ERROR, err); + } + } + } } CAmount AmountFromValue(const UniValue& value) diff --git a/src/rpc/server.h b/src/rpc/server.h index a7ed710ce..b47133661 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -70,7 +70,7 @@ void RPCTypeCheck(const UniValue& params, Use like: RPCTypeCheckObj(object, boost::assign::map_list_of("name", str_type)("value", int_type)); */ void RPCTypeCheckObj(const UniValue& o, - const std::map<std::string, UniValue::VType>& typesExpected, bool fAllowNull=false); + const std::map<std::string, UniValue::VType>& typesExpected, bool fAllowNull=false, bool fStrict=false); /** Opaque base class for timers returned by NewTimerFunc. * This provides no methods at the moment, but makes sure that delete |