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
Refactor script verification tests to use stateful object references (transaction,
script pubkey, transaction output, precomputed tx data) instead of inline hex
params.
Expand coverage from a single file to 11 dedicated files, one per output
type (P2PKH, P2SH multisig, CLTV, CSV, P2SH-P2WPKH, P2SH-P2WSH, P2WPKH, P2WSH,
P2TR keypath, P2TR scriptpath), each testing valid, corrupted, and flag-sensitivity
variants.
Adapt dependency tracker to detect refs nested inside array-valued params.
Document the new/changed methods in handler-spec.md.
@@ -102,10 +102,59 @@ Many operations return objects (contexts, blocks, chains, etc.) that must persis
102
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).
Verifies a real mainnet P2PKH output against three variants of the spending transaction: a valid signature (passes with no flags and with all pre-taproot flags), a corrupted signature (always fails), and a non-DER signature (passes without `btck_ScriptVerificationFlags_DERSIG`, fails when `btck_ScriptVerificationFlags_DERSIG` is set).
Verifies a real mainnet P2SH 2-of-3 multisig output against three spending transaction variants: valid signatures (passes with `btck_ScriptVerificationFlags_P2SH` and with all pre-taproot flags), a corrupted signature (fails with `btck_ScriptVerificationFlags_P2SH` but passes without it), and a non-null dummy stack element (passes with `btck_ScriptVerificationFlags_P2SH` alone, fails when `btck_ScriptVerificationFlags_NULLDUMMY` is also set).
Verifies a P2SH output containing `OP_CHECKLOCKTIMEVERIFY` locked to block 100. The transaction with `locktime=100` passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY` and with all pre-taproot flags. The transaction with `locktime=50` fails when `btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY` is enforced but passes when only `btck_ScriptVerificationFlags_P2SH` is set.
Verifies a P2SH output containing `OP_CHECKSEQUENCEVERIFY` locked to sequence 10. The transaction with `sequence=10` passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY` and with all pre-taproot flags. The transaction with `sequence=5` fails when `btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY` is enforced but passes when only `btck_ScriptVerificationFlags_P2SH` is set.
Verifies a real mainnet P2SH-wrapped P2WPKH output against two spending transaction variants: a valid witness signature (passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` and with all pre-taproot flags) and a corrupted witness signature (fails with `btck_ScriptVerificationFlags_WITNESS` enforced, passes with `btck_ScriptVerificationFlags_P2SH` only).
Verifies a real mainnet P2SH-wrapped P2WSH output against two spending transaction variants: a valid 2-of-3 multisig witness (passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` and with all pre-taproot flags) and a corrupted witness signature (fails with `btck_ScriptVerificationFlags_WITNESS` enforced, passes with `btck_ScriptVerificationFlags_P2SH` only).
Verifies a real mainnet native P2WPKH output using the same transaction with two different `amount` values: the correct amount (5003 satoshis) passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` and with all pre-taproot flags; an incorrect amount (5002 satoshis) causes the witness commitment check to fail when `btck_ScriptVerificationFlags_WITNESS` is enforced, but passes with `btck_ScriptVerificationFlags_P2SH` only.
Verifies a real mainnet native P2WSH output at input index 1 of a two-input transaction. A valid HTLC-style witness script passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` and with all pre-taproot flags. A transaction with a corrupted witness signature fails with `btck_ScriptVerificationFlags_WITNESS` enforced, but passes with `btck_ScriptVerificationFlags_P2SH` only.
Verifies a real mainnet P2TR key-path spend. Requires one spent output to build precomputed transaction data for Taproot. A valid Schnorr signature passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` + `btck_ScriptVerificationFlags_TAPROOT` and with all flags. A corrupted Schnorr signature fails when `btck_ScriptVerificationFlags_TAPROOT` is enforced but passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` only.
Verifies a real mainnet P2TR script-path spend at input index 1 of a two-input transaction. Requires two spent outputs (one per input) to build precomputed transaction data for Taproot. A valid script-path witness passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` + `btck_ScriptVerificationFlags_TAPROOT` and with all flags. A corrupted signature fails when `btck_ScriptVerificationFlags_TAPROOT` is enforced but passes with `btck_ScriptVerificationFlags_P2SH` + `btck_ScriptVerificationFlags_WITNESS` only.
-`script_pubkey` (reference, required): Reference to a ScriptPubkey from `btck_script_pubkey_create`
362
+
-`amount` (number, required): Amount of the script pubkey's associated output. May be zero if the witness flag is not set
363
+
-`tx_to` (reference, required): Reference to a Transaction from `btck_transaction_create`
364
+
-`precomputed_txdata` (reference, optional): Reference to PrecomputedTransactionData from `btck_precomputed_transaction_data_create`. Required when the taproot flag is set
365
+
-`input_index` (number, required): Index of the input in tx_to spending the script_pubkey
-`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:
299
-
-`script_pubkey` (string): Hex-encoded script pubkey of the spent output
300
-
-`amount` (number): Amount in satoshis of the spent output
301
375
302
376
**Result:** Boolean - true if script is valid, false if invalid
303
377
304
378
**Error:** On error, returns error code with type `btck_ScriptVerifyStatus` and member can be one of:
305
379
-`ERROR_INVALID_FLAGS_COMBINATION` - Invalid or inconsistent verification flags were provided. This occurs when the supplied `script_verify_flags` combination violates internal consistency rules.
306
380
-`ERROR_SPENT_OUTPUTS_REQUIRED` - Spent outputs are required but were not provided (e.g., for Taproot verification).
381
+
382
+
---
383
+
384
+
### Transaction Operations
385
+
386
+
#### `btck_transaction_create`
387
+
388
+
Creates a transaction object from raw hex-encoded transaction data.
389
+
390
+
**Parameters:**
391
+
-`raw_transaction` (string, required): Hex-encoded raw transaction data
392
+
393
+
**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$transaction"}`)
394
+
395
+
**Error:**`{}` when operation fails (C API returned null, e.g., invalid transaction bytes)
396
+
397
+
---
398
+
399
+
#### `btck_transaction_destroy`
400
+
401
+
Destroys a transaction and frees associated resources.
402
+
403
+
**Parameters:**
404
+
-`transaction` (reference, required): Transaction reference to destroy
405
+
406
+
**Result:**`null` (void operation)
407
+
408
+
**Error:**`null` (cannot return error)
409
+
410
+
---
411
+
412
+
### Transaction Output Operations
413
+
414
+
#### `btck_transaction_output_create`
415
+
416
+
Creates a transaction output from a script pubkey reference and amount.
417
+
418
+
**Parameters:**
419
+
-`script_pubkey` (reference, required): Reference to a ScriptPubkey from `btck_script_pubkey_create`
420
+
-`amount` (number, required): Amount in satoshis
421
+
422
+
**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$transaction_output"}`)
423
+
424
+
**Error:**`null` (cannot return error)
425
+
426
+
---
427
+
428
+
#### `btck_transaction_output_destroy`
429
+
430
+
Destroys a transaction output and frees associated resources.
431
+
432
+
**Parameters:**
433
+
-`transaction_output` (reference, required): Transaction output reference to destroy
434
+
435
+
**Result:**`null` (void operation)
436
+
437
+
**Error:**`null` (cannot return error)
438
+
439
+
---
440
+
441
+
### Precomputed Transaction Data Operations
442
+
443
+
#### `btck_precomputed_transaction_data_create`
444
+
445
+
Creates precomputed transaction data for script verification. Precomputed data is reusable when verifying multiple inputs of the same transaction.
446
+
447
+
**Parameters:**
448
+
-`tx_to` (reference, required): Reference to a Transaction from `btck_transaction_create`
449
+
-`spent_outputs` (array of references, optional): Array of references to TransactionOutput objects from `btck_transaction_output_create`. Required when `btck_ScriptVerificationFlags_TAPROOT` is set
450
+
451
+
**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$precomputed_txdata"}`)
452
+
453
+
**Error:**`{}` when operation fails (C API returned null)
454
+
455
+
---
456
+
457
+
#### `btck_precomputed_transaction_data_destroy`
458
+
459
+
Destroys precomputed transaction data and frees associated resources.
460
+
461
+
**Parameters:**
462
+
-`precomputed_txdata` (reference, required): Precomputed transaction data reference to destroy
0 commit comments