@@ -109,7 +109,6 @@ def run_test(self):
109
109
# Create a new block
110
110
b_dup_cb = self .next_block ('dup_cb' )
111
111
b_dup_cb .vtx [0 ].vin [0 ].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
112
- b_dup_cb .vtx [0 ].rehash ()
113
112
duplicate_tx = b_dup_cb .vtx [0 ]
114
113
b_dup_cb = self .update_block ('dup_cb' , [])
115
114
self .send_blocks ([b_dup_cb ])
@@ -194,7 +193,6 @@ def run_test(self):
194
193
badtx = template .get_tx ()
195
194
if TxTemplate != invalid_txs .InputMissing :
196
195
self .sign_tx (badtx , attempt_spend_tx )
197
- badtx .rehash ()
198
196
badblock = self .update_block (blockname , [badtx ])
199
197
self .send_blocks (
200
198
[badblock ], success = False ,
@@ -385,7 +383,6 @@ def run_test(self):
385
383
self .move_tip (15 )
386
384
b26 = self .next_block (26 , spend = out [6 ])
387
385
b26 .vtx [0 ].vin [0 ].scriptSig = b'\x00 '
388
- b26 .vtx [0 ].rehash ()
389
386
# update_block causes the merkle root to get updated, even with no new
390
387
# transactions, and updates the required state.
391
388
b26 = self .update_block (26 , [])
@@ -399,7 +396,6 @@ def run_test(self):
399
396
self .move_tip (15 )
400
397
b28 = self .next_block (28 , spend = out [6 ])
401
398
b28 .vtx [0 ].vin [0 ].scriptSig = b'\x00 ' * 101
402
- b28 .vtx [0 ].rehash ()
403
399
b28 = self .update_block (28 , [])
404
400
self .send_blocks ([b28 ], success = False , reject_reason = 'bad-cb-length' , reconnect = True )
405
401
@@ -413,7 +409,6 @@ def run_test(self):
413
409
b30 .vtx [0 ].vin [0 ].scriptSig = bytes (b30 .vtx [0 ].vin [0 ].scriptSig ) # Convert CScript to raw bytes
414
410
b30 .vtx [0 ].vin [0 ].scriptSig += b'\x00 ' * (100 - len (b30 .vtx [0 ].vin [0 ].scriptSig )) # Fill with 0s
415
411
assert_equal (len (b30 .vtx [0 ].vin [0 ].scriptSig ), 100 )
416
- b30 .vtx [0 ].rehash ()
417
412
b30 = self .update_block (30 , [])
418
413
self .send_blocks ([b30 ], True )
419
414
self .save_spendable_output ()
@@ -516,7 +511,6 @@ def run_test(self):
516
511
tx = self .create_tx (spend , 0 , 1 , p2sh_script )
517
512
tx .vout .append (CTxOut (spend .vout [0 ].nValue - 1 , CScript ([OP_TRUE ])))
518
513
self .sign_tx (tx , spend )
519
- tx .rehash ()
520
514
b39 = self .update_block (39 , [tx ])
521
515
b39_outputs += 1
522
516
@@ -527,7 +521,6 @@ def run_test(self):
527
521
while total_weight < MAX_BLOCK_WEIGHT :
528
522
tx_new = self .create_tx (tx_last , 1 , 1 , p2sh_script )
529
523
tx_new .vout .append (CTxOut (tx_last .vout [1 ].nValue - 1 , CScript ([OP_TRUE ])))
530
- tx_new .rehash ()
531
524
total_weight += tx_new .get_weight ()
532
525
if total_weight >= MAX_BLOCK_WEIGHT :
533
526
break
@@ -579,7 +572,6 @@ def run_test(self):
579
572
tx = CTransaction ()
580
573
tx .vin .append (CTxIn (lastOutpoint , b'' ))
581
574
tx .vout .append (CTxOut (1 , CScript ([OP_CHECKSIG ] * b40_sigops_to_fill )))
582
- tx .rehash ()
583
575
new_txs .append (tx )
584
576
self .update_block (40 , new_txs )
585
577
self .send_blocks ([b40 ], success = False , reject_reason = 'bad-blk-sigops' , reconnect = True )
@@ -593,7 +585,6 @@ def run_test(self):
593
585
tx = CTransaction ()
594
586
tx .vin .append (CTxIn (lastOutpoint , b'' ))
595
587
tx .vout .append (CTxOut (1 , CScript ([OP_CHECKSIG ] * b41_sigops_to_fill )))
596
- tx .rehash ()
597
588
self .update_block (41 , [tx ])
598
589
self .send_blocks ([b41 ], True )
599
590
@@ -833,7 +824,6 @@ def run_test(self):
833
824
assert len (out [17 ].vout ) < 42
834
825
tx .vin .append (CTxIn (COutPoint (out [17 ].sha256 , 42 ), CScript ([OP_TRUE ]), SEQUENCE_FINAL ))
835
826
tx .vout .append (CTxOut (0 , b"" ))
836
- tx .calc_sha256 ()
837
827
b58 = self .update_block (58 , [tx ])
838
828
self .send_blocks ([b58 ], success = False , reject_reason = 'bad-txns-inputs-missingorspent' , reconnect = True )
839
829
@@ -865,7 +855,6 @@ def run_test(self):
865
855
b61 = self .next_block (61 )
866
856
b61 .vtx [0 ].nLockTime = 0
867
857
b61 .vtx [0 ].vin [0 ].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
868
- b61 .vtx [0 ].rehash ()
869
858
b61 = self .update_block (61 , [])
870
859
assert_equal (duplicate_tx .serialize (), b61 .vtx [0 ].serialize ())
871
860
# BIP30 is always checked on regtest, regardless of the BIP34 activation height
@@ -882,13 +871,11 @@ def run_test(self):
882
871
tx .vin .append (CTxIn (COutPoint (duplicate_tx .sha256 , 0 )))
883
872
tx .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
884
873
self .sign_tx (tx , duplicate_tx )
885
- tx .rehash ()
886
874
b_spend_dup_cb = self .update_block ('spend_dup_cb' , [tx ])
887
875
888
876
b_dup_2 = self .next_block ('dup_2' )
889
877
b_dup_2 .vtx [0 ].nLockTime = 0
890
878
b_dup_2 .vtx [0 ].vin [0 ].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
891
- b_dup_2 .vtx [0 ].rehash ()
892
879
b_dup_2 = self .update_block ('dup_2' , [])
893
880
assert_equal (duplicate_tx .serialize (), b_dup_2 .vtx [0 ].serialize ())
894
881
assert_equal (self .nodes [0 ].gettxout (txid = duplicate_tx .hash , n = 0 )['confirmations' ], 119 )
@@ -909,7 +896,6 @@ def run_test(self):
909
896
tx .vin .append (CTxIn (COutPoint (out [18 ].sha256 , 0 ))) # don't set nSequence
910
897
tx .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
911
898
assert_greater_than (SEQUENCE_FINAL , tx .vin [0 ].nSequence )
912
- tx .calc_sha256 ()
913
899
b62 = self .update_block (62 , [tx ])
914
900
self .send_blocks ([b62 ], success = False , reject_reason = 'bad-txns-nonfinal' , reconnect = True )
915
901
@@ -923,7 +909,6 @@ def run_test(self):
923
909
b63 = self .next_block (63 )
924
910
b63 .vtx [0 ].nLockTime = 0xffffffff
925
911
b63 .vtx [0 ].vin [0 ].nSequence = 0xDEADBEEF
926
- b63 .vtx [0 ].rehash ()
927
912
b63 = self .update_block (63 , [])
928
913
self .send_blocks ([b63 ], success = False , reject_reason = 'bad-txns-nonfinal' , reconnect = True )
929
914
@@ -1241,7 +1226,6 @@ def run_test(self):
1241
1226
1242
1227
tx2 = self .create_and_sign_transaction (tx1 , 0 , CScript ([OP_TRUE ]))
1243
1228
tx2 .vin [0 ].scriptSig = CScript ([OP_FALSE ])
1244
- tx2 .rehash ()
1245
1229
1246
1230
b83 = self .update_block (83 , [tx1 , tx2 ])
1247
1231
self .send_blocks ([b83 ], True )
@@ -1259,9 +1243,7 @@ def run_test(self):
1259
1243
tx1 .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
1260
1244
tx1 .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
1261
1245
tx1 .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
1262
- tx1 .calc_sha256 ()
1263
1246
self .sign_tx (tx1 , out [29 ])
1264
- tx1 .rehash ()
1265
1247
tx2 = self .create_tx (tx1 , 1 , 0 , CScript ([OP_RETURN ]))
1266
1248
tx2 .vout .append (CTxOut (0 , CScript ([OP_RETURN ])))
1267
1249
tx3 = self .create_tx (tx1 , 2 , 0 , CScript ([OP_RETURN ]))
@@ -1347,7 +1329,6 @@ def run_test(self):
1347
1329
self .move_tip (chain1_tip + 2 )
1348
1330
b_cb34 = self .next_block ('b_cb34' )
1349
1331
b_cb34 .vtx [0 ].vin [0 ].scriptSig = b_cb34 .vtx [0 ].vin [0 ].scriptSig [:- 1 ]
1350
- b_cb34 .vtx [0 ].rehash ()
1351
1332
b_cb34 .hashMerkleRoot = b_cb34 .calc_merkle_root ()
1352
1333
b_cb34 .solve ()
1353
1334
self .send_blocks ([b_cb34 ], success = False , reject_reason = 'bad-cb-height' , reconnect = True )
@@ -1356,7 +1337,6 @@ def run_test(self):
1356
1337
################
1357
1338
1358
1339
def add_transactions_to_block (self , block , tx_list ):
1359
- [tx .rehash () for tx in tx_list ]
1360
1340
block .vtx .extend (tx_list )
1361
1341
1362
1342
# this is a little handier to use than the version in blocktools.py
@@ -1379,7 +1359,6 @@ def create_and_sign_transaction(self, spend_tx, value, output_script=None):
1379
1359
output_script = CScript ([OP_TRUE ])
1380
1360
tx = self .create_tx (spend_tx , 0 , value , output_script = output_script )
1381
1361
self .sign_tx (tx , spend_tx )
1382
- tx .rehash ()
1383
1362
return tx
1384
1363
1385
1364
def next_block (self , number , spend = None , additional_coinbase_value = 0 , * , script = None , version = 4 , additional_output_scripts = None ):
@@ -1399,15 +1378,12 @@ def next_block(self, number, spend=None, additional_coinbase_value=0, *, script=
1399
1378
coinbase .vout [0 ].nValue += additional_coinbase_value
1400
1379
for additional_script in additional_output_scripts :
1401
1380
coinbase .vout .append (CTxOut (0 , additional_script ))
1402
- coinbase .rehash ()
1403
1381
if spend is None :
1404
1382
block = create_block (base_block_hash , coinbase , block_time , version = version )
1405
1383
else :
1406
1384
coinbase .vout [0 ].nValue += spend .vout [0 ].nValue - 1 # all but one satoshi to fees
1407
- coinbase .rehash ()
1408
1385
tx = self .create_tx (spend , 0 , 1 , output_script = script ) # spend 1 satoshi
1409
1386
self .sign_tx (tx , spend )
1410
- tx .rehash ()
1411
1387
block = create_block (base_block_hash , coinbase , block_time , version = version , txlist = [tx ])
1412
1388
# Block is created. Find a valid nonce.
1413
1389
block .solve ()
0 commit comments