diff options
author | Russell Yanofsky <russ@yanofsky.org> | 2017-08-14 19:44:02 -0400 |
---|---|---|
committer | Russell Yanofsky <russ@yanofsky.org> | 2017-08-14 19:44:02 -0400 |
commit | e067673f4ea7a74b7251282b48ea9ca57416533a (patch) | |
tree | 9106b1044e0e734a76b417742f3c305a42ac9707 /src/rpc/net.cpp | |
parent | e666efcdba527a58175f9de3357dd19bb5880178 (diff) |
Avoid treating null RPC arguments different from missing arguments
This changes RPC methods to treat null arguments the same as missing arguments,
instead of throwing type errors. Specifically:
- `getbalance` method now returns the wallet balance when the `account` param
is null instead of throwing a type error (same as when parameter is missing).
It is still an error to supply `minconf` or `watchonly` options when the
account is null.
- `addnode` and `setban` methods now return help text instead of type errors if
`command` params are null (same as when params are missing).
- `sendrawtransaction`, `setaccount`, `movecmd`, `sendfrom`,
`addmultisigaddress`, `listaccounts`, `lockunspent` methods accept null
default values where missing values were previously allowed, and treat them
the same.
Diffstat (limited to 'src/rpc/net.cpp')
-rw-r--r-- | src/rpc/net.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index e6b210a199..f19b968244 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -193,7 +193,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request) UniValue addnode(const JSONRPCRequest& request) { std::string strCommand; - if (request.params.size() == 2) + if (!request.params[1].isNull()) strCommand = request.params[1].get_str(); if (request.fHelp || request.params.size() != 2 || (strCommand != "onetry" && strCommand != "add" && strCommand != "remove")) @@ -490,7 +490,7 @@ UniValue getnetworkinfo(const JSONRPCRequest& request) UniValue setban(const JSONRPCRequest& request) { std::string strCommand; - if (request.params.size() >= 2) + if (!request.params[1].isNull()) strCommand = request.params[1].get_str(); if (request.fHelp || request.params.size() < 2 || (strCommand != "add" && strCommand != "remove")) |