aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-06-08 14:07:32 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-06-08 14:14:54 +0200
commit75ec320a0d5393c31cccc4cf5a62f3f6b43c8672 (patch)
treea7d0b098f9d8f667c7530afc7520c5b7977abddd /src/rpc
parenta7c41f2de03c315394c0560f369544e24a3e5586 (diff)
parentfa7f4f577cbab2b4bc03b5427704c2ec16680c34 (diff)
downloadbitcoin-75ec320a0d5393c31cccc4cf5a62f3f6b43c8672.tar.xz
Merge #8153: [rpc] fundrawtransaction feeRate: Use BTC/kB
fa7f4f5 [rpc] fundrawtransaction feeRate: Use BTC/kB (MarcoFalke) faf82e8 [rpc] fundrawtransaction: Fix help text and interface (MarcoFalke)
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/rawtransaction.cpp15
-rw-r--r--src/rpc/server.cpp14
-rw-r--r--src/rpc/server.h15
3 files changed, 31 insertions, 13 deletions
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index 4517ffcbbc..992914f88c 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -682,7 +682,12 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
UniValue prevOut = p.get_obj();
- RPCTypeCheckObj(prevOut, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR));
+ RPCTypeCheckObj(prevOut,
+ {
+ {"txid", UniValueType(UniValue::VSTR)},
+ {"vout", UniValueType(UniValue::VNUM)},
+ {"scriptPubKey", UniValueType(UniValue::VSTR)},
+ });
uint256 txid = ParseHashO(prevOut, "txid");
@@ -710,7 +715,13 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
// if redeemScript given and not using the local wallet (private keys
// given), add redeemScript to the tempKeystore so it can be signed:
if (fGivenKeys && scriptPubKey.IsPayToScriptHash()) {
- RPCTypeCheckObj(prevOut, boost::assign::map_list_of("txid", UniValue::VSTR)("vout", UniValue::VNUM)("scriptPubKey", UniValue::VSTR)("redeemScript",UniValue::VSTR));
+ RPCTypeCheckObj(prevOut,
+ {
+ {"txid", UniValueType(UniValue::VSTR)},
+ {"vout", UniValueType(UniValue::VNUM)},
+ {"scriptPubKey", UniValueType(UniValue::VSTR)},
+ {"redeemScript", UniValueType(UniValue::VSTR)},
+ });
UniValue v = find_value(prevOut, "redeemScript");
if (!v.isNull()) {
vector<unsigned char> rsData(ParseHexV(v, "redeemScript"));
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index d06a9142b6..23149baa6d 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -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);
}
}
diff --git a/src/rpc/server.h b/src/rpc/server.h
index b471336617..b5ccc153d0 100644
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -32,6 +32,15 @@ namespace RPCServer
class CBlockIndex;
class CNetAddr;
+/** Wrapper for UniValue::VType, which includes typeAny:
+ * Used to denote don't care type. Only used by RPCTypeCheckObj */
+struct UniValueType {
+ UniValueType(UniValue::VType _type) : typeAny(false), type(_type) {}
+ UniValueType() : typeAny(true) {}
+ bool typeAny;
+ UniValue::VType type;
+};
+
class JSONRequest
{
public:
@@ -60,17 +69,17 @@ bool RPCIsInWarmup(std::string *statusOut);
/**
* Type-check arguments; throws JSONRPCError if wrong type given. Does not check that
* the right number of arguments are passed, just that any passed are the correct type.
- * Use like: RPCTypeCheck(params, boost::assign::list_of(str_type)(int_type)(obj_type));
*/
void RPCTypeCheck(const UniValue& params,
const std::list<UniValue::VType>& typesExpected, bool fAllowNull=false);
/*
Check for expected keys/value types in an Object.
- 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, bool fStrict=false);
+ const std::map<std::string, UniValueType>& 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