@@ -109,7 +109,6 @@ def run_test(self):
109109 # Create a new block
110110 b_dup_cb = self .next_block ('dup_cb' )
111111 b_dup_cb .vtx [0 ].vin [0 ].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
112- b_dup_cb .vtx [0 ].rehash ()
113112 duplicate_tx = b_dup_cb .vtx [0 ]
114113 b_dup_cb = self .update_block ('dup_cb' , [])
115114 self .send_blocks ([b_dup_cb ])
@@ -194,7 +193,6 @@ def run_test(self):
194193 badtx = template .get_tx ()
195194 if TxTemplate != invalid_txs .InputMissing :
196195 self .sign_tx (badtx , attempt_spend_tx )
197- badtx .rehash ()
198196 badblock = self .update_block (blockname , [badtx ])
199197 self .send_blocks (
200198 [badblock ], success = False ,
@@ -385,7 +383,6 @@ def run_test(self):
385383 self .move_tip (15 )
386384 b26 = self .next_block (26 , spend = out [6 ])
387385 b26 .vtx [0 ].vin [0 ].scriptSig = b'\x00 '
388- b26 .vtx [0 ].rehash ()
389386 # update_block causes the merkle root to get updated, even with no new
390387 # transactions, and updates the required state.
391388 b26 = self .update_block (26 , [])
@@ -399,7 +396,6 @@ def run_test(self):
399396 self .move_tip (15 )
400397 b28 = self .next_block (28 , spend = out [6 ])
401398 b28 .vtx [0 ].vin [0 ].scriptSig = b'\x00 ' * 101
402- b28 .vtx [0 ].rehash ()
403399 b28 = self .update_block (28 , [])
404400 self .send_blocks ([b28 ], success = False , reject_reason = 'bad-cb-length' , reconnect = True )
405401
@@ -413,7 +409,6 @@ def run_test(self):
413409 b30 .vtx [0 ].vin [0 ].scriptSig = bytes (b30 .vtx [0 ].vin [0 ].scriptSig ) # Convert CScript to raw bytes
414410 b30 .vtx [0 ].vin [0 ].scriptSig += b'\x00 ' * (100 - len (b30 .vtx [0 ].vin [0 ].scriptSig )) # Fill with 0s
415411 assert_equal (len (b30 .vtx [0 ].vin [0 ].scriptSig ), 100 )
416- b30 .vtx [0 ].rehash ()
417412 b30 = self .update_block (30 , [])
418413 self .send_blocks ([b30 ], True )
419414 self .save_spendable_output ()
@@ -516,7 +511,6 @@ def run_test(self):
516511 tx = self .create_tx (spend , 0 , 1 , p2sh_script )
517512 tx .vout .append (CTxOut (spend .vout [0 ].nValue - 1 , CScript ([OP_TRUE ])))
518513 self .sign_tx (tx , spend )
519- tx .rehash ()
520514 b39 = self .update_block (39 , [tx ])
521515 b39_outputs += 1
522516
@@ -527,7 +521,6 @@ def run_test(self):
527521 while total_weight < MAX_BLOCK_WEIGHT :
528522 tx_new = self .create_tx (tx_last , 1 , 1 , p2sh_script )
529523 tx_new .vout .append (CTxOut (tx_last .vout [1 ].nValue - 1 , CScript ([OP_TRUE ])))
530- tx_new .rehash ()
531524 total_weight += tx_new .get_weight ()
532525 if total_weight >= MAX_BLOCK_WEIGHT :
533526 break
@@ -579,7 +572,6 @@ def run_test(self):
579572 tx = CTransaction ()
580573 tx .vin .append (CTxIn (lastOutpoint , b'' ))
581574 tx .vout .append (CTxOut (1 , CScript ([OP_CHECKSIG ] * b40_sigops_to_fill )))
582- tx .rehash ()
583575 new_txs .append (tx )
584576 self .update_block (40 , new_txs )
585577 self .send_blocks ([b40 ], success = False , reject_reason = 'bad-blk-sigops' , reconnect = True )
@@ -593,7 +585,6 @@ def run_test(self):
593585 tx = CTransaction ()
594586 tx .vin .append (CTxIn (lastOutpoint , b'' ))
595587 tx .vout .append (CTxOut (1 , CScript ([OP_CHECKSIG ] * b41_sigops_to_fill )))
596- tx .rehash ()
597588 self .update_block (41 , [tx ])
598589 self .send_blocks ([b41 ], True )
599590
@@ -833,7 +824,6 @@ def run_test(self):
833824 assert len (out [17 ].vout ) < 42
834825 tx .vin .append (CTxIn (COutPoint (out [17 ].sha256 , 42 ), CScript ([OP_TRUE ]), SEQUENCE_FINAL ))
835826 tx .vout .append (CTxOut (0 , b"" ))
836- tx .calc_sha256 ()
837827 b58 = self .update_block (58 , [tx ])
838828 self .send_blocks ([b58 ], success = False , reject_reason = 'bad-txns-inputs-missingorspent' , reconnect = True )
839829
@@ -865,7 +855,6 @@ def run_test(self):
865855 b61 = self .next_block (61 )
866856 b61 .vtx [0 ].nLockTime = 0
867857 b61 .vtx [0 ].vin [0 ].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
868- b61 .vtx [0 ].rehash ()
869858 b61 = self .update_block (61 , [])
870859 assert_equal (duplicate_tx .serialize (), b61 .vtx [0 ].serialize ())
871860 # BIP30 is always checked on regtest, regardless of the BIP34 activation height
@@ -882,13 +871,11 @@ def run_test(self):
882871 tx .vin .append (CTxIn (COutPoint (duplicate_tx .sha256 , 0 )))
883872 tx .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
884873 self .sign_tx (tx , duplicate_tx )
885- tx .rehash ()
886874 b_spend_dup_cb = self .update_block ('spend_dup_cb' , [tx ])
887875
888876 b_dup_2 = self .next_block ('dup_2' )
889877 b_dup_2 .vtx [0 ].nLockTime = 0
890878 b_dup_2 .vtx [0 ].vin [0 ].scriptSig = DUPLICATE_COINBASE_SCRIPT_SIG
891- b_dup_2 .vtx [0 ].rehash ()
892879 b_dup_2 = self .update_block ('dup_2' , [])
893880 assert_equal (duplicate_tx .serialize (), b_dup_2 .vtx [0 ].serialize ())
894881 assert_equal (self .nodes [0 ].gettxout (txid = duplicate_tx .hash , n = 0 )['confirmations' ], 119 )
@@ -909,7 +896,6 @@ def run_test(self):
909896 tx .vin .append (CTxIn (COutPoint (out [18 ].sha256 , 0 ))) # don't set nSequence
910897 tx .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
911898 assert_greater_than (SEQUENCE_FINAL , tx .vin [0 ].nSequence )
912- tx .calc_sha256 ()
913899 b62 = self .update_block (62 , [tx ])
914900 self .send_blocks ([b62 ], success = False , reject_reason = 'bad-txns-nonfinal' , reconnect = True )
915901
@@ -923,7 +909,6 @@ def run_test(self):
923909 b63 = self .next_block (63 )
924910 b63 .vtx [0 ].nLockTime = 0xffffffff
925911 b63 .vtx [0 ].vin [0 ].nSequence = 0xDEADBEEF
926- b63 .vtx [0 ].rehash ()
927912 b63 = self .update_block (63 , [])
928913 self .send_blocks ([b63 ], success = False , reject_reason = 'bad-txns-nonfinal' , reconnect = True )
929914
@@ -1241,7 +1226,6 @@ def run_test(self):
12411226
12421227 tx2 = self .create_and_sign_transaction (tx1 , 0 , CScript ([OP_TRUE ]))
12431228 tx2 .vin [0 ].scriptSig = CScript ([OP_FALSE ])
1244- tx2 .rehash ()
12451229
12461230 b83 = self .update_block (83 , [tx1 , tx2 ])
12471231 self .send_blocks ([b83 ], True )
@@ -1259,9 +1243,7 @@ def run_test(self):
12591243 tx1 .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
12601244 tx1 .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
12611245 tx1 .vout .append (CTxOut (0 , CScript ([OP_TRUE ])))
1262- tx1 .calc_sha256 ()
12631246 self .sign_tx (tx1 , out [29 ])
1264- tx1 .rehash ()
12651247 tx2 = self .create_tx (tx1 , 1 , 0 , CScript ([OP_RETURN ]))
12661248 tx2 .vout .append (CTxOut (0 , CScript ([OP_RETURN ])))
12671249 tx3 = self .create_tx (tx1 , 2 , 0 , CScript ([OP_RETURN ]))
@@ -1347,7 +1329,6 @@ def run_test(self):
13471329 self .move_tip (chain1_tip + 2 )
13481330 b_cb34 = self .next_block ('b_cb34' )
13491331 b_cb34 .vtx [0 ].vin [0 ].scriptSig = b_cb34 .vtx [0 ].vin [0 ].scriptSig [:- 1 ]
1350- b_cb34 .vtx [0 ].rehash ()
13511332 b_cb34 .hashMerkleRoot = b_cb34 .calc_merkle_root ()
13521333 b_cb34 .solve ()
13531334 self .send_blocks ([b_cb34 ], success = False , reject_reason = 'bad-cb-height' , reconnect = True )
@@ -1356,7 +1337,6 @@ def run_test(self):
13561337 ################
13571338
13581339 def add_transactions_to_block (self , block , tx_list ):
1359- [tx .rehash () for tx in tx_list ]
13601340 block .vtx .extend (tx_list )
13611341
13621342 # 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):
13791359 output_script = CScript ([OP_TRUE ])
13801360 tx = self .create_tx (spend_tx , 0 , value , output_script = output_script )
13811361 self .sign_tx (tx , spend_tx )
1382- tx .rehash ()
13831362 return tx
13841363
13851364 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=
13991378 coinbase .vout [0 ].nValue += additional_coinbase_value
14001379 for additional_script in additional_output_scripts :
14011380 coinbase .vout .append (CTxOut (0 , additional_script ))
1402- coinbase .rehash ()
14031381 if spend is None :
14041382 block = create_block (base_block_hash , coinbase , block_time , version = version )
14051383 else :
14061384 coinbase .vout [0 ].nValue += spend .vout [0 ].nValue - 1 # all but one satoshi to fees
1407- coinbase .rehash ()
14081385 tx = self .create_tx (spend , 0 , 1 , output_script = script ) # spend 1 satoshi
14091386 self .sign_tx (tx , spend )
1410- tx .rehash ()
14111387 block = create_block (base_block_hash , coinbase , block_time , version = version , txlist = [tx ])
14121388 # Block is created. Find a valid nonce.
14131389 block .solve ()
0 commit comments