88
99from random import randint
1010from test_framework .util import BITCOIN_ASSET_BYTES , assert_raises_rpc_error , satoshi_round
11- from test_framework .key import ECKey , ECPubKey , compute_xonly_pubkey , generate_privkey , sign_schnorr , tweak_add_privkey , tweak_add_pubkey , verify_schnorr
12- from test_framework .messages import COIN , COutPoint , CTransaction , CTxIn , CTxInWitness , CTxOut , CTxOutNonce , CTxOutValue , CTxOutWitness , ser_uint256 , sha256 , tx_from_hex , uint256_from_str
11+ from test_framework .key import ECKey , compute_xonly_pubkey , generate_privkey , sign_schnorr
12+ from test_framework .messages import COIN , COutPoint , CTransaction , CTxIn , CTxInWitness , CTxOut , CTxOutNonce , CTxOutValue , ser_uint256 , sha256 , tx_from_hex
1313from test_framework .test_framework import BitcoinTestFramework
14- from test_framework .script import CScript , CScriptNum , CScriptOp , OP_0 , OP_1 , OP_2 , OP_3 , OP_4 , OP_5 , OP_6 , OP_7 , OP_ADD64 , OP_AND , OP_CAT , OP_CHECKSIGFROMSTACK , OP_DIV64 , OP_DROP , OP_DUP , OP_ECMULSCALARVERIFY , OP_ELSE , OP_EQUAL , OP_EQUALVERIFY , OP_FALSE , OP_FROMALTSTACK , OP_GREATERTHAN64 , OP_GREATERTHANOREQUAL64 , OP_INSPECTINPUTASSET , OP_INSPECTINPUTISSUANCE , OP_INSPECTINPUTOUTPOINT , OP_INSPECTINPUTSCRIPTPUBKEY , OP_INSPECTINPUTSEQUENCE , OP_INSPECTINPUTVALUE , OP_INSPECTLOCKTIME , OP_INSPECTNUMINPUTS , OP_INSPECTNUMOUTPUTS , OP_INSPECTOUTPUTASSET , OP_INSPECTOUTPUTNONCE , OP_INSPECTOUTPUTSCRIPTPUBKEY , OP_INSPECTOUTPUTVALUE , OP_IF , OP_INSPECTVERSION , OP_LE32TOLE64 , OP_LE64TOSCRIPTNUM , OP_LESSTHAN64 , OP_LESSTHANOREQUAL64 , OP_MUL64 , OP_NEG64 , OP_NOT , OP_INVERT , OP_NOTIF , OP_OR , OP_PUSHCURRENTINPUTINDEX , OP_SCRIPTNUMTOLE64 , OP_SHA256FINALIZE , OP_SHA256INITIALIZE , OP_SHA256UPDATE , OP_SIZE , OP_SUB64 , OP_SWAP , OP_TWEAKVERIFY , OP_TOALTSTACK , OP_TXWEIGHT , OP_VERIFY , OP_XOR , OP_XOR , TaprootSignatureHash , taproot_construct , SIGHASH_DEFAULT , SIGHASH_ALL , SIGHASH_NONE , SIGHASH_SINGLE , SIGHASH_ANYONECANPAY
14+ from test_framework .script import CScript , CScriptNum , CScriptOp , OP_0 , OP_1 , OP_2 , OP_ADD64 , OP_AND , OP_CHECKSIGFROMSTACK , OP_DIV64 , OP_DROP , OP_DUP , OP_ECMULSCALARVERIFY , OP_EQUAL , OP_EQUALVERIFY , OP_FALSE , OP_FROMALTSTACK , OP_GREATERTHAN64 , OP_GREATERTHANOREQUAL64 , OP_INSPECTINPUTASSET , OP_INSPECTINPUTISSUANCE , OP_INSPECTINPUTOUTPOINT , OP_INSPECTINPUTSCRIPTPUBKEY , OP_INSPECTINPUTSEQUENCE , OP_INSPECTINPUTVALUE , OP_INSPECTLOCKTIME , OP_INSPECTNUMINPUTS , OP_INSPECTNUMOUTPUTS , OP_INSPECTOUTPUTASSET , OP_INSPECTOUTPUTNONCE , OP_INSPECTOUTPUTSCRIPTPUBKEY , OP_INSPECTOUTPUTVALUE , OP_INSPECTVERSION , OP_LE32TOLE64 , OP_LE64TOSCRIPTNUM , OP_LESSTHAN64 , OP_LESSTHANOREQUAL64 , OP_MUL64 , OP_NEG64 , OP_NOT , OP_INVERT , OP_OR , OP_PUSHCURRENTINPUTINDEX , OP_SCRIPTNUMTOLE64 , OP_SHA256FINALIZE , OP_SHA256INITIALIZE , OP_SHA256UPDATE , OP_SIZE , OP_SUB64 , OP_SWAP , OP_TWEAKVERIFY , OP_TOALTSTACK , OP_TXWEIGHT , OP_VERIFY , OP_XOR , taproot_construct , SIGHASH_DEFAULT , SIGHASH_ALL , SIGHASH_NONE , SIGHASH_SINGLE , SIGHASH_ANYONECANPAY
1515
1616import os
1717
@@ -93,7 +93,7 @@ def create_taproot_utxo(self, scripts = None, blind = False):
9393
9494 tx = self .nodes [0 ].blindrawtransaction (fund_tx .serialize ().hex ())
9595 signed_raw_tx = self .nodes [0 ].signrawtransactionwithwallet (tx )
96- _txid = self .nodes [0 ].sendrawtransaction (signed_raw_tx ['hex' ])
96+ self .nodes [0 ].sendrawtransaction (signed_raw_tx ['hex' ])
9797 tx = tx_from_hex (signed_raw_tx ['hex' ])
9898 tx .rehash ()
9999 self .nodes [0 ].generate (1 )
@@ -102,11 +102,13 @@ def create_taproot_utxo(self, scripts = None, blind = False):
102102
103103 return tx , prev_vout , spk , sec , pub , tap
104104
105- def tapscript_satisfy_test (self , script , inputs = [], add_issuance = False ,
106- add_pegin = False , fail = None , add_prevout = False , add_asset = False ,
107- add_value = False , add_spk = False , seq = 0 , add_out_spk = None ,
108- add_out_asset = None , add_out_value = None , add_out_nonce = None ,
109- ver = 2 , locktime = 0 , add_num_outputs = False , add_weight = False , blind = False ):
105+ def tapscript_satisfy_test (self , script , inputs = None , add_issuance = False ,
106+ add_pegin = False , fail = None , add_prevout = False , add_asset = False ,
107+ add_value = False , add_spk = False , seq = 0 , add_out_spk = None ,
108+ add_out_asset = None , add_out_value = None , add_out_nonce = None ,
109+ ver = 2 , locktime = 0 , add_num_outputs = False , add_weight = False , blind = False ):
110+ if inputs is None :
111+ inputs = []
110112 # Create a taproot utxo
111113 scripts = [("s0" , script )]
112114 prev_tx , prev_vout , spk , sec , pub , tap = self .create_taproot_utxo (scripts )
@@ -387,20 +389,28 @@ def le8(x, signed=True):
387389
388390 def check_add (a , b , c , fail = None ):
389391 self .tapscript_satisfy_test (CScript ([OP_ADD64 , OP_VERIFY , le8 (c ), OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
392+
390393 def check_sub (a , b , c , fail = None ):
391394 self .tapscript_satisfy_test (CScript ([OP_SUB64 , OP_VERIFY , le8 (c ), OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
395+
392396 def check_mul (a , b , c , fail = None ):
393397 self .tapscript_satisfy_test (CScript ([OP_MUL64 , OP_VERIFY , le8 (c ), OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
398+
394399 def check_div (a , b , q , r , fail = None ):
395400 self .tapscript_satisfy_test (CScript ([OP_DIV64 , OP_VERIFY , le8 (q ), OP_EQUALVERIFY , le8 (r ), OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
401+
396402 def check_le (a , b , res , fail = None ):
397403 self .tapscript_satisfy_test (CScript ([OP_LESSTHAN64 , res , OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
404+
398405 def check_leq (a , b , res , fail = None ):
399406 self .tapscript_satisfy_test (CScript ([OP_LESSTHANOREQUAL64 , res , OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
407+
400408 def check_ge (a , b , res , fail = None ):
401409 self .tapscript_satisfy_test (CScript ([OP_GREATERTHAN64 , res , OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
410+
402411 def check_geq (a , b , res , fail = None ):
403412 self .tapscript_satisfy_test (CScript ([OP_GREATERTHANOREQUAL64 , res , OP_EQUAL ]), inputs = [le8 (a ), le8 (b )], fail = fail )
413+
404414 def check_neg (a , res , fail = None ):
405415 self .tapscript_satisfy_test (CScript ([OP_NEG64 , OP_VERIFY , le8 (res ), OP_EQUAL ]), inputs = [le8 (a )], fail = fail )
406416 # Arithematic opcodes
0 commit comments