Skip to content

Commit edafc71

Browse files
committed
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 <[email protected]> bitcoin/bitcoin#11257 Request URI is not used for anything except multiwallet request dispatching, so this change has no other effects. Fixes #11257
1 parent b4a509a commit edafc71

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/httprpc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
192192

193193
// array of requests
194194
} else if (valRequest.isArray())
195-
strReply = JSONRPCExecBatch(valRequest.get_array());
195+
strReply = JSONRPCExecBatch(jreq, valRequest.get_array());
196196
else
197197
throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error");
198198

src/rpc/server.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,10 @@ bool IsDeprecatedRPCEnabled(const std::string& method)
389389
return find(enabled_methods.begin(), enabled_methods.end(), method) != enabled_methods.end();
390390
}
391391

392-
static UniValue JSONRPCExecOne(const UniValue& req)
392+
static UniValue JSONRPCExecOne(JSONRPCRequest jreq, const UniValue& req)
393393
{
394394
UniValue rpc_result(UniValue::VOBJ);
395395

396-
JSONRPCRequest jreq;
397396
try {
398397
jreq.parse(req);
399398

@@ -413,11 +412,11 @@ static UniValue JSONRPCExecOne(const UniValue& req)
413412
return rpc_result;
414413
}
415414

416-
std::string JSONRPCExecBatch(const UniValue& vReq)
415+
std::string JSONRPCExecBatch(const JSONRPCRequest& jreq, const UniValue& vReq)
417416
{
418417
UniValue ret(UniValue::VARR);
419418
for (unsigned int reqIdx = 0; reqIdx < vReq.size(); reqIdx++)
420-
ret.push_back(JSONRPCExecOne(vReq[reqIdx]));
419+
ret.push_back(JSONRPCExecOne(jreq, vReq[reqIdx]));
421420

422421
return ret.write() + "\n";
423422
}

src/rpc/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ extern std::string HelpExampleRpc(const std::string& methodname, const std::stri
191191
bool StartRPC();
192192
void InterruptRPC();
193193
void StopRPC();
194-
std::string JSONRPCExecBatch(const UniValue& vReq);
194+
std::string JSONRPCExecBatch(const JSONRPCRequest& jreq, const UniValue& vReq);
195195

196196
// Retrieves any serialization flags requested in command line argument
197197
int RPCSerializationFlags();

0 commit comments

Comments
 (0)