aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Zipkin <pinheadmz@gmail.com>2024-06-06 10:25:48 -0400
committerMatthew Zipkin <pinheadmz@gmail.com>2024-06-07 09:26:55 -0400
commit391843b0297db03d71a8d88ab77609e2ad230bf2 (patch)
tree2e46338e53581a7aa0c6f5a823b36030facaacf7
parentd39bdf339772166a5545ae811e58b7764af093a8 (diff)
downloadbitcoin-391843b0297db03d71a8d88ab77609e2ad230bf2.tar.xz
bitcoin-cli: use json-rpc 2.0
-rw-r--r--src/bitcoin-cli.cpp8
-rw-r--r--src/rpc/request.cpp1
-rw-r--r--src/rpc/request.h1
3 files changed, 6 insertions, 4 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index cc639d8793..4c7f3717f6 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -298,7 +298,7 @@ public:
}
addresses.pushKV("total", total);
result.pushKV("addresses_known", std::move(addresses));
- return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V1_LEGACY);
+ return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V2);
}
};
@@ -367,7 +367,7 @@ public:
}
result.pushKV("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]);
result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]);
- return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V1_LEGACY);
+ return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V2);
}
};
@@ -622,7 +622,7 @@ public:
}
}
- return JSONRPCReplyObj(UniValue{result}, NullUniValue, /*id=*/1, JSONRPCVersion::V1_LEGACY);
+ return JSONRPCReplyObj(UniValue{result}, NullUniValue, /*id=*/1, JSONRPCVersion::V2);
}
const std::string m_help_doc{
@@ -709,7 +709,7 @@ public:
UniValue result(UniValue::VOBJ);
result.pushKV("address", address_str);
result.pushKV("blocks", reply.get_obj()["result"]);
- return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V1_LEGACY);
+ return JSONRPCReplyObj(std::move(result), NullUniValue, /*id=*/1, JSONRPCVersion::V2);
}
protected:
std::string address_str;
diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp
index d35782189e..87b9f18b33 100644
--- a/src/rpc/request.cpp
+++ b/src/rpc/request.cpp
@@ -45,6 +45,7 @@ UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params,
request.pushKV("method", strMethod);
request.pushKV("params", params);
request.pushKV("id", id);
+ request.pushKV("jsonrpc", "2.0");
return request;
}
diff --git a/src/rpc/request.h b/src/rpc/request.h
index e47f90af86..9968426636 100644
--- a/src/rpc/request.h
+++ b/src/rpc/request.h
@@ -17,6 +17,7 @@ enum class JSONRPCVersion {
V2
};
+/** JSON-RPC 2.0 request, only used in bitcoin-cli **/
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
UniValue JSONRPCReplyObj(UniValue result, UniValue error, std::optional<UniValue> id, JSONRPCVersion jsonrpc_version);
UniValue JSONRPCError(int code, const std::string& message);