Skip to content

Commit 72b9452

Browse files
committed
When processing RPC commands during warmup phase, parse the
request object before returning an error so that id value can be used in the response. Prior to this commit, RPC commands sent during Bitcoin's warmup/startup phase were responded to with a JSON-RPC error with an id of null, which violated the JSON-RPC 2.0 spec: id: This member is REQUIRED. It MUST be the same as the value of the id member in the Request Object. If there was an error in detecting the id in the Request object (e.g. Parse error/Invalid Request), it MUST be Null.
1 parent 6bcb0a2 commit 72b9452

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/rpcserver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -930,13 +930,6 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
930930
if (!valRequest.read(strRequest))
931931
throw JSONRPCError(RPC_PARSE_ERROR, "Parse error");
932932

933-
// Return immediately if in warmup
934-
{
935-
LOCK(cs_rpcWarmup);
936-
if (fRPCInWarmup)
937-
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
938-
}
939-
940933
string strReply;
941934

942935
// singleton request
@@ -1008,6 +1001,13 @@ void ServiceConnection(AcceptedConnection *conn)
10081001

10091002
UniValue CRPCTable::execute(const std::string &strMethod, const UniValue &params) const
10101003
{
1004+
// Return immediately if in warmup
1005+
{
1006+
LOCK(cs_rpcWarmup);
1007+
if (fRPCInWarmup)
1008+
throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus);
1009+
}
1010+
10111011
// Find method
10121012
const CRPCCommand *pcmd = tableRPC[strMethod];
10131013
if (!pcmd)

0 commit comments

Comments
 (0)