Skip to content

Commit dd5c930

Browse files
committed
Update handler spec to reflect response restructuring and new semantics
1 parent 5c90dfe commit dd5c930

File tree

1 file changed

+40
-27
lines changed

1 file changed

+40
-27
lines changed

docs/handler-spec.md

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,47 @@ Handlers communicate with the test runner via **stdin/stdout**:
2424
**Fields:**
2525
- `id` (string, required): Unique identifier for this request
2626
- `method` (string, required): The operation to perform. Each unique method must be implemented by the handler to exercise the corresponding binding API operation.
27-
- `params` (object, required): Method-specific parameters (can be `null` or `{}`)
27+
- `params` (object, optional): Method-specific parameters
2828

29-
### Response
29+
### Success Response
3030

3131
```json
3232
{
3333
"id": "unique-request-id",
34-
"success": { /* method-specific result */ }
34+
"result": {},
35+
"error": null
3536
}
3637
```
3738

3839
**Success response fields:**
3940
- `id` (string, required): Must match the request ID
40-
- `success` (any, required): Method-specific result data. Must be present on success (can be empty `{}`)
41-
- `error` (null or omitted): Must not be present on success
41+
- `result` (any, optional): The return value, or `null` for void/nullptr operations
42+
- `error`: Must be `null` on success
43+
44+
**Note:** Throughout this protocol, an omitted field is semantically equivalent to `null`.
4245

4346
### Error Response
4447

4548
```json
4649
{
4750
"id": "unique-request-id",
51+
"result": null,
4852
"error": {
49-
"type": "error_category",
50-
"variant": "specific_error"
53+
"code": {
54+
"type": "error_type",
55+
"member": "ERROR_MEMBER_NAME"
56+
}
5157
}
5258
}
5359
```
5460

5561
**Error response fields:**
5662
- `id` (string, required): Must match the request ID
57-
- `success` (null or omitted): Must not be present on error
58-
- `error` (object, required): Error details
59-
- `type` (string, required): Error category/type
60-
- `variant` (string, optional): Specific error variant within the type. Whether the runner expects this field depends on the specific test case
63+
- `result`: Must be `null` on error
64+
- `error` (object, optional): Error details. Whether this field is required depends on the specific test case.
65+
- `code` (object, optional): Error code details
66+
- `type` (string, required): Error type (e.g., "btck_ScriptVerifyStatus")
67+
- `member` (string, required): Specific error member (e.g., "ERROR_INVALID_FLAGS_COMBINATION")
6168

6269
## Handler Requirements
6370

@@ -74,43 +81,49 @@ The conformance tests are organized into suites, each testing a specific aspect
7481
### Script Verification Success Cases
7582
**File:** [`script_verify_success.json`](../testdata/script_verify_success.json)
7683

77-
Tests valid Bitcoin script verification scenarios across different transaction types.
84+
Test cases where the script verification operation executes successfully and returns a boolean result (true for valid scripts, false for invalid scripts).
7885

79-
**Method:** `script_pubkey.verify`
86+
**Method:** `btck_script_pubkey_verify`
8087

8188
**Expected Response Format:**
8289
```json
8390
{
8491
"id": "test-id",
85-
"success": {}
92+
"result": true
93+
}
94+
```
95+
or
96+
```json
97+
{
98+
"id": "test-id",
99+
"result": false
86100
}
87101
```
88102

89103
### Script Verification Error Cases
90104
**File:** [`script_verify_errors.json`](../testdata/script_verify_errors.json)
91105

92-
Tests error handling for invalid script verification scenarios.
106+
Test cases where the verification operation fails to determine validity of the script due to bad user input.
93107

94-
**Method:** `script_pubkey.verify`
108+
**Method:** `btck_script_pubkey_verify`
95109

96110
**Expected Response Format:**
97111
```json
98112
{
99113
"id": "test-id",
114+
"result": null,
100115
"error": {
101-
"type": "ScriptVerify",
102-
"variant": "ErrorVariant"
116+
"code": {
117+
"type": "btck_ScriptVerifyStatus",
118+
"member": "ERROR_MEMBER_NAME"
119+
}
103120
}
104121
}
105122
```
106123

107-
**Error Variants:**
124+
**Error Members:**
108125

109-
| Variant | Description |
110-
|---------|-------------|
111-
| `TxInputIndex` | The specified input index is out of bounds. The `input_index` parameter is greater than or equal to the number of inputs in the transaction. |
112-
| `InvalidFlags` | Invalid verification flags were provided. The flags parameter contains bits that don't correspond to any defined verification flag. |
113-
| `InvalidFlagsCombination` | Invalid or inconsistent verification flags were provided. This occurs when the supplied `script_verify_flags` combination violates internal consistency rules. |
114-
| `SpentOutputsMismatch` | The spent_outputs array length doesn't match the input count. When spent_outputs is non-empty, it must contain exactly one output for each input in the transaction. |
115-
| `SpentOutputsRequired` | Spent outputs are required but were not provided. |
116-
| `Invalid` | Script verification failed. |
126+
| Member | Description |
127+
|--------|-------------|
128+
| `ERROR_INVALID_FLAGS_COMBINATION` | Invalid or inconsistent verification flags were provided. This occurs when the supplied `script_verify_flags` combination violates internal consistency rules. |
129+
| `ERROR_SPENT_OUTPUTS_REQUIRED` | Spent outputs are required but were not provided (e.g., for Taproot verification). |

0 commit comments

Comments
 (0)