Merge bitcoin/bitcoin#35946: rpc: Improve some type specs for openrpc

e07d826e0e rpc: Fix type in ApplyTypeStrOverride (Shuvam Pandey)
c94074fa1b rpc: Surface OBJ_USER_KEYS description for openrpc (sedited)
c020c21d54 rpc: Handle skip type args for openrpc (sedited)

Pull request description:

  This was initially motivated by testing the dump of the schema against open-rpc-generator, which crashed with:

  ```
  open-rpc-generator generate -t client -l rust -n bitcoin_client -d ./openrpc.gen.json -o ./generated
  There was error at generator runtime:
  TypeError: Cannot convert undefined or null to object
  ```

  The changes here fix this crash (albeit perfectly valid existing schema), but I think creating a more complete output is helpful on its own. The openrpc schema dumps can eventually be re-used for the rpc docs and to track rpc interface changes more accurately. Adding the CreateTxDoc outputs section seems useful for that.

  Also includes a type tightening from number to integer in `ApplyTypeStrOverride` to reflect the actual behaviour in the rpc calls, where only integers are accepted.

ACKs for top commit:
  achow101:
    ACK e07d826e0e
  willcl-ark:
    ACK e07d826e0e

Tree-SHA512: d0454a71b4f1dab1daf8a0d5b1e5bf1c1b8f1a16d26638d4a64a2652402ad74230366cabf0cf4135a16d0bdab584d3d4b2a47f2968a4eff605348ce85e8dbadb
This commit is contained in:
merge-script
2026-08-18 09:59:26 +01:00
2 changed files with 25 additions and 14 deletions

View File

@@ -52,7 +52,7 @@ class OpenRPCDocTest(BitcoinTestFramework):
self.log.info("Checking type_str override schemas")
getblockstats = find_method(openrpc, "getblockstats")
hash_or_height = find_param(getblockstats, "hash_or_height")
assert_equal(hash_or_height["schema"], {"oneOf": [{"type": "number"}, {"type": "string"}]})
assert_equal(hash_or_height["schema"], {"oneOf": [{"type": "integer"}, {"type": "string"}]})
self.log.info("Checking fixed-length array schemas")
deriveaddresses = find_method(openrpc, "deriveaddresses")
@@ -75,7 +75,11 @@ class OpenRPCDocTest(BitcoinTestFramework):
self.log.info("Checking relaxed schemas for unchecked RPC types")
createrawtransaction = find_method(openrpc, "createrawtransaction")
outputs = find_param(createrawtransaction, "outputs")
assert_equal(outputs["schema"], {"oneOf": [{"type": "array"}, {"type": "object"}]})
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"}]})
getdescriptoractivity = find_method(openrpc, "getdescriptoractivity")
activity = getdescriptoractivity["result"]["schema"]["properties"]["activity"]