10
10
NORMAL_GBT_REQUEST_PARAMS ,
11
11
add_witness_commitment ,
12
12
create_block ,
13
+ script_to_p2wsh_script ,
13
14
)
14
15
from test_framework .messages import (
15
16
COIN ,
16
17
COutPoint ,
17
18
CTransaction ,
18
19
CTxIn ,
20
+ CTxInWitness ,
19
21
CTxOut ,
20
22
tx_from_hex ,
21
23
)
24
+ from test_framework .script import (
25
+ CScript ,
26
+ OP_TRUE ,
27
+ )
22
28
from test_framework .test_framework import BitcoinTestFramework
23
29
from test_framework .util import (
24
30
assert_equal ,
25
31
assert_greater_than ,
26
32
assert_raises_rpc_error ,
27
33
softfork_active ,
28
34
)
29
- from test_framework .script_util import DUMMY_P2WPKH_SCRIPT
35
+
36
+ SCRIPT_W0_SH_OP_TRUE = script_to_p2wsh_script (CScript ([OP_TRUE ]))
30
37
31
38
SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31 )
32
39
SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22 ) # this means use time (0 means height)
@@ -42,11 +49,9 @@ def set_test_params(self):
42
49
self .extra_args = [
43
50
[
44
51
'-testactivationheight=csv@432' ,
45
- "-acceptnonstdtxn=1" ,
46
52
],
47
53
[
48
54
'-testactivationheight=csv@432' ,
49
- "-acceptnonstdtxn=0" ,
50
55
],
51
56
]
52
57
@@ -100,7 +105,7 @@ def test_disable_flag(self):
100
105
# input to mature.
101
106
sequence_value = SEQUENCE_LOCKTIME_DISABLE_FLAG | 1
102
107
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 )]
104
109
105
110
tx1_signed = self .nodes [0 ].signrawtransactionwithwallet (tx1 .serialize ().hex ())["hex" ]
106
111
tx1_id = self .nodes [0 ].sendrawtransaction (tx1_signed )
@@ -112,7 +117,9 @@ def test_disable_flag(self):
112
117
tx2 .nVersion = 2
113
118
sequence_value = sequence_value & 0x7fffffff
114
119
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 )]
116
123
tx2 .rehash ()
117
124
118
125
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):
207
214
value += utxos [j ]["amount" ]* COIN
208
215
# Overestimate the size of the tx - signatures should be less than 120 bytes, and leave 50 for the output
209
216
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 ))
211
218
rawtx = self .nodes [0 ].signrawtransactionwithwallet (tx .serialize ().hex ())["hex" ]
212
219
213
220
if (using_sequence_locks and not should_pass ):
@@ -236,7 +243,7 @@ def test_sequence_lock_unconfirmed_inputs(self):
236
243
tx2 = CTransaction ()
237
244
tx2 .nVersion = 2
238
245
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 )]
240
247
tx2_raw = self .nodes [0 ].signrawtransactionwithwallet (tx2 .serialize ().hex ())["hex" ]
241
248
tx2 = tx_from_hex (tx2_raw )
242
249
tx2 .rehash ()
@@ -254,7 +261,9 @@ def test_nonzero_locks(orig_tx, node, relayfee, use_height_lock):
254
261
tx = CTransaction ()
255
262
tx .nVersion = 2
256
263
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 )]
258
267
tx .rehash ()
259
268
260
269
if (orig_tx .hash in node .getrawmempool ()):
@@ -367,7 +376,7 @@ def test_bip68_not_consensus(self):
367
376
tx2 = CTransaction ()
368
377
tx2 .nVersion = 1
369
378
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 )]
371
380
372
381
# sign tx2
373
382
tx2_raw = self .nodes [0 ].signrawtransactionwithwallet (tx2 .serialize ().hex ())["hex" ]
@@ -382,7 +391,9 @@ def test_bip68_not_consensus(self):
382
391
tx3 = CTransaction ()
383
392
tx3 .nVersion = 2
384
393
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 )]
386
397
tx3 .rehash ()
387
398
388
399
assert_raises_rpc_error (- 26 , NOT_FINAL_ERROR , self .nodes [0 ].sendrawtransaction , tx3 .serialize ().hex ())
0 commit comments