aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-09-07 17:20:26 -0400
committerMarcoFalke <falke.marco@gmail.com>2017-11-03 10:07:59 -0400
commit70268454e857dd89768c73fc4ce90976c3d1a7e6 (patch)
treed004e11942c9d30c880f89a928731c24eeb76d7f
parent6372a7558194e82981cd564d258edac9a8424ba0 (diff)
downloadbitcoin-70268454e857dd89768c73fc4ce90976c3d1a7e6.tar.xz
Fix uninitialized URI in batch RPC requests
This fixes "Wallet file not specified" errors when making batch wallet RPC calls with more than one wallet loaded. This issue was reported by NicolasDorier <nicolas.dorier@gmail.com> https://github.com/bitcoin/bitcoin/issues/11257 Request URI is not used for anything except multiwallet request dispatching, so this change has no other effects. Fixes #11257 Github-Pull: #11277 Rebased-From: edafc718ad071993d10b3b9a1e1828bbd1f8ce54
-rw-r--r--src/httprpc.cpp2
-rw-r--r--src/rpc/server.cpp7
-rw-r--r--src/rpc/server.h2
3 files changed, 5 insertions, 6 deletions
diff --git a/src/httprpc.cpp b/src/httprpc.cpp
index dd219c7291..8836814258 100644
--- a/src/httprpc.cpp
+++ b/src/httprpc.cpp
@@ -192,7 +192,7 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
// array of requests
} else if (valRequest.isArray())
- strReply = JSONRPCExecBatch(valRequest.get_array());
+ strReply = JSONRPCExecBatch(jreq, valRequest.get_array());
else
throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error");
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 9ad8d228fa..db45a9950c 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -387,11 +387,10 @@ void JSONRPCRequest::parse(const UniValue& valRequest)
throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array or object");
}
-static UniValue JSONRPCExecOne(const UniValue& req)
+static UniValue JSONRPCExecOne(JSONRPCRequest jreq, const UniValue& req)
{
UniValue rpc_result(UniValue::VOBJ);
- JSONRPCRequest jreq;
try {
jreq.parse(req);
@@ -411,11 +410,11 @@ static UniValue JSONRPCExecOne(const UniValue& req)
return rpc_result;
}
-std::string JSONRPCExecBatch(const UniValue& vReq)
+std::string JSONRPCExecBatch(const JSONRPCRequest& jreq, const UniValue& vReq)
{
UniValue ret(UniValue::VARR);
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
- ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
+ ret.push_back(JSONRPCExecOne(jreq, vReq[reqIdx]));
return ret.write() + "\n";
}
diff --git a/src/rpc/server.h b/src/rpc/server.h
index dd6f763245..a7fe01e3ef 100644
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -191,7 +191,7 @@ extern std::string HelpExampleRpc(const std::string& methodname, const std::stri
bool StartRPC();
void InterruptRPC();
void StopRPC();
-std::string JSONRPCExecBatch(const UniValue& vReq);
+std::string JSONRPCExecBatch(const JSONRPCRequest& jreq, const UniValue& vReq);
// Retrieves any serialization flags requested in command line argument
int RPCSerializationFlags();