From 244e6c8db8102b66c6044d109bce4ff8c7d880d6 Mon Sep 17 00:00:00 2001 From: Brotcrunsher Date: Sun, 4 Jun 2023 02:06:11 +0200 Subject: [PATCH] CLI: Only one Request Handler can be specified. Previously it was possible to specify multiple, however only one was picked in this arbitrary and (probably) undocumented priority: getinfo > netinfo > generate > addrinfo. --- src/bitcoin-cli.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 45db7a9a66..ab8f0bc7d8 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -1170,6 +1170,14 @@ static int CommandLineRPC(int argc, char *argv[]) fputc('\n', stdout); } } + int nRh = 0; + if (gArgs.IsArgSet("-getinfo")) nRh++; + if (gArgs.GetBoolArg("-netinfo", false)) nRh++; + if (gArgs.GetBoolArg("-generate", false)) nRh++; + if (gArgs.GetBoolArg("-addrinfo", false)) nRh++; + if (nRh > 1) { + throw std::runtime_error("Only one of \"-getinfo\", \"-netinfo\", \"-generate\", and \"-addrinfo\" may be specified."); + } std::unique_ptr rh; std::string method; if (gArgs.IsArgSet("-getinfo")) {