diff options
| author | Wladimir J. van der Laan <[email protected]> | 2017-01-19 19:59:19 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-01-19 19:59:24 +0100 |
| commit | 2ef52d3cf11bd3b1117da8a7affcf9fcfd133767 (patch) | |
| tree | fc1634d32639bde0be2883125fd22adbb5511394 /src/rpc | |
| parent | Merge #9498: Basic CCheckQueue Benchmarks (diff) | |
| parent | [RPC] bumpfee (diff) | |
| download | discoin-2ef52d3cf11bd3b1117da8a7affcf9fcfd133767.tar.xz discoin-2ef52d3cf11bd3b1117da8a7affcf9fcfd133767.zip | |
Merge #8456: [RPC] Simplified bumpfee command.
cc0243a [RPC] bumpfee (mrbandrews)
52dde66 [wallet] Add include_unsafe argument to listunspent RPC (Russell Yanofsky)
766e8a4 [wallet] Add IsAllFromMe: true if all inputs are from wallet (Suhas Daftuar)
Diffstat (limited to 'src/rpc')
| -rw-r--r-- | src/rpc/client.cpp | 1 | ||||
| -rw-r--r-- | src/rpc/server.cpp | 14 | ||||
| -rw-r--r-- | src/rpc/server.h | 5 |
3 files changed, 15 insertions, 5 deletions
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 5d3c45845..5bdd84e55 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -117,6 +117,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "setnetworkactive", 0, "state" }, { "getmempoolancestors", 1, "verbose" }, { "getmempooldescendants", 1, "verbose" }, + { "bumpfee", 1, "options" }, // Echo with conversion (For testing only) { "echojson", 0, "arg0" }, { "echojson", 1, "arg1" }, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 1b94e1007..283d458c8 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -79,16 +79,20 @@ void RPCTypeCheck(const UniValue& params, break; const UniValue& v = params[i]; - if (!((v.type() == t) || (fAllowNull && (v.isNull())))) - { - string err = strprintf("Expected type %s, got %s", - uvTypeName(t), uvTypeName(v.type())); - throw JSONRPCError(RPC_TYPE_ERROR, err); + if (!(fAllowNull && v.isNull())) { + RPCTypeCheckArgument(v, t); } i++; } } +void RPCTypeCheckArgument(const UniValue& value, UniValue::VType typeExpected) +{ + if (value.type() != typeExpected) { + throw JSONRPCError(RPC_TYPE_ERROR, strprintf("Expected type %s, got %s", uvTypeName(typeExpected), uvTypeName(value.type()))); + } +} + void RPCTypeCheckObj(const UniValue& o, const map<string, UniValueType>& typesExpected, bool fAllowNull, diff --git a/src/rpc/server.h b/src/rpc/server.h index fed3d8c90..52f82866d 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -78,6 +78,11 @@ bool RPCIsInWarmup(std::string *statusOut); void RPCTypeCheck(const UniValue& params, const std::list<UniValue::VType>& typesExpected, bool fAllowNull=false); +/** + * Type-check one argument; throws JSONRPCError if wrong type given. + */ +void RPCTypeCheckArgument(const UniValue& value, UniValue::VType typeExpected); + /* Check for expected keys/value types in an Object. */ |