diff --git a/docs/handler-spec.md b/docs/handler-spec.md index 8b27b6e..ae488aa 100644 --- a/docs/handler-spec.md +++ b/docs/handler-spec.md @@ -102,10 +102,59 @@ Many operations return objects (contexts, blocks, chains, etc.) that must persis The conformance tests are organized into suites, each testing a specific aspect of the Bitcoin Kernel bindings. Test files are located in [`../testdata/`](../testdata/). ### Script Verification Success Cases -**File:** [`script_verify_success.json`](../testdata/script_verify_success.json) Test cases where the script verification operation executes successfully and returns a boolean result (true for valid scripts, false for invalid scripts). +#### Script Verification — P2PKH +**File:** [`script_verify_p2pkh.json`](../testdata/script_verify_p2pkh.json) + +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). + +#### Script Verification — P2SH Multisig +**File:** [`script_verify_p2sh_multisig.json`](../testdata/script_verify_p2sh_multisig.json) + +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). + +#### Script Verification — CLTV +**File:** [`script_verify_cltv.json`](../testdata/script_verify_cltv.json) + +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. + +#### Script Verification — CSV +**File:** [`script_verify_csv.json`](../testdata/script_verify_csv.json) + +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. + +#### Script Verification — P2SH-P2WPKH +**File:** [`script_verify_p2sh_p2wpkh.json`](../testdata/script_verify_p2sh_p2wpkh.json) + +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). + +#### Script Verification — P2SH-P2WSH +**File:** [`script_verify_p2sh_p2wsh.json`](../testdata/script_verify_p2sh_p2wsh.json) + +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). + +#### Script Verification — P2WPKH +**File:** [`script_verify_p2wpkh.json`](../testdata/script_verify_p2wpkh.json) + +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. + +#### Script Verification — P2WSH +**File:** [`script_verify_p2wsh.json`](../testdata/script_verify_p2wsh.json) + +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. + +#### Script Verification — P2TR Key-Path +**File:** [`script_verify_p2tr_keypath.json`](../testdata/script_verify_p2tr_keypath.json) + +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. + +#### Script Verification — P2TR Script-Path +**File:** [`script_verify_p2tr_scriptpath.json`](../testdata/script_verify_p2tr_scriptpath.json) + +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 Verification Error Cases **File:** [`script_verify_errors.json`](../testdata/script_verify_errors.json) @@ -276,18 +325,46 @@ Gets the block hash from a block tree entry. --- -### Script Verification +### Script Pubkey Operations + +#### `btck_script_pubkey_create` + +Creates a script pubkey object from hex-encoded data. + +**Parameters:** +- `script_pubkey` (string, required): Hex-encoded script pubkey data + +**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$script_pubkey"}`) + +**Error:** `{}` when operation fails (C API returned null) + +--- + +#### `btck_script_pubkey_destroy` + +Destroys a script pubkey and frees associated resources. + +**Parameters:** +- `script_pubkey` (reference, required): Script pubkey reference to destroy + +**Result:** `null` (void operation) + +**Error:** `null` (cannot return error) + +--- #### `btck_script_pubkey_verify` Verifies a script pubkey against spending conditions. **Parameters:** -- `script_pubkey` (string): Hex-encoded script pubkey to be spent -- `amount` (number): Amount of the script pubkey's associated output. May be zero if the witness flag is not set -- `tx_to` (string): Hex-encoded transaction spending the script_pubkey -- `input_index` (number): Index of the input in tx_to spending the script_pubkey -- `flags` (array of strings): Script verification flags controlling validation constraints. Valid flags include: +- `script_pubkey` (reference, required): Reference to a ScriptPubkey from `btck_script_pubkey_create` +- `amount` (number, required): Amount of the script pubkey's associated output. May be zero if the witness flag is not set +- `tx_to` (reference, required): Reference to a Transaction from `btck_transaction_create` +- `precomputed_txdata` (reference, optional): Reference to PrecomputedTransactionData from `btck_precomputed_transaction_data_create`. Required when the taproot flag is set +- `input_index` (number, required): Index of the input in tx_to spending the script_pubkey +- `flags` (array of strings, required): Script verification flags controlling validation constraints. Valid flags include: + - `btck_ScriptVerificationFlags_NONE` - `btck_ScriptVerificationFlags_P2SH` - `btck_ScriptVerificationFlags_DERSIG` - `btck_ScriptVerificationFlags_NULLDUMMY` @@ -295,12 +372,95 @@ Verifies a script pubkey against spending conditions. - `btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY` - `btck_ScriptVerificationFlags_WITNESS` - `btck_ScriptVerificationFlags_TAPROOT` -- `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: - - `script_pubkey` (string): Hex-encoded script pubkey of the spent output - - `amount` (number): Amount in satoshis of the spent output **Result:** Boolean - true if script is valid, false if invalid **Error:** On error, returns error code with type `btck_ScriptVerifyStatus` and member can be one of: - `ERROR_INVALID_FLAGS_COMBINATION` - Invalid or inconsistent verification flags were provided. This occurs when the supplied `script_verify_flags` combination violates internal consistency rules. - `ERROR_SPENT_OUTPUTS_REQUIRED` - Spent outputs are required but were not provided (e.g., for Taproot verification). + +--- + +### Transaction Operations + +#### `btck_transaction_create` + +Creates a transaction object from raw hex-encoded transaction data. + +**Parameters:** +- `raw_transaction` (string, required): Hex-encoded raw transaction data + +**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$transaction"}`) + +**Error:** `{}` when operation fails (C API returned null, e.g., invalid transaction bytes) + +--- + +#### `btck_transaction_destroy` + +Destroys a transaction and frees associated resources. + +**Parameters:** +- `transaction` (reference, required): Transaction reference to destroy + +**Result:** `null` (void operation) + +**Error:** `null` (cannot return error) + +--- + +### Transaction Output Operations + +#### `btck_transaction_output_create` + +Creates a transaction output from a script pubkey reference and amount. + +**Parameters:** +- `script_pubkey` (reference, required): Reference to a ScriptPubkey from `btck_script_pubkey_create` +- `amount` (number, required): Amount in satoshis + +**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$transaction_output"}`) + +**Error:** `null` (cannot return error) + +--- + +#### `btck_transaction_output_destroy` + +Destroys a transaction output and frees associated resources. + +**Parameters:** +- `transaction_output` (reference, required): Transaction output reference to destroy + +**Result:** `null` (void operation) + +**Error:** `null` (cannot return error) + +--- + +### Precomputed Transaction Data Operations + +#### `btck_precomputed_transaction_data_create` + +Creates precomputed transaction data for script verification. Precomputed data is reusable when verifying multiple inputs of the same transaction. + +**Parameters:** +- `tx_to` (reference, required): Reference to a Transaction from `btck_transaction_create` +- `spent_outputs` (array of references, optional): Array of references to TransactionOutput objects from `btck_transaction_output_create`. Required when `btck_ScriptVerificationFlags_TAPROOT` is set + +**Result:** Reference type - Object containing the reference name from the request `ref` field (e.g., `{"ref": "$precomputed_txdata"}`) + +**Error:** `{}` when operation fails (C API returned null) + +--- + +#### `btck_precomputed_transaction_data_destroy` + +Destroys precomputed transaction data and frees associated resources. + +**Parameters:** +- `precomputed_txdata` (reference, required): Precomputed transaction data reference to destroy + +**Result:** `null` (void operation) + +**Error:** `null` (cannot return error) diff --git a/runner/dependency_tracker.go b/runner/dependency_tracker.go index 1281e0a..6ff78c3 100644 --- a/runner/dependency_tracker.go +++ b/runner/dependency_tracker.go @@ -125,7 +125,8 @@ func (dt *DependencyTracker) testUsesStatefulRefs(testIndex int, allTests []Test } // extractRefsFromParams extracts all reference names from params JSON. -// Searches for ref objects with structure {"ref": "..."} at the first level of params. +// Searches for ref objects with structure {"ref": "..."} at the top level of params, +// and also inside array values one level deep. func extractRefsFromParams(params json.RawMessage) []string { var refs []string @@ -137,6 +138,16 @@ func extractRefsFromParams(params json.RawMessage) []string { for _, value := range paramsMap { if ref, ok := ParseRefObject(value); ok { refs = append(refs, ref) + continue + } + // Check if value is an array and scan its elements for ref objects + var arr []json.RawMessage + if err := json.Unmarshal(value, &arr); err == nil { + for _, elem := range arr { + if ref, ok := ParseRefObject(elem); ok { + refs = append(refs, ref) + } + } } } return refs diff --git a/runner/dependency_tracker_test.go b/runner/dependency_tracker_test.go index 994e22f..30755ca 100644 --- a/runner/dependency_tracker_test.go +++ b/runner/dependency_tracker_test.go @@ -43,6 +43,14 @@ func TestDependencyTracker_BuildDependencyChains(t *testing.T) { "params": {"first": {"ref": "$ref_b"}, "second": {"ref": "$ref_c"}} }, "expected_response": {} + }, + { + "request": { + "id": "test4", + "method": "use_array", + "params": {"items": [{"ref": "$ref_a"}, {"ref": "$ref_c"}]} + }, + "expected_response": {} } ]` @@ -86,6 +94,11 @@ func TestDependencyTracker_BuildDependencyChains(t *testing.T) { wantDepChain: []int{0, 1, 2}, description: "test3 depends on test1 (which depends on test0) and test2", }, + { + testIdx: 4, + wantDepChain: []int{0, 2}, + description: "test4 depends on test0 and test2 via refs nested in an array param", + }, } for _, tt := range tests { diff --git a/testdata/script_verify_cltv.json b/testdata/script_verify_cltv.json new file mode 100644 index 0000000..cd684c8 --- /dev/null +++ b/testdata/script_verify_cltv.json @@ -0,0 +1,277 @@ +{ + "name": "script_verify_cltv", + "description": "Verifies a P2SH output with OP_CHECKLOCKTIMEVERIFY locked to block 100. Transaction with locktime=100 passes with P2SH + CHECKLOCKTIMEVERIFY and all pre-taproot flags; transaction with locktime=50 fails when CHECKLOCKTIMEVERIFY is enforced but passes with P2SH only.", + "stateful": true, + "tests": [ + { + "description": "Create CLTV P2SH script pubkey (locked to block 100)", + "request": { + "id": "script_verify_cltv#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "a914e6855a94d0e499a0d554b2476cb779885986575b87" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create CLTV transaction with locktime=100 (satisfies CLTV condition)", + "request": { + "id": "script_verify_cltv#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0200000001738df4ccd15745a9539ff632cbe903f1050807edf35a1a3835c5bca619078f19010000007047304402202124e252c265a905c02063b1235b77c2406ae3c44d5749117f0ac086e2350ba2022061b65765be68ac21b60ede916d2a6deb1e6f8c9f723e66859bf4f06d98f7112b01270164b1752102d8019ae39403a4c0b49e98a0be4ed9ad0b1ba20f324fd6268c7455841deddd0dac000000000118ddf50500000000015164000000" + }, + "ref": "$tx_valid_locktime" + }, + "expected_response": { + "result": { + "ref": "$tx_valid_locktime" + } + } + }, + { + "description": "Create precomputed transaction data for valid locktime CLTV", + "request": { + "id": "script_verify_cltv#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid_locktime" + } + }, + "ref": "$precomp_valid_locktime" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid_locktime" + } + } + }, + { + "description": "Verify CLTV with locktime=100 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY - passes", + "request": { + "id": "script_verify_cltv#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid_locktime" + }, + "precomputed_txdata": { + "ref": "$precomp_valid_locktime" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify CLTV with locktime=100 and all pre-taproot flags - passes", + "request": { + "id": "script_verify_cltv#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid_locktime" + }, + "precomputed_txdata": { + "ref": "$precomp_valid_locktime" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid locktime CLTV", + "request": { + "id": "script_verify_cltv#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid_locktime" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid locktime CLTV transaction", + "request": { + "id": "script_verify_cltv#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid_locktime" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create CLTV transaction with locktime=50 (does not satisfy CLTV condition)", + "request": { + "id": "script_verify_cltv#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0200000001738df4ccd15745a9539ff632cbe903f1050807edf35a1a3835c5bca619078f190100000071483045022100bdaefb402ddf25738762c57978b9f02adb9007e7c835673d8cbda6bc0b58ee78022054011b17b5d7d8b516d1ced26d124b435a5c4cccc7492778ab2a6661f5ef365801270164b1752102d8019ae39403a4c0b49e98a0be4ed9ad0b1ba20f324fd6268c7455841deddd0dac000000000118ddf50500000000015132000000" + }, + "ref": "$tx_invalid_locktime" + }, + "expected_response": { + "result": { + "ref": "$tx_invalid_locktime" + } + } + }, + { + "description": "Create precomputed transaction data for invalid locktime CLTV", + "request": { + "id": "script_verify_cltv#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_invalid_locktime" + } + }, + "ref": "$precomp_invalid_locktime" + }, + "expected_response": { + "result": { + "ref": "$precomp_invalid_locktime" + } + } + }, + { + "description": "Verify CLTV with locktime=50 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY - fails (locktime < 100)", + "request": { + "id": "script_verify_cltv#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_invalid_locktime" + }, + "precomputed_txdata": { + "ref": "$precomp_invalid_locktime" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify CLTV with locktime=50 and btck_ScriptVerificationFlags_P2SH only - passes (CLTV not enforced)", + "request": { + "id": "script_verify_cltv#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_invalid_locktime" + }, + "precomputed_txdata": { + "ref": "$precomp_invalid_locktime" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for invalid locktime CLTV", + "request": { + "id": "script_verify_cltv#12", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_invalid_locktime" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy invalid locktime CLTV transaction", + "request": { + "id": "script_verify_cltv#13", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_invalid_locktime" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy CLTV P2SH script pubkey", + "request": { + "id": "script_verify_cltv#14", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_csv.json b/testdata/script_verify_csv.json new file mode 100644 index 0000000..dada662 --- /dev/null +++ b/testdata/script_verify_csv.json @@ -0,0 +1,277 @@ +{ + "name": "script_verify_csv", + "description": "Verifies a P2SH output with OP_CHECKSEQUENCEVERIFY locked to sequence 10. Transaction with sequence=10 passes with P2SH + CHECKSEQUENCEVERIFY and all pre-taproot flags; transaction with sequence=5 fails when CHECKSEQUENCEVERIFY is enforced but passes with P2SH only.", + "stateful": true, + "tests": [ + { + "description": "Create CSV P2SH script pubkey (locked to sequence 10)", + "request": { + "id": "script_verify_csv#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "a914284e9e01049bc9bfe2a1f06e6e78cd29a717ffb987" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create CSV transaction with input sequence=10 (satisfies CSV condition)", + "request": { + "id": "script_verify_csv#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0200000001b4b3b5eed405f118a43e411d51eace0b7a48ad6ec061e0c6d1e2a5dbc50fa1780100000071483045022100fc82daf200e56d9500d3cdb4708a5d9cf1b62a3299dedc9cdf7b6e6412b7fa280220144b6d6c535a6a66f60d25b68c6b6ae95c0e45c8801e4007b76d0cfcf264ec4d0127010ab275210291c420b3afc1c75796653268a727d61df2edd606c243b261df61dd22f388553fac0a0000000118ddf50500000000015100000000" + }, + "ref": "$tx_valid_sequence" + }, + "expected_response": { + "result": { + "ref": "$tx_valid_sequence" + } + } + }, + { + "description": "Create precomputed transaction data for valid sequence CSV", + "request": { + "id": "script_verify_csv#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid_sequence" + } + }, + "ref": "$precomp_valid_sequence" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid_sequence" + } + } + }, + { + "description": "Verify CSV with sequence=10 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY - passes", + "request": { + "id": "script_verify_csv#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid_sequence" + }, + "precomputed_txdata": { + "ref": "$precomp_valid_sequence" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify CSV with sequence=10 and all pre-taproot flags - passes", + "request": { + "id": "script_verify_csv#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid_sequence" + }, + "precomputed_txdata": { + "ref": "$precomp_valid_sequence" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid sequence CSV", + "request": { + "id": "script_verify_csv#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid_sequence" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid sequence CSV transaction", + "request": { + "id": "script_verify_csv#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid_sequence" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create CSV transaction with input sequence=5 (does not satisfy CSV condition)", + "request": { + "id": "script_verify_csv#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0200000001b4b3b5eed405f118a43e411d51eace0b7a48ad6ec061e0c6d1e2a5dbc50fa178010000007148304502210080c15d7432d18c78529b95f6677dfc57ae22024789eefed400dbfebcdc8341da02204775fed6dedc3b540eea67c3bf8058e1211248970cdab9980c0ed09736e13fbb0127010ab275210291c420b3afc1c75796653268a727d61df2edd606c243b261df61dd22f388553fac050000000118ddf50500000000015100000000" + }, + "ref": "$tx_invalid_sequence" + }, + "expected_response": { + "result": { + "ref": "$tx_invalid_sequence" + } + } + }, + { + "description": "Create precomputed transaction data for invalid sequence CSV", + "request": { + "id": "script_verify_csv#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_invalid_sequence" + } + }, + "ref": "$precomp_invalid_sequence" + }, + "expected_response": { + "result": { + "ref": "$precomp_invalid_sequence" + } + } + }, + { + "description": "Verify CSV with sequence=5 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY - fails (sequence < 10)", + "request": { + "id": "script_verify_csv#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_invalid_sequence" + }, + "precomputed_txdata": { + "ref": "$precomp_invalid_sequence" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify CSV with sequence=5 and btck_ScriptVerificationFlags_P2SH only - passes (CSV not enforced)", + "request": { + "id": "script_verify_csv#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_invalid_sequence" + }, + "precomputed_txdata": { + "ref": "$precomp_invalid_sequence" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for invalid sequence CSV", + "request": { + "id": "script_verify_csv#12", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_invalid_sequence" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy invalid sequence CSV transaction", + "request": { + "id": "script_verify_csv#13", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_invalid_sequence" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy CSV P2SH script pubkey", + "request": { + "id": "script_verify_csv#14", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_errors.json b/testdata/script_verify_errors.json index b276afc..583a8bc 100644 --- a/testdata/script_verify_errors.json +++ b/testdata/script_verify_errors.json @@ -1,25 +1,77 @@ { "name": "Failed Script Verification Cases", "description": "Test cases where the verification operation fails to determine validity of the script due to bad user input", + "stateful": true, "tests": [ { - "description": "VERIFY_WITNESS flag requires P2SH flag to be set as well", + "description": "Create P2PKH script pubkey", "request": { - "id": "error_invalid_flags_combination", + "id": "script_verify_errors#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ac" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create P2PKH transaction", + "request": { + "id": "script_verify_errors#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700" + }, + "ref": "$tx" + }, + "expected_response": { + "result": { + "ref": "$tx" + } + } + }, + { + "description": "Create precomputed transaction data", + "request": { + "id": "script_verify_errors#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx" + } + }, + "ref": "$precomp" + }, + "expected_response": { + "result": { + "ref": "$precomp" + } + } + }, + { + "description": "btck_ScriptVerificationFlags_WITNESS flag requires btck_ScriptVerificationFlags_P2SH flag to be set as well", + "request": { + "id": "script_verify_errors#4", "method": "btck_script_pubkey_verify", "params": { - "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ac", + "script_pubkey": { + "ref": "$spk" + }, "amount": 0, - "tx_to": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700", + "tx_to": { + "ref": "$tx" + }, + "precomputed_txdata": { + "ref": "$precomp" + }, "input_index": 0, "flags": [ "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [ - { - "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ac", - "amount": 100000 - } ] } }, @@ -33,19 +85,25 @@ } }, { - "description": "Taproot verification requires spent outputs to be provided", + "description": "btck_ScriptVerificationFlags_TAPROOT flag requires spent outputs to be provided", "request": { - "id": "error_spent_outputs_required", + "id": "script_verify_errors#5", "method": "btck_script_pubkey_verify", "params": { - "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ac", + "script_pubkey": { + "ref": "$spk" + }, "amount": 0, - "tx_to": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700", + "tx_to": { + "ref": "$tx" + }, + "precomputed_txdata": { + "ref": "$precomp" + }, "input_index": 0, "flags": [ "btck_ScriptVerificationFlags_TAPROOT" - ], - "spent_outputs": [] + ] } }, "expected_response": { @@ -56,6 +114,51 @@ } } } + }, + { + "description": "Destroy precomputed transaction data", + "request": { + "id": "script_verify_errors#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy transaction", + "request": { + "id": "script_verify_errors#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy script pubkey", + "request": { + "id": "script_verify_errors#8", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } } ] } diff --git a/testdata/script_verify_p2pkh.json b/testdata/script_verify_p2pkh.json new file mode 100644 index 0000000..0fb9951 --- /dev/null +++ b/testdata/script_verify_p2pkh.json @@ -0,0 +1,365 @@ +{ + "name": "script_verify_p2pkh", + "description": "Verifies a mainnet P2PKH output against three transaction variants: valid sig (passes with no flags and all pre-taproot flags), corrupted sig (always fails), non-DER sig (passes without DERSIG, fails with it). Mainnet tx aca326a724eda9a461c10a876534ecd5ae7b27f10f26c3862fb996f80ea2d45d.", + "stateful": true, + "tests": [ + { + "description": "Create P2PKH script pubkey", + "request": { + "id": "script_verify_p2pkh#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ac" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create valid P2PKH transaction", + "request": { + "id": "script_verify_p2pkh#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2PKH", + "request": { + "id": "script_verify_p2pkh#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + } + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2PKH with no flags", + "request": { + "id": "script_verify_p2pkh#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_NONE" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2PKH with all pre-taproot flags", + "request": { + "id": "script_verify_p2pkh#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2PKH", + "request": { + "id": "script_verify_p2pkh#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2PKH transaction", + "request": { + "id": "script_verify_p2pkh#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2PKH transaction with corrupted signature (one byte flipped)", + "request": { + "id": "script_verify_p2pkh#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c6f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2PKH", + "request": { + "id": "script_verify_p2pkh#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + } + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2PKH with corrupted signature and no flags - fails with invalid", + "request": { + "id": "script_verify_p2pkh#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_NONE" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2PKH", + "request": { + "id": "script_verify_p2pkh#11", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2PKH transaction", + "request": { + "id": "script_verify_p2pkh#12", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2PKH transaction with non-DER signature (length byte 0x46 instead of 0x45)", + "request": { + "id": "script_verify_p2pkh#13", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483046022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700" + }, + "ref": "$tx_non_der_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_non_der_sig" + } + } + }, + { + "description": "Create precomputed transaction data for non-DER sig P2PKH", + "request": { + "id": "script_verify_p2pkh#14", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_non_der_sig" + } + }, + "ref": "$precomp_non_der_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_non_der_sig" + } + } + }, + { + "description": "Verify P2PKH with non-DER signature and no flags - succeeds (DER not enforced)", + "request": { + "id": "script_verify_p2pkh#15", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_non_der_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_non_der_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_NONE" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify P2PKH with non-DER signature and btck_ScriptVerificationFlags_DERSIG - fails (DER enforced)", + "request": { + "id": "script_verify_p2pkh#16", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_non_der_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_non_der_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_DERSIG" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Destroy precomputed transaction data for non-DER sig P2PKH", + "request": { + "id": "script_verify_p2pkh#17", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_non_der_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy non-DER sig P2PKH transaction", + "request": { + "id": "script_verify_p2pkh#18", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_non_der_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy P2PKH script pubkey", + "request": { + "id": "script_verify_p2pkh#19", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2sh_multisig.json b/testdata/script_verify_p2sh_multisig.json new file mode 100644 index 0000000..09ae587 --- /dev/null +++ b/testdata/script_verify_p2sh_multisig.json @@ -0,0 +1,392 @@ +{ + "name": "script_verify_p2sh_multisig", + "description": "Verifies a mainnet P2SH 2-of-3 multisig output against three variants: valid sigs (passes with P2SH and all pre-taproot flags), corrupted sig (fails with P2SH, passes without it), non-null dummy element (passes with P2SH only, fails when NULLDUMMY is also set). Mainnet tx 3cd7f78499632d6f672d8a9412ae756b29c41342954c97846e0d153c7753a37e.", + "stateful": true, + "tests": [ + { + "description": "Create P2SH multisig script pubkey", + "request": { + "id": "script_verify_p2sh_multisig#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "a914fc8b5799cb5ae54c1be1fd97844a1cd97e820c5587" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create valid P2SH multisig transaction", + "request": { + "id": "script_verify_p2sh_multisig#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0100000001dd320ee7e290ddd042332f85dd064d2ee052257a9f4761929c237a7674ff1f0d01000000fdfe0000483045022100f808cadda09bf753740a9d1f012fe9224d670d2b4337af61858e9a61d1415a6a0220296e83ac33055c8e58bcd4f7a1afc010b6da0787e41b0add9ced70bf1b5694c901483045022100ed525f5b43420c4fe745a19276e851bf21270bbb81717e4ead7d7919a1be267802201b48b9e6c92cc698f6ceb0c170321deb253d9d94c355f00bb0c6727a567d3dcf014c69522102239bbabd01dc2e4974d60dd658ca8547924f3f3fa5e583f4dea116c5a330b7d32102135d7f51e7c3aced9d0b7a5c0dc374eea814afce5e5a075f3bacf143b33af2e62102606e72be62d5fcff8764807ff676d31e7e99b5f56b79e38fdbb794d2796bbbfa53aeffffffff02846a8700000000001976a914932850c5373a1dda47027c51125b0493c026c9a388ac4da06c000000000017a91498dd7103a99f268f443fee4424a240af3d4a5aeb8700000000" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2SH multisig", + "request": { + "id": "script_verify_p2sh_multisig#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + } + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2SH multisig with btck_ScriptVerificationFlags_P2SH", + "request": { + "id": "script_verify_p2sh_multisig#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2SH multisig with all pre-taproot flags", + "request": { + "id": "script_verify_p2sh_multisig#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2SH multisig", + "request": { + "id": "script_verify_p2sh_multisig#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2SH multisig transaction", + "request": { + "id": "script_verify_p2sh_multisig#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2SH multisig transaction with corrupted signature (length byte 0x31 instead of 0x30)", + "request": { + "id": "script_verify_p2sh_multisig#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0100000001dd320ee7e290ddd042332f85dd064d2ee052257a9f4761929c237a7674ff1f0d01000000fdfe0000483045023100f808cadda09bf753740a9d1f012fe9224d670d2b4337af61858e9a61d1415a6a0220296e83ac33055c8e58bcd4f7a1afc010b6da0787e41b0add9ced70bf1b5694c901483045022100ed525f5b43420c4fe745a19276e851bf21270bbb81717e4ead7d7919a1be267802201b48b9e6c92cc698f6ceb0c170321deb253d9d94c355f00bb0c6727a567d3dcf014c69522102239bbabd01dc2e4974d60dd658ca8547924f3f3fa5e583f4dea116c5a330b7d32102135d7f51e7c3aced9d0b7a5c0dc374eea814afce5e5a075f3bacf143b33af2e62102606e72be62d5fcff8764807ff676d31e7e99b5f56b79e38fdbb794d2796bbbfa53aeffffffff02846a8700000000001976a914932850c5373a1dda47027c51125b0493c026c9a388ac4da06c000000000017a91498dd7103a99f268f443fee4424a240af3d4a5aeb8700000000" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2SH multisig", + "request": { + "id": "script_verify_p2sh_multisig#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + } + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2SH multisig with corrupted signature and btck_ScriptVerificationFlags_P2SH - fails", + "request": { + "id": "script_verify_p2sh_multisig#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify P2SH multisig with corrupted signature and no flags - passes (P2SH not enforced)", + "request": { + "id": "script_verify_p2sh_multisig#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_NONE" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2SH multisig", + "request": { + "id": "script_verify_p2sh_multisig#12", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2SH multisig transaction", + "request": { + "id": "script_verify_p2sh_multisig#13", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2SH multisig transaction with non-null dummy stack element (OP_1 instead of OP_0)", + "request": { + "id": "script_verify_p2sh_multisig#14", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0100000001dd320ee7e290ddd042332f85dd064d2ee052257a9f4761929c237a7674ff1f0d01000000fdfe0051483045022100f808cadda09bf753740a9d1f012fe9224d670d2b4337af61858e9a61d1415a6a0220296e83ac33055c8e58bcd4f7a1afc010b6da0787e41b0add9ced70bf1b5694c901483045022100ed525f5b43420c4fe745a19276e851bf21270bbb81717e4ead7d7919a1be267802201b48b9e6c92cc698f6ceb0c170321deb253d9d94c355f00bb0c6727a567d3dcf014c69522102239bbabd01dc2e4974d60dd658ca8547924f3f3fa5e583f4dea116c5a330b7d32102135d7f51e7c3aced9d0b7a5c0dc374eea814afce5e5a075f3bacf143b33af2e62102606e72be62d5fcff8764807ff676d31e7e99b5f56b79e38fdbb794d2796bbbfa53aeffffffff02846a8700000000001976a914932850c5373a1dda47027c51125b0493c026c9a388ac4da06c000000000017a91498dd7103a99f268f443fee4424a240af3d4a5aeb8700000000" + }, + "ref": "$tx_non_null_dummy" + }, + "expected_response": { + "result": { + "ref": "$tx_non_null_dummy" + } + } + }, + { + "description": "Create precomputed transaction data for non-null dummy P2SH multisig", + "request": { + "id": "script_verify_p2sh_multisig#15", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_non_null_dummy" + } + }, + "ref": "$precomp_non_null_dummy" + }, + "expected_response": { + "result": { + "ref": "$precomp_non_null_dummy" + } + } + }, + { + "description": "Verify P2SH multisig with non-null dummy and btck_ScriptVerificationFlags_P2SH - passes (NULLDUMMY not enforced)", + "request": { + "id": "script_verify_p2sh_multisig#16", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_non_null_dummy" + }, + "precomputed_txdata": { + "ref": "$precomp_non_null_dummy" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify P2SH multisig with non-null dummy and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_NULLDUMMY - fails", + "request": { + "id": "script_verify_p2sh_multisig#17", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 0, + "tx_to": { + "ref": "$tx_non_null_dummy" + }, + "precomputed_txdata": { + "ref": "$precomp_non_null_dummy" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_NULLDUMMY" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Destroy precomputed transaction data for non-null dummy P2SH multisig", + "request": { + "id": "script_verify_p2sh_multisig#18", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_non_null_dummy" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy non-null dummy P2SH multisig transaction", + "request": { + "id": "script_verify_p2sh_multisig#19", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_non_null_dummy" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy P2SH multisig script pubkey", + "request": { + "id": "script_verify_p2sh_multisig#20", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2sh_p2wpkh.json b/testdata/script_verify_p2sh_p2wpkh.json new file mode 100644 index 0000000..c7eb2fd --- /dev/null +++ b/testdata/script_verify_p2sh_p2wpkh.json @@ -0,0 +1,277 @@ +{ + "name": "script_verify_p2sh_p2wpkh", + "description": "Verifies a mainnet P2SH-P2WPKH output against two variants: valid witness sig (passes with P2SH + WITNESS and all pre-taproot flags), corrupted witness sig (fails with WITNESS enforced, passes with P2SH only). Mainnet tx 07dea5918a500d7476b1d116d80507a66bc2167681b2e6ca7dd99dbc6d95c31d.", + "stateful": true, + "tests": [ + { + "description": "Create P2SH-P2WPKH script pubkey", + "request": { + "id": "script_verify_p2sh_p2wpkh#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "a91434c06f8c87e355e123bdc6dda4ffabc64b6989ef87" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create valid P2SH-P2WPKH transaction", + "request": { + "id": "script_verify_p2sh_p2wpkh#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "01000000000101d9fd94d0ff0026d307c994d0003180a5f248146efb6371d040c5973f5f66d9df0400000017160014b31b31a6cb654cfab3c50567bcf124f48a0beaecffffffff012cbd1c000000000017a914233b74bf0823fa58bbbd26dfc3bb4ae715547167870247304402206f60569cac136c114a58aedd80f6fa1c51b49093e7af883e605c212bdafcd8d202200e91a55f408a021ad2631bc29a67bd6915b2d7e9ef0265627eabd7f7234455f6012103e7e802f50344303c76d12c089c8724c1b230e3b745693bbe16aad536293d15e300000000" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2SH-P2WPKH", + "request": { + "id": "script_verify_p2sh_p2wpkh#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + } + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2SH-P2WPKH with btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS", + "request": { + "id": "script_verify_p2sh_p2wpkh#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1900000, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2SH-P2WPKH with all pre-taproot flags", + "request": { + "id": "script_verify_p2sh_p2wpkh#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1900000, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2SH-P2WPKH", + "request": { + "id": "script_verify_p2sh_p2wpkh#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2SH-P2WPKH transaction", + "request": { + "id": "script_verify_p2sh_p2wpkh#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2SH-P2WPKH transaction with corrupted signature (one byte flipped in witness)", + "request": { + "id": "script_verify_p2sh_p2wpkh#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "01000000000101d9fd94d0ff0026d307c994d0003180a5f248146efb6371d040c5973f5f66d9df0400000017160014b31b31a6cb654cfab3c50567bcf124f48a0beaecffffffff012cbd1c000000000017a914233b74bf0823fa58bbbd26dfc3bb4ae715547167870247304402206f60569cac136c114a58aedd80f6fa1c51b49093e7af883e615c212bdafcd8d202200e91a55f408a021ad2631bc29a67bd6915b2d7e9ef0265627eabd7f7234455f6012103e7e802f50344303c76d12c089c8724c1b230e3b745693bbe16aad536293d15e300000000" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2SH-P2WPKH", + "request": { + "id": "script_verify_p2sh_p2wpkh#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + } + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2SH-P2WPKH with corrupted signature and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS - fails", + "request": { + "id": "script_verify_p2sh_p2wpkh#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1900000, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify P2SH-P2WPKH with corrupted signature and btck_ScriptVerificationFlags_P2SH only - passes (witness not enforced)", + "request": { + "id": "script_verify_p2sh_p2wpkh#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1900000, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2SH-P2WPKH", + "request": { + "id": "script_verify_p2sh_p2wpkh#12", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2SH-P2WPKH transaction", + "request": { + "id": "script_verify_p2sh_p2wpkh#13", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy P2SH-P2WPKH script pubkey", + "request": { + "id": "script_verify_p2sh_p2wpkh#14", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2sh_p2wsh.json b/testdata/script_verify_p2sh_p2wsh.json new file mode 100644 index 0000000..64647a7 --- /dev/null +++ b/testdata/script_verify_p2sh_p2wsh.json @@ -0,0 +1,277 @@ +{ + "name": "script_verify_p2sh_p2wsh", + "description": "Verifies a mainnet P2SH-P2WSH (2-of-3 multisig) output against two variants: valid witness sigs (passes with P2SH + WITNESS and all pre-taproot flags), corrupted witness sig (fails with WITNESS enforced, passes with P2SH only). Mainnet tx 017be55761bf5a3920c73778810a6be4c3315dc6efa4f31b590bc3bc1da9d75f.", + "stateful": true, + "tests": [ + { + "description": "Create P2SH-P2WSH script pubkey", + "request": { + "id": "script_verify_p2sh_p2wsh#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "a91469abb4763c2074e22a2ab2e06208f552bf7c654387" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create valid P2SH-P2WSH transaction", + "request": { + "id": "script_verify_p2sh_p2wsh#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "020000000001018d30fa8c3023ae9e72f44cea3525b4fe084a816830efb98b605678230cc9c48d0100000023220020a9cd0514e7793003d378df96bbe21c901421ff089ad5598a1a9b5a3cf6eaef0afdffffff0201ed11a60000000017a914194b877577228c0012e4ca3c3780198d8b09d14c87bccb510200000000160014db65e96bfbf0d6ce727ab2518a2f45635367f8b3040047304402202e679780ebe920a1e367482cace23cebaa9d8be7e7d1bd727d7439fb62c8332802204008e33b111161206cd09c947588b43114011a60c7dbaf0679c60d891e38fbb701473044022029233663e8fdbaead30f4ff806018d7ec939505fb4e11cd53195e3ca83f36f5302202010174a3b84d1128272ef1fabf23f1add09e8e074ed2443688a718be86947e40169522102282a387d21d8784fbbf28e6d0cb3f9984996771e7283bd8f5c32dc4b7a961ba8210294586ab0277cae2a8b138527816bf9f36a7203265d83e08bbeaebdd7e1568b2c21030e724028e64b78c0479a35e7c9b4cc3c13456f12ba993a8f19a38ee3b2d7743953ae00000000" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2SH-P2WSH", + "request": { + "id": "script_verify_p2sh_p2wsh#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + } + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2SH-P2WSH with btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS", + "request": { + "id": "script_verify_p2sh_p2wsh#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 2825108081, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2SH-P2WSH with all pre-taproot flags", + "request": { + "id": "script_verify_p2sh_p2wsh#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 2825108081, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2SH-P2WSH", + "request": { + "id": "script_verify_p2sh_p2wsh#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2SH-P2WSH transaction", + "request": { + "id": "script_verify_p2sh_p2wsh#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2SH-P2WSH transaction with corrupted signature (one byte flipped in witness)", + "request": { + "id": "script_verify_p2sh_p2wsh#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "020000000001018d30fa8c3023ae9e72f44cea3525b4fe084a816830efb98b605678230cc9c48d0100000023220020a9cd0514e7793003d378df96bbe21c901421ff089ad5598a1a9b5a3cf6eaef0afdffffff0201ed11a60000000017a914194b877577228c0012e4ca3c3780198d8b09d14c87bccb510200000000160014db65e96bfbf0d6ce727ab2518a2f45635367f8b3040047304402202e679780ebe920a1e367482cace23cebaa9d8be7e7d1bd727d7439fb62c8332802203008e33b111161206cd09c947588b43114011a60c7dbaf0679c60d891e38fbb701473044022029233663e8fdbaead30f4ff806018d7ec939505fb4e11cd53195e3ca83f36f5302202010174a3b84d1128272ef1fabf23f1add09e8e074ed2443688a718be86947e40169522102282a387d21d8784fbbf28e6d0cb3f9984996771e7283bd8f5c32dc4b7a961ba8210294586ab0277cae2a8b138527816bf9f36a7203265d83e08bbeaebdd7e1568b2c21030e724028e64b78c0479a35e7c9b4cc3c13456f12ba993a8f19a38ee3b2d7743953ae00000000" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2SH-P2WSH", + "request": { + "id": "script_verify_p2sh_p2wsh#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + } + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2SH-P2WSH with corrupted signature and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS - fails", + "request": { + "id": "script_verify_p2sh_p2wsh#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 2825108081, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify P2SH-P2WSH with corrupted signature and btck_ScriptVerificationFlags_P2SH only - passes (witness not enforced)", + "request": { + "id": "script_verify_p2sh_p2wsh#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 2825108081, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2SH-P2WSH", + "request": { + "id": "script_verify_p2sh_p2wsh#12", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2SH-P2WSH transaction", + "request": { + "id": "script_verify_p2sh_p2wsh#13", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy P2SH-P2WSH script pubkey", + "request": { + "id": "script_verify_p2sh_p2wsh#14", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2tr_keypath.json b/testdata/script_verify_p2tr_keypath.json new file mode 100644 index 0000000..bbb426b --- /dev/null +++ b/testdata/script_verify_p2tr_keypath.json @@ -0,0 +1,325 @@ +{ + "name": "script_verify_p2tr_keypath", + "description": "Verifies a mainnet P2TR key-path spend. Requires one spent output for precomputed transaction data. Valid Schnorr sig passes with P2SH + WITNESS + TAPROOT and all flags; corrupted Schnorr sig fails when TAPROOT is enforced, passes with P2SH + WITNESS only. Mainnet tx 33e794d097969002ee05d336686fc03c9e15a597c1b9827669460fac98799036.", + "stateful": true, + "tests": [ + { + "description": "Create P2TR script pubkey (also used as the spent output's script pubkey)", + "request": { + "id": "script_verify_p2tr_keypath#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "5120339ce7e165e67d93adb3fef88a6d4beed33f01fa876f05a225242b82a631abc0" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create spent output (the UTXO being spent: same P2TR script pubkey, amount=88480)", + "request": { + "id": "script_verify_p2tr_keypath#2", + "method": "btck_transaction_output_create", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 88480 + }, + "ref": "$spent_output" + }, + "expected_response": { + "result": { + "ref": "$spent_output" + } + } + }, + { + "description": "Create valid P2TR key-path transaction", + "request": { + "id": "script_verify_p2tr_keypath#3", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "01000000000101d1f1c1f8cdf6759167b90f52c9ad358a369f95284e841d7a2536cef31c0549580100000000fdffffff020000000000000000316a2f49206c696b65205363686e6f7272207369677320616e6420492063616e6e6f74206c69652e204062697462756734329e06010000000000225120a37c3903c8d0db6512e2b40b0dffa05e5a3ab73603ce8c9c4b7771e5412328f90140a60c383f71bac0ec919b1d7dbc3eb72dd56e7aa99583615564f9f99b8ae4e837b758773a5b2e4c51348854c8389f008e05029db7f464a5ff2e01d5e6e626174affd30a00" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2TR key-path (with spent output for taproot)", + "request": { + "id": "script_verify_p2tr_keypath#4", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + }, + "spent_outputs": [ + { + "ref": "$spent_output" + } + ] + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2TR key-path with btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS + btck_ScriptVerificationFlags_TAPROOT - passes", + "request": { + "id": "script_verify_p2tr_keypath#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 88480, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS", + "btck_ScriptVerificationFlags_TAPROOT" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2TR key-path with all flags - passes", + "request": { + "id": "script_verify_p2tr_keypath#6", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 88480, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS", + "btck_ScriptVerificationFlags_TAPROOT" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2TR key-path", + "request": { + "id": "script_verify_p2tr_keypath#7", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2TR key-path transaction", + "request": { + "id": "script_verify_p2tr_keypath#8", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2TR key-path transaction with corrupted Schnorr signature (one byte flipped)", + "request": { + "id": "script_verify_p2tr_keypath#9", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "01000000000101d1f1c1f8cdf6759167b90f52c9ad358a369f95284e841d7a2536cef31c0549580100000000fdffffff020000000000000000316a2f49206c696b65205363686e6f7272207369677320616e6420492063616e6e6f74206c69652e204062697462756734329e06010000000000225120a37c3903c8d0db6512e2b40b0dffa05e5a3ab73603ce8c9c4b7771e5412328f90140a60c383f71bac0ec919b1d7dbc3eb72dd56e7aa99583615564f9f99b8ae4e837b758772a5b2e4c51348854c8389f008e05029db7f464a5ff2e01d5e6e626174affd30a00" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2TR key-path (with spent output)", + "request": { + "id": "script_verify_p2tr_keypath#10", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "spent_outputs": [ + { + "ref": "$spent_output" + } + ] + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2TR key-path with corrupted signature and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS + btck_ScriptVerificationFlags_TAPROOT - fails", + "request": { + "id": "script_verify_p2tr_keypath#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 88480, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS", + "btck_ScriptVerificationFlags_TAPROOT" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify P2TR key-path with corrupted signature and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS only - passes (taproot not enforced)", + "request": { + "id": "script_verify_p2tr_keypath#12", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 88480, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2TR key-path", + "request": { + "id": "script_verify_p2tr_keypath#13", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2TR key-path transaction", + "request": { + "id": "script_verify_p2tr_keypath#14", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy spent output", + "request": { + "id": "script_verify_p2tr_keypath#15", + "method": "btck_transaction_output_destroy", + "params": { + "transaction_output": { + "ref": "$spent_output" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy P2TR script pubkey", + "request": { + "id": "script_verify_p2tr_keypath#16", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2tr_scriptpath.json b/testdata/script_verify_p2tr_scriptpath.json new file mode 100644 index 0000000..b8d193a --- /dev/null +++ b/testdata/script_verify_p2tr_scriptpath.json @@ -0,0 +1,396 @@ +{ + "name": "script_verify_p2tr_scriptpath", + "description": "Verifies a mainnet P2TR script-path spend at input index 1 of a two-input transaction. Requires two spent outputs for precomputed transaction data. Valid script-path witness passes with P2SH + WITNESS + TAPROOT and all flags; corrupted sig fails when TAPROOT is enforced, passes with P2SH + WITNESS only. Mainnet tx 1ba232a8bf936cf24155292c9a4330298278f572bacc78455eb68e3552197c30.", + "stateful": true, + "tests": [ + { + "description": "Create script pubkey for spent output at index 0", + "request": { + "id": "script_verify_p2tr_scriptpath#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "51207ee3c4ab9c8144be0e39fc849fab95e70da97fb0d70754b34553c25f9d325fa0" + }, + "ref": "$spk_0" + }, + "expected_response": { + "result": { + "ref": "$spk_0" + } + } + }, + { + "description": "Create script pubkey for spent output at index 1 (the P2TR output being verified)", + "request": { + "id": "script_verify_p2tr_scriptpath#2", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "5120e687f4f55e3de5264cf4c4f43b53edb5c26e4adae3a3098ce918a663582785bd" + }, + "ref": "$spk_1" + }, + "expected_response": { + "result": { + "ref": "$spk_1" + } + } + }, + { + "description": "Create spent output at index 0 (amount=1757828)", + "request": { + "id": "script_verify_p2tr_scriptpath#3", + "method": "btck_transaction_output_create", + "params": { + "script_pubkey": { + "ref": "$spk_0" + }, + "amount": 1757828 + }, + "ref": "$spent_output_0" + }, + "expected_response": { + "result": { + "ref": "$spent_output_0" + } + } + }, + { + "description": "Create spent output at index 1 (the P2TR output being spent, amount=503185)", + "request": { + "id": "script_verify_p2tr_scriptpath#4", + "method": "btck_transaction_output_create", + "params": { + "script_pubkey": { + "ref": "$spk_1" + }, + "amount": 503185 + }, + "ref": "$spent_output_1" + }, + "expected_response": { + "result": { + "ref": "$spent_output_1" + } + } + }, + { + "description": "Create valid P2TR script-path transaction", + "request": { + "id": "script_verify_p2tr_scriptpath#5", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "02000000000102761402258bf42275f52db288dbbc8fdfe30b35dea86c5425a57feef1a4008b0b0100000000ffffffff3847ba0ccc4e1b63ed2f3b4a677bd247940f4d5669cc91d9a4eb096e7615badc0000000000ffffffff0291ad070000000000225120059715a12766bbbee8529b53dce51fe708e9895f50c6babec988c7917ff5958464d11a0000000000225120bee1246f13735551e5e5c2b5631014501a6c77f8ee2d16d33dc109096f22b2a40140ac4e4af854be645890275c8144869343752d5ceee9b361cfab3de0726c10a449cc7491a295417f7c457961fdde59bde483330364b42fddddeef65cd1d97150fc0440b78c0a5065343d451a93dcb499edd3d8994697932322be5e27fa218f5a99be8484a8ef802c3054dee442baced3c170b8afe18ec9758c860876fe4f06a5e3ccb240984299fc968b71d999354af2e991e089908adec84e1b1f04da8149aa0ffce28311b363dfd2dfc456de77746919c263e95a14952080f433ddb87b13b884812bda4420b5095be39b9f2f96a77235854af7635dd09d0324569e9b3d587fe5fb7c44720cad202b74c2011af089c849383ee527c72325de52df6a788428b68d49e9174053aabaac41c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0675a94484b3d55d76af4a2275d327a47c1ec5c7d2232596a09fc883d40bb237e00000000" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2TR script-path (with both spent outputs for taproot)", + "request": { + "id": "script_verify_p2tr_scriptpath#6", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + }, + "spent_outputs": [ + { + "ref": "$spent_output_0" + }, + { + "ref": "$spent_output_1" + } + ] + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2TR script-path at input index 1 with btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS + btck_ScriptVerificationFlags_TAPROOT - passes", + "request": { + "id": "script_verify_p2tr_scriptpath#7", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk_1" + }, + "amount": 503185, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS", + "btck_ScriptVerificationFlags_TAPROOT" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2TR script-path at input index 1 with all flags - passes", + "request": { + "id": "script_verify_p2tr_scriptpath#8", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk_1" + }, + "amount": 503185, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS", + "btck_ScriptVerificationFlags_TAPROOT" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2TR script-path", + "request": { + "id": "script_verify_p2tr_scriptpath#9", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2TR script-path transaction", + "request": { + "id": "script_verify_p2tr_scriptpath#10", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2TR script-path transaction with corrupted signature (one byte flipped in script-path witness)", + "request": { + "id": "script_verify_p2tr_scriptpath#11", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "02000000000102761402258bf42275f52db288dbbc8fdfe30b35dea86c5425a57feef1a4008b0b0100000000ffffffff3847ba0ccc4e1b63ed2f3b4a677bd247940f4d5669cc91d9a4eb096e7615badc0000000000ffffffff0291ad070000000000225120059715a12766bbbee8529b53dce51fe708e9895f50c6babec988c7917ff5958464d11a0000000000225120bee1246f13735551e5e5c2b5631014501a6c77f8ee2d16d33dc109096f22b2a40140ac4e4af854be645890275c8144869343752d5ceee9b361cfab3de0726c10a449cc7491a295417f7c457961fdde59bde483330364b42fddddeef65cd1d97150fc0440b78c0a5065343d451a93dcb499edd3d8994697932322be5e27fa218f5a99be8484a8ef802c3054dee442baced3c170b8afe18ec9758c860876fe4f06a5e3ccb240984299fc968b71d999354af2e991e089908adec84e1b1f04da8149aa0ffce28211b363dfd2dfc456de77746919c263e95a14952080f433ddb87b13b884812bda4420b5095be39b9f2f96a77235854af7635dd09d0324569e9b3d587fe5fb7c44720cad202b74c2011af089c849383ee527c72325de52df6a788428b68d49e9174053aabaac41c150929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0675a94484b3d55d76af4a2275d327a47c1ec5c7d2232596a09fc883d40bb237e00000000" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2TR script-path (with both spent outputs)", + "request": { + "id": "script_verify_p2tr_scriptpath#12", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "spent_outputs": [ + { + "ref": "$spent_output_0" + }, + { + "ref": "$spent_output_1" + } + ] + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2TR script-path with corrupted signature at input index 1 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS + btck_ScriptVerificationFlags_TAPROOT - fails", + "request": { + "id": "script_verify_p2tr_scriptpath#13", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk_1" + }, + "amount": 503185, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS", + "btck_ScriptVerificationFlags_TAPROOT" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify P2TR script-path with corrupted signature at input index 1 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS only - passes (taproot not enforced)", + "request": { + "id": "script_verify_p2tr_scriptpath#14", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk_1" + }, + "amount": 503185, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2TR script-path", + "request": { + "id": "script_verify_p2tr_scriptpath#15", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2TR script-path transaction", + "request": { + "id": "script_verify_p2tr_scriptpath#16", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy spent output at index 0", + "request": { + "id": "script_verify_p2tr_scriptpath#17", + "method": "btck_transaction_output_destroy", + "params": { + "transaction_output": { + "ref": "$spent_output_0" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy spent output at index 1", + "request": { + "id": "script_verify_p2tr_scriptpath#18", + "method": "btck_transaction_output_destroy", + "params": { + "transaction_output": { + "ref": "$spent_output_1" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy script pubkey for spent output at index 0", + "request": { + "id": "script_verify_p2tr_scriptpath#19", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk_0" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy script pubkey for spent output at index 1", + "request": { + "id": "script_verify_p2tr_scriptpath#20", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk_1" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2wpkh.json b/testdata/script_verify_p2wpkh.json new file mode 100644 index 0000000..e1b13ae --- /dev/null +++ b/testdata/script_verify_p2wpkh.json @@ -0,0 +1,213 @@ +{ + "name": "script_verify_p2wpkh", + "description": "Verifies a mainnet native P2WPKH output with two amount values: correct amount (5003 sat) passes with P2SH + WITNESS and all pre-taproot flags; wrong amount (5002 sat) fails the witness commitment check when WITNESS is enforced, passes with P2SH only. Mainnet tx 00000000102d4e899ec7cc3656d91ab83aa8e95807dabb90fbe16a1a9e70b6ab.", + "stateful": true, + "tests": [ + { + "description": "Create native P2WPKH script pubkey", + "request": { + "id": "script_verify_p2wpkh#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "0014141e536966344275512b7c2f49be5b8fbe7fbd05" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create native P2WPKH transaction", + "request": { + "id": "script_verify_p2wpkh#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "0200000000010118cd99a3898c2b63da66ec9b7e1d15928453a0b3c2fa74fd74883042000000000000000000ffffffff011d13000000000000160014f222ad02300df72ab7129602f279b47d83b453ca02483045022100b1da3d290132155acd68dafee7c794e84922f364cf9acb1b65e806dc41bd702b02200af6003caf19a291488649be0396edb1274888beb5bb3a96e1d8e6f4903e0e7401210364b35b722e1e3590575994dad5c6c25b8b24d3777964a28cedea41bbaa297da555d2d73d" + }, + "ref": "$tx" + }, + "expected_response": { + "result": { + "ref": "$tx" + } + } + }, + { + "description": "Create precomputed transaction data for native P2WPKH", + "request": { + "id": "script_verify_p2wpkh#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx" + } + }, + "ref": "$precomp" + }, + "expected_response": { + "result": { + "ref": "$precomp" + } + } + }, + { + "description": "Verify native P2WPKH with correct amount (5003) and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS - passes", + "request": { + "id": "script_verify_p2wpkh#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 5003, + "tx_to": { + "ref": "$tx" + }, + "precomputed_txdata": { + "ref": "$precomp" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify native P2WPKH with correct amount (5003) and all pre-taproot flags - passes", + "request": { + "id": "script_verify_p2wpkh#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 5003, + "tx_to": { + "ref": "$tx" + }, + "precomputed_txdata": { + "ref": "$precomp" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify native P2WPKH with wrong amount (5002) and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS - fails (amount mismatch in witness commitment)", + "request": { + "id": "script_verify_p2wpkh#6", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 5002, + "tx_to": { + "ref": "$tx" + }, + "precomputed_txdata": { + "ref": "$precomp" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify native P2WPKH with wrong amount (5002) and btck_ScriptVerificationFlags_P2SH only - passes (witness not enforced)", + "request": { + "id": "script_verify_p2wpkh#7", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 5002, + "tx_to": { + "ref": "$tx" + }, + "precomputed_txdata": { + "ref": "$precomp" + }, + "input_index": 0, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for native P2WPKH", + "request": { + "id": "script_verify_p2wpkh#8", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy native P2WPKH transaction", + "request": { + "id": "script_verify_p2wpkh#9", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy native P2WPKH script pubkey", + "request": { + "id": "script_verify_p2wpkh#10", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_p2wsh.json b/testdata/script_verify_p2wsh.json new file mode 100644 index 0000000..932cd4b --- /dev/null +++ b/testdata/script_verify_p2wsh.json @@ -0,0 +1,277 @@ +{ + "name": "script_verify_p2wsh", + "description": "Verifies a mainnet native P2WSH output at input index 1 of a two-input transaction. Valid HTLC-style witness script passes with P2SH + WITNESS and all pre-taproot flags; corrupted witness sig fails with WITNESS enforced, passes with P2SH only. Mainnet tx 12fc05be6778b06e77191e8fb18fee632b2d92efa0b6830e1cf63e28723a8b8f.", + "stateful": true, + "tests": [ + { + "description": "Create native P2WSH script pubkey", + "request": { + "id": "script_verify_p2wsh#1", + "method": "btck_script_pubkey_create", + "params": { + "script_pubkey": "0020b38c970d115bffbc7d16c5f3fc858cefe3448c8d141a679b65554de78a88a0cd" + }, + "ref": "$spk" + }, + "expected_response": { + "result": { + "ref": "$spk" + } + } + }, + { + "description": "Create valid P2WSH transaction", + "request": { + "id": "script_verify_p2wsh#2", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "01000000000102e1434357ad4d08274ed106e21f2694d35000b46e66b1dd714d63e9cd3f2ab4740000000000ffffffffb9de6f14166a841772ec53c6e384adb3dc151ba1e7b2c0a92cc9f194690be1240000000000ffffffff0198282d0000000000160014c95362dd904e547af461dbf4cc4d251a8fa1295205483045022100c8553375207dd6ef92439a22707a268629b4af08ae94d02e92c8acc355f5911902207ed6b01a97a9cc52c1fb8c6c6999b27e9c34f703a03917d8a640a45e0589ed9901210200c503dc20b66731af9d189f0a0981b148b40cb2c26f3ff15cc90037b812b6e22017e3c268fe7c34ea02effd3975038fc09ce0326b063fe0ec9356b6f558ba55ff0101616382012088a820be72730c5ba3ae4d924ef26be8a20b2e820d63916bb9db4f38214f739b897e1d8876a9148d1fe4411b3cd3a0bccafb8b57ee0c071e5abd79670428c18969b17576a914bec3dacae92ec1cd60843a8704119b0e202c6d346888ac05483045022100ae691ea4c91edf52f44e56e4f53d1ab6bb2562bb34f4f56f4f0003ea52f91fa7022001ca8196e6961b29cff64e1b5ac8917ba90a162f8230860bbc7b050624578fb701210200c503dc20b66731af9d189f0a0981b148b40cb2c26f3ff15cc90037b812b6e220362fc6c6a5b56532c27f701a067eda066ec2be426b5cd696a3a030abffc446ce0101616382012088a820360537c727eed2694b8d5493c1b0b5d79289042af10f6cdb3361f14d3fab523e8876a9148d1fe4411b3cd3a0bccafb8b57ee0c071e5abd7967043cc18969b17576a914ad27aa467040ddf17bbea8be0794e3e6953c09066888ac00000000" + }, + "ref": "$tx_valid" + }, + "expected_response": { + "result": { + "ref": "$tx_valid" + } + } + }, + { + "description": "Create precomputed transaction data for valid P2WSH", + "request": { + "id": "script_verify_p2wsh#3", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_valid" + } + }, + "ref": "$precomp_valid" + }, + "expected_response": { + "result": { + "ref": "$precomp_valid" + } + } + }, + { + "description": "Verify valid P2WSH at input index 1 with btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS", + "request": { + "id": "script_verify_p2wsh#4", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1480000, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Verify valid P2WSH at input index 1 with all pre-taproot flags", + "request": { + "id": "script_verify_p2wsh#5", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1480000, + "tx_to": { + "ref": "$tx_valid" + }, + "precomputed_txdata": { + "ref": "$precomp_valid" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_DERSIG", + "btck_ScriptVerificationFlags_NULLDUMMY", + "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", + "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for valid P2WSH", + "request": { + "id": "script_verify_p2wsh#6", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy valid P2WSH transaction", + "request": { + "id": "script_verify_p2wsh#7", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_valid" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Create P2WSH transaction with corrupted signature (one byte flipped in second witness)", + "request": { + "id": "script_verify_p2wsh#8", + "method": "btck_transaction_create", + "params": { + "raw_transaction": "01000000000102e1434357ad4d08274ed106e21f2694d35000b46e66b1dd714d63e9cd3f2ab4740000000000ffffffffb9de6f14166a841772ec53c6e384adb3dc151ba1e7b2c0a92cc9f194690be1240000000000ffffffff0198282d0000000000160014c95362dd904e547af461dbf4cc4d251a8fa1295205483045022100c8553375207dd6ef92439a22707a268629b4af08ae94d02e92c8acc355f5911902207ed6b01a97a9cc52c1fb8c6c6999b27e9c34f703a03917d8a640a45e0589ed9901210200c503dc20b66731af9d189f0a0981b148b40cb2c26f3ff15cc90037b812b6e22017e3c268fe7c34ea02effd3975038fc09ce0326b063fe0ec9356b6f558ba55ff0101616382012088a820be72730c5ba3ae4d924ef26be8a20b2e820d63916bb9db4f38214f739b897e1d8876a9148d1fe4411b3cd3a0bccafb8b57ee0c071e5abd79670428c18969b17576a914bec3dacae92ec1cd60843a8704119b0e202c6d346888ac05483045022100ae691ea4c91edf52f44e56e4f53d1ab6bb2562bb34f4f56f4f0003ea52f91fa7022001ca2196e6961b29cff64e1b5ac8917ba90a162f8230860bbc7b050624578fb701210200c503dc20b66731af9d189f0a0981b148b40cb2c26f3ff15cc90037b812b6e220362fc6c6a5b56532c27f701a067eda066ec2be426b5cd696a3a030abffc446ce0101616382012088a820360537c727eed2694b8d5493c1b0b5d79289042af10f6cdb3361f14d3fab523e8876a9148d1fe4411b3cd3a0bccafb8b57ee0c071e5abd7967043cc18969b17576a914ad27aa467040ddf17bbea8be0794e3e6953c09066888ac00000000" + }, + "ref": "$tx_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$tx_corrupted_sig" + } + } + }, + { + "description": "Create precomputed transaction data for corrupted sig P2WSH", + "request": { + "id": "script_verify_p2wsh#9", + "method": "btck_precomputed_transaction_data_create", + "params": { + "tx_to": { + "ref": "$tx_corrupted_sig" + } + }, + "ref": "$precomp_corrupted_sig" + }, + "expected_response": { + "result": { + "ref": "$precomp_corrupted_sig" + } + } + }, + { + "description": "Verify P2WSH with corrupted signature at input index 1 and btck_ScriptVerificationFlags_P2SH + btck_ScriptVerificationFlags_WITNESS - fails", + "request": { + "id": "script_verify_p2wsh#10", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1480000, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH", + "btck_ScriptVerificationFlags_WITNESS" + ] + } + }, + "expected_response": { + "result": false + } + }, + { + "description": "Verify P2WSH with corrupted signature at input index 1 and btck_ScriptVerificationFlags_P2SH only - passes (witness not enforced)", + "request": { + "id": "script_verify_p2wsh#11", + "method": "btck_script_pubkey_verify", + "params": { + "script_pubkey": { + "ref": "$spk" + }, + "amount": 1480000, + "tx_to": { + "ref": "$tx_corrupted_sig" + }, + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + }, + "input_index": 1, + "flags": [ + "btck_ScriptVerificationFlags_P2SH" + ] + } + }, + "expected_response": { + "result": true + } + }, + { + "description": "Destroy precomputed transaction data for corrupted sig P2WSH", + "request": { + "id": "script_verify_p2wsh#12", + "method": "btck_precomputed_transaction_data_destroy", + "params": { + "precomputed_txdata": { + "ref": "$precomp_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy corrupted sig P2WSH transaction", + "request": { + "id": "script_verify_p2wsh#13", + "method": "btck_transaction_destroy", + "params": { + "transaction": { + "ref": "$tx_corrupted_sig" + } + } + }, + "expected_response": { + "result": null + } + }, + { + "description": "Destroy native P2WSH script pubkey", + "request": { + "id": "script_verify_p2wsh#14", + "method": "btck_script_pubkey_destroy", + "params": { + "script_pubkey": { + "ref": "$spk" + } + } + }, + "expected_response": { + "result": null + } + } + ] +} diff --git a/testdata/script_verify_success.json b/testdata/script_verify_success.json deleted file mode 100644 index 7a9a384..0000000 --- a/testdata/script_verify_success.json +++ /dev/null @@ -1,156 +0,0 @@ -{ - "name": "Successful Script Verification Cases", - "description": "Test cases where the script verification operation executes successfully and returns a boolean result (true for valid scripts, false for invalid scripts)", - "tests": [ - { - "description": "Valid legacy P2PKH (Pay-to-PubKey-Hash) transaction verification", - "request": { - "id": "valid_p2pkh_legacy", - "method": "btck_script_pubkey_verify", - "params": { - "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ac", - "amount": 0, - "tx_to": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700", - "input_index": 0, - "flags": [ - "btck_ScriptVerificationFlags_P2SH", - "btck_ScriptVerificationFlags_DERSIG", - "btck_ScriptVerificationFlags_NULLDUMMY", - "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", - "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", - "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [] - } - }, - "expected_response": { - "result": true - } - }, - { - "description": "Valid P2SH-wrapped SegWit transaction verification", - "request": { - "id": "valid_p2sh_wrapped_segwit", - "method": "btck_script_pubkey_verify", - "params": { - "script_pubkey": "a91434c06f8c87e355e123bdc6dda4ffabc64b6989ef87", - "amount": 1900000, - "tx_to": "01000000000101d9fd94d0ff0026d307c994d0003180a5f248146efb6371d040c5973f5f66d9df0400000017160014b31b31a6cb654cfab3c50567bcf124f48a0beaecffffffff012cbd1c000000000017a914233b74bf0823fa58bbbd26dfc3bb4ae715547167870247304402206f60569cac136c114a58aedd80f6fa1c51b49093e7af883e605c212bdafcd8d202200e91a55f408a021ad2631bc29a67bd6915b2d7e9ef0265627eabd7f7234455f6012103e7e802f50344303c76d12c089c8724c1b230e3b745693bbe16aad536293d15e300000000", - "input_index": 0, - "flags": [ - "btck_ScriptVerificationFlags_P2SH", - "btck_ScriptVerificationFlags_DERSIG", - "btck_ScriptVerificationFlags_NULLDUMMY", - "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", - "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", - "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [] - } - }, - "expected_response": { - "result": true - } - }, - { - "description": "Valid native SegWit (P2WPKH) transaction verification", - "request": { - "id": "valid_native_segwit_p2wpkh", - "method": "btck_script_pubkey_verify", - "params": { - "script_pubkey": "0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d", - "amount": 18393430, - "tx_to": "010000000001011f97548fbbe7a0db7588a66e18d803d0089315aa7d4cc28360b6ec50ef36718a0100000000ffffffff02df1776000000000017a9146c002a686959067f4866b8fb493ad7970290ab728757d29f0000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220565d170eed95ff95027a69b313758450ba84a01224e1f7f130dda46e94d13f8602207bdd20e307f062594022f12ed5017bbf4a055a06aea91c10110a0e3bb23117fc014730440220647d2dc5b15f60bc37dc42618a370b2a1490293f9e5c8464f53ec4fe1dfe067302203598773895b4b16d37485cbe21b337f4e4b650739880098c592553add7dd4355016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000", - "input_index": 0, - "flags": [ - "btck_ScriptVerificationFlags_P2SH", - "btck_ScriptVerificationFlags_DERSIG", - "btck_ScriptVerificationFlags_NULLDUMMY", - "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", - "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", - "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [] - } - }, - "expected_response": { - "result": true - } - }, - { - "description": "P2PKH script verification fails due to wrong signature (malformed final opcode)", - "request": { - "id": "error_invalid_p2pkh_wrong_signature", - "method": "btck_script_pubkey_verify", - "params": { - "script_pubkey": "76a9144bfbaf6afb76cc5771bc6404810d1cc041a6933988ff", - "amount": 0, - "tx_to": "02000000013f7cebd65c27431a90bba7f796914fe8cc2ddfc3f2cbd6f7e5f2fc854534da95000000006b483045022100de1ac3bcdfb0332207c4a91f3832bd2c2915840165f876ab47c5f8996b971c3602201c6c053d750fadde599e6f5c4e1963df0f01fc0d97815e8157e3d59fe09ca30d012103699b464d1d8bc9e47d4fb1cdaa89a1c5783d68363c4dbc4b524ed3d857148617feffffff02836d3c01000000001976a914fc25d6d5c94003bf5b0c7b640a248e2c637fcfb088ac7ada8202000000001976a914fbed3d9b11183209a57999d54d59f67c019e756c88ac6acb0700", - "input_index": 0, - "flags": [ - "btck_ScriptVerificationFlags_P2SH", - "btck_ScriptVerificationFlags_DERSIG", - "btck_ScriptVerificationFlags_NULLDUMMY", - "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", - "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", - "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [] - } - }, - "expected_response": { - "result": false - } - }, - { - "description": "P2SH-wrapped SegWit verification fails due to incorrect amount", - "request": { - "id": "error_invalid_p2sh_segwit_wrong_amount", - "method": "btck_script_pubkey_verify", - "params": { - "script_pubkey": "a91434c06f8c87e355e123bdc6dda4ffabc64b6989ef87", - "amount": 900000, - "tx_to": "01000000000101d9fd94d0ff0026d307c994d0003180a5f248146efb6371d040c5973f5f66d9df0400000017160014b31b31a6cb654cfab3c50567bcf124f48a0beaecffffffff012cbd1c000000000017a914233b74bf0823fa58bbbd26dfc3bb4ae715547167870247304402206f60569cac136c114a58aedd80f6fa1c51b49093e7af883e605c212bdafcd8d202200e91a55f408a021ad2631bc29a67bd6915b2d7e9ef0265627eabd7f7234455f6012103e7e802f50344303c76d12c089c8724c1b230e3b745693bbe16aad536293d15e300000000", - "input_index": 0, - "flags": [ - "btck_ScriptVerificationFlags_P2SH", - "btck_ScriptVerificationFlags_DERSIG", - "btck_ScriptVerificationFlags_NULLDUMMY", - "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", - "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", - "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [] - } - }, - "expected_response": { - "result": false - } - }, - { - "description": "Native SegWit verification fails due to malformed witness script hash", - "request": { - "id": "error_invalid_native_segwit_wrong_script", - "method": "btck_script_pubkey_verify", - "params": { - "script_pubkey": "0020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58f", - "amount": 18393430, - "tx_to": "010000000001011f97548fbbe7a0db7588a66e18d803d0089315aa7d4cc28360b6ec50ef36718a0100000000ffffffff02df1776000000000017a9146c002a686959067f4866b8fb493ad7970290ab728757d29f0000000000220020701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d04004730440220565d170eed95ff95027a69b313758450ba84a01224e1f7f130dda46e94d13f8602207bdd20e307f062594022f12ed5017bbf4a055a06aea91c10110a0e3bb23117fc014730440220647d2dc5b15f60bc37dc42618a370b2a1490293f9e5c8464f53ec4fe1dfe067302203598773895b4b16d37485cbe21b337f4e4b650739880098c592553add7dd4355016952210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae00000000", - "input_index": 0, - "flags": [ - "btck_ScriptVerificationFlags_P2SH", - "btck_ScriptVerificationFlags_DERSIG", - "btck_ScriptVerificationFlags_NULLDUMMY", - "btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY", - "btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY", - "btck_ScriptVerificationFlags_WITNESS" - ], - "spent_outputs": [] - } - }, - "expected_response": { - "result": false - } - } - ] -}