You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds chain.json test suite demonstrating stateful chain operations including block processing, height tracking, and verifying state after a reorg scenario.
Documents the ref field and registry pattern in handler-spec.md.
Restructures handler-spec.md with a method reference documenting supported operations (context management, chainstate manager, chain operations, block operations, and script verification) with their parameters, return values, and error conditions.
@@ -17,14 +17,16 @@ Handlers communicate with the test runner via **stdin/stdout**:
17
17
{
18
18
"id": "unique-request-id",
19
19
"method": "method_name",
20
-
"params": { /* method-specific parameters */ }
20
+
"params": { /* method-specific parameters */ },
21
+
"ref": "reference-name"
21
22
}
22
23
```
23
24
24
25
**Fields:**
25
26
-`id` (string, required): Unique identifier for this request
26
27
-`method` (string, required): The operation to perform. Each unique method must be implemented by the handler to exercise the corresponding binding API operation.
-`ref` (string, optional): Reference name for storing the returned object. Required for methods that return object references (see [Object References and Registry](#object-references-and-registry))
28
30
29
31
### Response
30
32
@@ -41,12 +43,25 @@ Handlers communicate with the test runner via **stdin/stdout**:
41
43
```
42
44
43
45
**Fields:**
44
-
-`result` (any, optional): The return value, or `null` for void/nullptr operations. Must be `null` on error
46
+
-`result` (any, optional): The return value, or `null` for void/nullptr operations. Must be `null` on error. For methods that return object references, the result is a reference type object (see [Reference Type](#reference-type))
45
47
-`error` (object, optional): Error details. Must be `null` on success. An empty object `{}` is used to indicate an error is raised without further details, it is NOT equivalent to `null`
46
48
-`code` (object, optional): Error code details
47
49
-`type` (string, required): Error type (e.g., "btck_ScriptVerifyStatus")
48
50
-`member` (string, required): Specific error member (e.g., "ERROR_INVALID_FLAGS_COMBINATION")
49
51
52
+
### Reference Type
53
+
54
+
For methods that return object references, the result is an object containing the reference name:
55
+
56
+
```json
57
+
{
58
+
"ref": "reference-name"
59
+
}
60
+
```
61
+
62
+
**Fields:**
63
+
-`ref` (string, required): The reference name from the request's `ref` field
64
+
50
65
**Note:** Throughout this protocol, an omitted field is semantically equivalent to `null`.
51
66
52
67
## Handler Requirements
@@ -56,53 +71,223 @@ Handlers communicate with the test runner via **stdin/stdout**:
56
71
3.**Error Handling**: Return error responses for invalid requests or failed operations
57
72
4.**Exit Behavior**: Exit cleanly when stdin closes
58
73
59
-
## Test Suites and Expected Responses
60
-
61
-
The conformance tests are organized into suites, each testing a specific aspect of the Bitcoin Kernel bindings. Test files are located in [`../testdata/`](../testdata/).
Test cases where the script verification operation executes successfully and returns a boolean result (true for valid scripts, false for invalid scripts).
76
+
Many operations return objects (contexts, blocks, chains, etc.) that must persist across requests. The protocol uses named references and a registry pattern:
67
77
68
-
**Method:**`btck_script_pubkey_verify`
78
+
**Creating Objects**: Methods that return objects require a `ref` field in the request. The handler stores the object in a registry under that name and returns a reference type object containing the reference name.
**Using Objects**: When a parameter is marked as `(reference, required)`, the runner passes a reference type object and the handler extracts the reference name to look it up:
// Handler action: Extract ref from params.context, look up registry["$ctx1"], create manager, store as registry["$csm1"]
81
96
```
82
97
98
+
**Implementation**: Handlers must maintain a registry (map of reference names to object pointers) throughout their lifetime. Objects remain alive until explicitly destroyed or handler exit.
99
+
100
+
## Test Suites Overview
101
+
102
+
The conformance tests are organized into suites, each testing a specific aspect of the Bitcoin Kernel bindings. Test files are located in [`../testdata/`](../testdata/).
Test cases where the script verification operation executes successfully and returns a boolean result (true for valid scripts, false for invalid scripts).
-`spent_outputs` (array of objects): Array of outputs spent by the transaction. May be empty if the taproot flag is not set. Each object contains:
286
+
-`script_pubkey` (string): Hex-encoded script pubkey of the spent output
287
+
-`amount` (number): Amount in satoshis of the spent output
102
288
103
-
**Error Members:**
289
+
**Result:** Boolean - true if script is valid, false if invalid
104
290
105
-
| Member | Description |
106
-
|--------|-------------|
107
-
|`ERROR_INVALID_FLAGS_COMBINATION`| Invalid or inconsistent verification flags were provided. This occurs when the supplied `script_verify_flags` combination violates internal consistency rules. |
108
-
|`ERROR_SPENT_OUTPUTS_REQUIRED`| Spent outputs are required but were not provided (e.g., for Taproot verification). |
291
+
**Error:** On error, returns error code with type `btck_ScriptVerifyStatus` and member can be one of:
292
+
-`ERROR_INVALID_FLAGS_COMBINATION` - Invalid or inconsistent verification flags were provided. This occurs when the supplied `script_verify_flags` combination violates internal consistency rules.
293
+
-`ERROR_SPENT_OUTPUTS_REQUIRED` - Spent outputs are required but were not provided (e.g., for Taproot verification).
0 commit comments