diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-02-25 09:29:50 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-02-25 09:31:08 +0100 |
commit | 1a8a5ede9fc334bd97b774670eb340b8665a0aa4 (patch) | |
tree | c3449c48d35f665b8de6da0888e87e2b8a6e62b7 /src/rpc/util.h | |
parent | f3f9c1de19e6d254e0c3a26ce7a3d8cd57fb7641 (diff) | |
parent | fa4ce7038d444defe0b98a30097174c278054a33 (diff) |
Merge #15401: rpc: Actually throw help when passed invalid number of params
fa4ce7038d444defe0b98a30097174c278054a33 rpc: Actually throw help when passed invalid number of params (MarcoFalke)
fa05626ca7a0fe896ac554c79eaea4c36acdf861 rpc: Add RPCHelpMan::IsValidNumArgs() (MarcoFalke)
Pull request description:
Can be tested by
* running the included test against an old binary (compiled without this patch)
* calling `setban 1 "add" 3 4 5 6 7 8 9 0` in the gui
Tree-SHA512: aa6a25bbe6f40722913ea292252a62a4012c964eed9f4035335a2e2d13be98eb60f368e8a3251a104a26a62c08b2cb926b06e5ab1418ef1cf4abdd71d87c2919
Diffstat (limited to 'src/rpc/util.h')
-rw-r--r-- | src/rpc/util.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/rpc/util.h b/src/rpc/util.h index a83ae98b7e..06800ad63c 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 The Bitcoin Core developers +// Copyright (c) 2017-2019 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -54,7 +54,7 @@ struct RPCArg { /** Required arg */ NO, /** - * Optinal arg that is a named argument and has a default value of + * Optional arg that is a named argument and has a default value of * `null`. When possible, the default value should be specified. */ OMITTED_NAMED_ARG, @@ -111,6 +111,8 @@ struct RPCArg { assert(type == Type::ARR || type == Type::OBJ); } + bool IsOptional() const; + /** * Return the type string of the argument. * Set oneline to allow it to be overridden by a custom oneline type string (m_oneline_description). @@ -186,6 +188,8 @@ public: RPCHelpMan(std::string name, std::string description, std::vector<RPCArg> args, RPCResults results, RPCExamples examples); std::string ToString() const; + /** If the supplied number of args is neither too small nor too high */ + bool IsValidNumArgs(size_t num_args) const; private: const std::string m_name; |