Skip to content

Commit cada2d7

Browse files
committed
Add JSON schema for request and response handling spec 0.0.3
1 parent 4df1da5 commit cada2d7

File tree

2 files changed

+402
-0
lines changed

2 files changed

+402
-0
lines changed

docs/schemas/request-schema.json

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://github.com/stringintech/kernel-bindings-tests/request-schema.json",
4+
"title": "Bitcoin Kernel Bindings Test Handler Request",
5+
"description": "JSON Schema for requests sent from the test runner to handlers via stdin",
6+
"version": "0.0.3",
7+
"$ref": "#/definitions/Request",
8+
"definitions": {
9+
"Request": {
10+
"type": "object",
11+
"description": "A request sent from the test runner to the handler via stdin",
12+
"properties": {
13+
"id": {
14+
"type": "string",
15+
"description": "Unique identifier for this request. The response must include the same id"
16+
},
17+
"method": {
18+
"type": "string",
19+
"description": "The method to invoke on the handler",
20+
"enum": [
21+
"btck_context_create",
22+
"btck_context_destroy",
23+
"btck_chainstate_manager_create",
24+
"btck_chainstate_manager_get_active_chain",
25+
"btck_chainstate_manager_process_block",
26+
"btck_chainstate_manager_destroy",
27+
"btck_chain_get_height",
28+
"btck_chain_get_by_height",
29+
"btck_chain_contains",
30+
"btck_block_create",
31+
"btck_block_tree_entry_get_block_hash",
32+
"btck_script_pubkey_verify"
33+
]
34+
},
35+
"params": {
36+
"description": "Method-specific parameters",
37+
"oneOf": [
38+
{
39+
"$ref": "#/definitions/ContextCreateParams"
40+
},
41+
{
42+
"$ref": "#/definitions/ContextRefParams"
43+
},
44+
{
45+
"$ref": "#/definitions/ChainstateManagerRefParams"
46+
},
47+
{
48+
"$ref": "#/definitions/ChainstateManagerProcessBlockParams"
49+
},
50+
{
51+
"$ref": "#/definitions/ChainQueryParams"
52+
},
53+
{
54+
"$ref": "#/definitions/BlockCreateParams"
55+
},
56+
{
57+
"$ref": "#/definitions/BlockTreeEntryGetBlockHashParams"
58+
},
59+
{
60+
"$ref": "#/definitions/ScriptPubkeyVerifyParams"
61+
}
62+
]
63+
},
64+
"ref": {
65+
"type": "string",
66+
"description": "Reference name for storing the returned object. Required for methods that return object references",
67+
"pattern": "^\\$"
68+
}
69+
},
70+
"required": [
71+
"id",
72+
"method"
73+
]
74+
},
75+
"ContextCreateParams": {
76+
"type": "object",
77+
"description": "Parameters for btck_context_create method",
78+
"properties": {
79+
"chain_parameters": {
80+
"$ref": "#/definitions/ChainParameters"
81+
}
82+
},
83+
"required": [
84+
"chain_parameters"
85+
]
86+
},
87+
"ChainParameters": {
88+
"type": "object",
89+
"description": "Chain parameters for context creation",
90+
"properties": {
91+
"chain_type": {
92+
"$ref": "#/definitions/ChainType"
93+
}
94+
},
95+
"required": [
96+
"chain_type"
97+
]
98+
},
99+
"ChainType": {
100+
"type": "string",
101+
"description": "Chain type for context creation",
102+
"enum": [
103+
"btck_ChainType_MAINNET",
104+
"btck_ChainType_TESTNET",
105+
"btck_ChainType_TESTNET_4",
106+
"btck_ChainType_SIGNET",
107+
"btck_ChainType_REGTEST"
108+
]
109+
},
110+
"ScriptPubkeyVerifyParams": {
111+
"type": "object",
112+
"description": "Parameters for the btck_script_pubkey_verify method",
113+
"properties": {
114+
"script_pubkey": {
115+
"type": "string",
116+
"description": "The scriptPubKey of the output being spent, hex-encoded",
117+
"pattern": "^[0-9a-fA-F]*$"
118+
},
119+
"amount": {
120+
"type": "integer",
121+
"description": "The amount in satoshis of the output being spent",
122+
"minimum": 0
123+
},
124+
"tx_to": {
125+
"type": "string",
126+
"description": "The spending transaction, hex-encoded in raw format",
127+
"pattern": "^[0-9a-fA-F]*$"
128+
},
129+
"input_index": {
130+
"type": "integer",
131+
"description": "The index of the input in tx_to that is spending the output",
132+
"minimum": 0
133+
},
134+
"flags": {
135+
"description": "Script verification flags to apply. Can be an integer (combined flags) or an array of flag strings",
136+
"oneOf": [
137+
{
138+
"type": "integer",
139+
"description": "Combined flags as a single integer value",
140+
"minimum": 0
141+
},
142+
{
143+
"type": "array",
144+
"description": "Array of script verification flag strings",
145+
"items": {
146+
"$ref": "#/definitions/ScriptVerificationFlag"
147+
}
148+
}
149+
]
150+
},
151+
"spent_outputs": {
152+
"type": "array",
153+
"description": "Array of all outputs being spent by this transaction. Required for Taproot verification",
154+
"items": {
155+
"$ref": "#/definitions/SpentOutput"
156+
}
157+
}
158+
},
159+
"required": [
160+
"script_pubkey",
161+
"amount",
162+
"tx_to",
163+
"input_index",
164+
"flags",
165+
"spent_outputs"
166+
]
167+
},
168+
"ScriptVerificationFlag": {
169+
"type": "string",
170+
"description": "Script verification flags that control which rules are enforced during script execution",
171+
"enum": [
172+
"btck_ScriptVerificationFlags_P2SH",
173+
"btck_ScriptVerificationFlags_DERSIG",
174+
"btck_ScriptVerificationFlags_NULLDUMMY",
175+
"btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY",
176+
"btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY",
177+
"btck_ScriptVerificationFlags_WITNESS",
178+
"btck_ScriptVerificationFlags_TAPROOT"
179+
]
180+
},
181+
"SpentOutput": {
182+
"type": "object",
183+
"description": "Information about a transaction output being spent",
184+
"properties": {
185+
"script_pubkey": {
186+
"type": "string",
187+
"description": "The scriptPubKey of the output, hex-encoded",
188+
"pattern": "^[0-9a-fA-F]*$"
189+
},
190+
"amount": {
191+
"type": "integer",
192+
"description": "The amount in satoshis",
193+
"minimum": 0
194+
}
195+
},
196+
"required": [
197+
"script_pubkey",
198+
"amount"
199+
]
200+
},
201+
"ContextRefParams": {
202+
"type": "object",
203+
"description": "Parameters for methods that take a context reference (btck_context_destroy, btck_chainstate_manager_create)",
204+
"properties": {
205+
"context": {
206+
"type": "string",
207+
"description": "Context reference"
208+
}
209+
},
210+
"required": [
211+
"context"
212+
]
213+
},
214+
"ChainstateManagerRefParams": {
215+
"type": "object",
216+
"description": "Parameters for methods that take a chainstate manager reference (btck_chainstate_manager_get_active_chain, btck_chainstate_manager_destroy)",
217+
"properties": {
218+
"chainstate_manager": {
219+
"type": "string",
220+
"description": "Chainstate manager reference"
221+
}
222+
},
223+
"required": [
224+
"chainstate_manager"
225+
]
226+
},
227+
"ChainstateManagerProcessBlockParams": {
228+
"type": "object",
229+
"description": "Parameters for btck_chainstate_manager_process_block method",
230+
"properties": {
231+
"chainstate_manager": {
232+
"type": "string",
233+
"description": "Chainstate manager reference"
234+
},
235+
"block": {
236+
"type": "string",
237+
"description": "Block reference from btck_block_create"
238+
}
239+
},
240+
"required": [
241+
"chainstate_manager",
242+
"block"
243+
]
244+
},
245+
"ChainQueryParams": {
246+
"type": "object",
247+
"description": "Parameters for chain methods (btck_chain_get_height, btck_chain_get_by_height, btck_chain_contains)",
248+
"properties": {
249+
"chain": {
250+
"type": "string",
251+
"description": "Chain reference from btck_chainstate_manager_get_active_chain"
252+
},
253+
"block_height": {
254+
"type": "integer",
255+
"description": "Height to query",
256+
"minimum": 0
257+
},
258+
"block_tree_entry": {
259+
"type": "string",
260+
"description": "Block tree entry reference to check"
261+
}
262+
},
263+
"required": [
264+
"chain"
265+
],
266+
"oneOf": [
267+
{
268+
"properties": {},
269+
"not": {
270+
"anyOf": [
271+
{
272+
"required": [
273+
"block_height"
274+
]
275+
},
276+
{
277+
"required": [
278+
"block_tree_entry"
279+
]
280+
}
281+
]
282+
}
283+
},
284+
{
285+
"required": [
286+
"block_height"
287+
]
288+
},
289+
{
290+
"required": [
291+
"block_tree_entry"
292+
]
293+
}
294+
]
295+
},
296+
"BlockCreateParams": {
297+
"type": "object",
298+
"description": "Parameters for btck_block_create method",
299+
"properties": {
300+
"raw_block": {
301+
"type": "string",
302+
"description": "Hex-encoded raw block data",
303+
"pattern": "^[0-9a-fA-F]*$"
304+
}
305+
},
306+
"required": [
307+
"raw_block"
308+
]
309+
},
310+
"BlockTreeEntryGetBlockHashParams": {
311+
"type": "object",
312+
"description": "Parameters for btck_block_tree_entry_get_block_hash method",
313+
"properties": {
314+
"block_tree_entry": {
315+
"type": "string",
316+
"description": "Block tree entry reference from btck_chain_get_by_height"
317+
}
318+
},
319+
"required": [
320+
"block_tree_entry"
321+
]
322+
}
323+
}
324+
}

0 commit comments

Comments
 (0)