MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / JSONRPCReplyObj

Function JSONRPCReplyObj

src/rpc/request.cpp:51–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51UniValue JSONRPCReplyObj(UniValue result, UniValue error, std::optional<UniValue> id, JSONRPCVersion jsonrpc_version)
52{
53 UniValue reply(UniValue::VOBJ);
54 // Add JSON-RPC version number field in v2 only.
55 if (jsonrpc_version == JSONRPCVersion::V2) reply.pushKV("jsonrpc", "2.0");
56
57 // Add both result and error fields in v1, even though one will be null.
58 // Omit the null field in v2.
59 if (error.isNull()) {
60 reply.pushKV("result", std::move(result));
61 if (jsonrpc_version == JSONRPCVersion::V1_LEGACY) reply.pushKV("error", NullUniValue);
62 } else {
63 if (jsonrpc_version == JSONRPCVersion::V1_LEGACY) reply.pushKV("result", NullUniValue);
64 reply.pushKV("error", std::move(error));
65 }
66 if (id.has_value()) reply.pushKV("id", std::move(id.value()));
67 return reply;
68}
69
70UniValue JSONRPCError(int code, const std::string& message)
71{

Callers 7

JSONErrorReplyFunction · 0.85
ExecuteHTTPRPCFunction · 0.85
ProcessReplyMethod · 0.85
ProcessReplyMethod · 0.85
ProcessReplyMethod · 0.85
ProcessReplyMethod · 0.85
JSONRPCExecFunction · 0.85

Calls 4

pushKVMethod · 0.80
isNullMethod · 0.80
has_valueMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected