From c94074fa1b1396e310ab94955f5d04c9bda61b64 Mon Sep 17 00:00:00 2001 From: sedited Date: Mon, 10 Aug 2026 16:05:12 +0200 Subject: [PATCH] rpc: Surface OBJ_USER_KEYS description for openrpc While this is usually used where the types are not enforced strictly, adding the description is both useful to the developer implementing a client and for potentially using the openrpc output as a basis for documentation. ```diff diff interim_dump.json new_dump.json 465c465,466 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address,\nthe value (float or string) is the amount in BTC" 777c778,779 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC" 903c905,906 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC" 12915c12918,12919 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address,\nthe value (float or string) is the amount in BTC" 13692c13696,13697 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address,\nthe value (float or string) is the amount in BTC" 14002c14007,14008 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC" 14254c14260,14261 < } --- > }, > "description": "The bitcoin address is the key, the numeric amount (can be string) in BTC is the value" 16046c16053,16054 < } --- > }, > "description": "A key-value pair. The key (string) is the bitcoin address,\nthe value (float or string) is the amount in BTC" ``` --- src/rpc/server.cpp | 3 +++ test/functional/rpc_openrpc.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 73b0d248f6f..5f3bf91683b 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -415,6 +415,9 @@ UniValue OpenRPCArgSchema(const RPCArg& arg, bool include_hidden, bool in_skip_t schema.pushKV("type", "object"); if (!arg.m_inner.empty()) { schema.pushKV("additionalProperties", OpenRPCArgSchema(arg.m_inner[0], include_hidden, in_skip_type_check)); + if (!arg.m_inner[0].m_description.empty()) { + schema.pushKV("description", arg.m_inner[0].m_description); + } } else { schema.pushKV("additionalProperties", true); } diff --git a/test/functional/rpc_openrpc.py b/test/functional/rpc_openrpc.py index d25d6daff0b..5a57e6251ad 100755 --- a/test/functional/rpc_openrpc.py +++ b/test/functional/rpc_openrpc.py @@ -75,7 +75,8 @@ class OpenRPCDocTest(BitcoinTestFramework): self.log.info("Checking relaxed schemas for unchecked RPC types") createrawtransaction = find_method(openrpc, "createrawtransaction") outputs = find_param(createrawtransaction, "outputs") - address_obj = { "type": "object", "additionalProperties": {"oneOf": [{"type": "number"},{"type": "string"}]}} + address_description = "A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC" + address_obj = {"type": "object", "additionalProperties": {"oneOf": [{"type": "number"},{"type": "string"}]}, "description": address_description} data_description = "A key-value pair. The key must be \"data\", the value is hex-encoded data that becomes a part of an OP_RETURN output" data_obj = {"type": "object", "properties": { "data": {"type": "string", "pattern": "^[0-9a-fA-F]+$", "description": data_description}}, "additionalProperties": False, "required": ["data"]} assert_equal(outputs["schema"], {"oneOf": [{"type": "array", "items": {"anyOf": [address_obj, data_obj]}}, {"type": "object"}]})