mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
bitcoin-cli: use json-rpc 2.0
This commit is contained in:
@@ -298,7 +298,7 @@ public:
|
|||||||
}
|
}
|
||||||
addresses.pushKV("total", total);
|
addresses.pushKV("total", total);
|
||||||
result.pushKV("addresses_known", std::move(addresses));
|
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("relayfee", batch[ID_NETWORKINFO]["result"]["relayfee"]);
|
||||||
result.pushKV("warnings", batch[ID_NETWORKINFO]["result"]["warnings"]);
|
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{
|
const std::string m_help_doc{
|
||||||
@@ -709,7 +709,7 @@ public:
|
|||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
result.pushKV("address", address_str);
|
result.pushKV("address", address_str);
|
||||||
result.pushKV("blocks", reply.get_obj()["result"]);
|
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:
|
protected:
|
||||||
std::string address_str;
|
std::string address_str;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params,
|
|||||||
request.pushKV("method", strMethod);
|
request.pushKV("method", strMethod);
|
||||||
request.pushKV("params", params);
|
request.pushKV("params", params);
|
||||||
request.pushKV("id", id);
|
request.pushKV("id", id);
|
||||||
|
request.pushKV("jsonrpc", "2.0");
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ enum class JSONRPCVersion {
|
|||||||
V2
|
V2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** JSON-RPC 2.0 request, only used in bitcoin-cli **/
|
||||||
UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
|
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 JSONRPCReplyObj(UniValue result, UniValue error, std::optional<UniValue> id, JSONRPCVersion jsonrpc_version);
|
||||||
UniValue JSONRPCError(int code, const std::string& message);
|
UniValue JSONRPCError(int code, const std::string& message);
|
||||||
|
|||||||
Reference in New Issue
Block a user