diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2017-02-03 16:23:01 +0000 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2017-04-10 09:26:03 -0400 |
commit | c99ab3ca4b2363b721d6582cf22d5d41896d1037 (patch) | |
tree | 1c6517bdd05e682f9382138b470c2bbff90b7a37 | |
parent | e19586a8a95502ce0f9fb8319ca6456c2ce161b3 (diff) |
RPC: Allow multiple names for parameters
-rw-r--r-- | src/rpc/server.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5c493428d8..ea93e8cc74 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -22,6 +22,8 @@ #include <boost/signals2/signal.hpp> #include <boost/thread.hpp> #include <boost/algorithm/string/case_conv.hpp> // for to_upper() +#include <boost/algorithm/string/classification.hpp> +#include <boost/algorithm/string/split.hpp> #include <memory> // for unique_ptr #include <unordered_map> @@ -432,8 +434,16 @@ static inline JSONRPCRequest transformNamedArguments(const JSONRPCRequest& in, c } // Process expected parameters. int hole = 0; - for (const std::string &argName: argNames) { - auto fr = argsIn.find(argName); + for (const std::string &argNamePattern: argNames) { + std::vector<std::string> vargNames; + boost::algorithm::split(vargNames, argNamePattern, boost::algorithm::is_any_of("|")); + auto fr = argsIn.end(); + for (const std::string & argName : vargNames) { + fr = argsIn.find(argName); + if (fr != argsIn.end()) { + break; + } + } if (fr != argsIn.end()) { for (int i = 0; i < hole; ++i) { // Fill hole between specified parameters with JSON nulls, |