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"
```
This commit is contained in:
sedited
2026-08-10 16:05:12 +02:00
parent c020c21d54
commit c94074fa1b
2 changed files with 5 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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"}]})