1010 NORMAL_GBT_REQUEST_PARAMS ,
1111 add_witness_commitment ,
1212 create_block ,
13+ script_to_p2wsh_script ,
1314)
1415from test_framework .messages import (
1516 COIN ,
1617 COutPoint ,
1718 CTransaction ,
1819 CTxIn ,
20+ CTxInWitness ,
1921 CTxOut ,
2022 tx_from_hex ,
2123)
24+ from test_framework .script import (
25+ CScript ,
26+ OP_TRUE ,
27+ )
2228from test_framework .test_framework import BitcoinTestFramework
2329from test_framework .util import (
2430 assert_equal ,
2531 assert_greater_than ,
2632 assert_raises_rpc_error ,
2733 softfork_active ,
2834)
29- from test_framework .script_util import DUMMY_P2WPKH_SCRIPT
35+
36+ SCRIPT_W0_SH_OP_TRUE = script_to_p2wsh_script (CScript ([OP_TRUE ]))
3037
3138SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31 )
3239SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22 ) # this means use time (0 means height)
@@ -42,11 +49,9 @@ def set_test_params(self):
4249 self .extra_args = [
4350 [
4451 '-testactivationheight=csv@432' ,
45- "-acceptnonstdtxn=1" ,
4652 ],
4753 [
4854 '-testactivationheight=csv@432' ,
49- "-acceptnonstdtxn=0" ,
5055 ],
5156 ]
5257
@@ -100,7 +105,7 @@ def test_disable_flag(self):
100105 # input to mature.
101106 sequence_value = SEQUENCE_LOCKTIME_DISABLE_FLAG | 1
102107 tx1 .vin = [CTxIn (COutPoint (int (utxo ["txid" ], 16 ), utxo ["vout" ]), nSequence = sequence_value )]
103- tx1 .vout = [CTxOut (value , DUMMY_P2WPKH_SCRIPT )]
108+ tx1 .vout = [CTxOut (value , SCRIPT_W0_SH_OP_TRUE )]
104109
105110 tx1_signed = self .nodes [0 ].signrawtransactionwithwallet (tx1 .serialize ().hex ())["hex" ]
106111 tx1_id = self .nodes [0 ].sendrawtransaction (tx1_signed )
@@ -112,7 +117,9 @@ def test_disable_flag(self):
112117 tx2 .nVersion = 2
113118 sequence_value = sequence_value & 0x7fffffff
114119 tx2 .vin = [CTxIn (COutPoint (tx1_id , 0 ), nSequence = sequence_value )]
115- tx2 .vout = [CTxOut (int (value - self .relayfee * COIN ), DUMMY_P2WPKH_SCRIPT )]
120+ tx2 .wit .vtxinwit = [CTxInWitness ()]
121+ tx2 .wit .vtxinwit [0 ].scriptWitness .stack = [CScript ([OP_TRUE ])]
122+ tx2 .vout = [CTxOut (int (value - self .relayfee * COIN ), SCRIPT_W0_SH_OP_TRUE )]
116123 tx2 .rehash ()
117124
118125 assert_raises_rpc_error (- 26 , NOT_FINAL_ERROR , self .nodes [0 ].sendrawtransaction , tx2 .serialize ().hex ())
@@ -207,7 +214,7 @@ def test_sequence_lock_confirmed_inputs(self):
207214 value += utxos [j ]["amount" ]* COIN
208215 # Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
209216 tx_size = len (tx .serialize ().hex ())// 2 + 120 * num_inputs + 50
210- tx .vout .append (CTxOut (int (value - self .relayfee * tx_size * COIN / 1000 ), DUMMY_P2WPKH_SCRIPT ))
217+ tx .vout .append (CTxOut (int (value - self .relayfee * tx_size * COIN / 1000 ), SCRIPT_W0_SH_OP_TRUE ))
211218 rawtx = self .nodes [0 ].signrawtransactionwithwallet (tx .serialize ().hex ())["hex" ]
212219
213220 if (using_sequence_locks and not should_pass ):
@@ -236,7 +243,7 @@ def test_sequence_lock_unconfirmed_inputs(self):
236243 tx2 = CTransaction ()
237244 tx2 .nVersion = 2
238245 tx2 .vin = [CTxIn (COutPoint (tx1 .sha256 , 0 ), nSequence = 0 )]
239- tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), DUMMY_P2WPKH_SCRIPT )]
246+ tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), SCRIPT_W0_SH_OP_TRUE )]
240247 tx2_raw = self .nodes [0 ].signrawtransactionwithwallet (tx2 .serialize ().hex ())["hex" ]
241248 tx2 = tx_from_hex (tx2_raw )
242249 tx2 .rehash ()
@@ -254,7 +261,9 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
254261 tx = CTransaction ()
255262 tx .nVersion = 2
256263 tx .vin = [CTxIn (COutPoint (orig_tx .sha256 , 0 ), nSequence = sequence_value )]
257- tx .vout = [CTxOut (int (orig_tx .vout [0 ].nValue - relayfee * COIN ), DUMMY_P2WPKH_SCRIPT )]
264+ tx .wit .vtxinwit = [CTxInWitness ()]
265+ tx .wit .vtxinwit [0 ].scriptWitness .stack = [CScript ([OP_TRUE ])]
266+ tx .vout = [CTxOut (int (orig_tx .vout [0 ].nValue - relayfee * COIN ), SCRIPT_W0_SH_OP_TRUE )]
258267 tx .rehash ()
259268
260269 if (orig_tx .hash in node .getrawmempool ()):
@@ -367,7 +376,7 @@ def test_bip68_not_consensus(self):
367376 tx2 = CTransaction ()
368377 tx2 .nVersion = 1
369378 tx2 .vin = [CTxIn (COutPoint (tx1 .sha256 , 0 ), nSequence = 0 )]
370- tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), DUMMY_P2WPKH_SCRIPT )]
379+ tx2 .vout = [CTxOut (int (tx1 .vout [0 ].nValue - self .relayfee * COIN ), SCRIPT_W0_SH_OP_TRUE )]
371380
372381 # sign tx2
373382 tx2_raw = self .nodes [0 ].signrawtransactionwithwallet (tx2 .serialize ().hex ())["hex" ]
@@ -382,7 +391,9 @@ def test_bip68_not_consensus(self):
382391 tx3 = CTransaction ()
383392 tx3 .nVersion = 2
384393 tx3 .vin = [CTxIn (COutPoint (tx2 .sha256 , 0 ), nSequence = sequence_value )]
385- tx3 .vout = [CTxOut (int (tx2 .vout [0 ].nValue - self .relayfee * COIN ), DUMMY_P2WPKH_SCRIPT )]
394+ tx3 .wit .vtxinwit = [CTxInWitness ()]
395+ tx3 .wit .vtxinwit [0 ].scriptWitness .stack = [CScript ([OP_TRUE ])]
396+ tx3 .vout = [CTxOut (int (tx2 .vout [0 ].nValue - self .relayfee * COIN ), SCRIPT_W0_SH_OP_TRUE )]
386397 tx3 .rehash ()
387398
388399 assert_raises_rpc_error (- 26 , NOT_FINAL_ERROR , self .nodes [0 ].sendrawtransaction , tx3 .serialize ().hex ())
0 commit comments