@@ -452,10 +452,10 @@ def serialize_with_witness(self):
452452 r += struct .pack ("<I" , self .nLockTime )
453453 return r
454454
455- # Regular serialization is without witness -- must explicitly
456- # call serialize_with_witness to include witness data.
455+ # Regular serialization is with witness -- must explicitly
456+ # call serialize_without_witness to exclude witness data.
457457 def serialize (self ):
458- return self .serialize_without_witness ()
458+ return self .serialize_with_witness ()
459459
460460 # Recalculate the txid (transaction hash without witness)
461461 def rehash (self ):
@@ -471,7 +471,7 @@ def calc_sha256(self, with_witness=False):
471471
472472 if self .sha256 is None :
473473 self .sha256 = uint256_from_str (hash256 (self .serialize_without_witness ()))
474- self .hash = encode (hash256 (self .serialize ())[::- 1 ], 'hex_codec' ).decode ('ascii' )
474+ self .hash = encode (hash256 (self .serialize_without_witness ())[::- 1 ], 'hex_codec' ).decode ('ascii' )
475475
476476 def is_valid (self ):
477477 self .calc_sha256 ()
@@ -568,7 +568,7 @@ def serialize(self, with_witness=False):
568568 if with_witness :
569569 r += ser_vector (self .vtx , "serialize_with_witness" )
570570 else :
571- r += ser_vector (self .vtx )
571+ r += ser_vector (self .vtx , "serialize_without_witness" )
572572 return r
573573
574574 # Calculate the merkle root given a vector of transaction hashes
@@ -635,7 +635,7 @@ def deserialize(self, f):
635635 self .tx = CTransaction ()
636636 self .tx .deserialize (f )
637637
638- def serialize (self , with_witness = False ):
638+ def serialize (self , with_witness = True ):
639639 r = b""
640640 r += ser_compact_size (self .index )
641641 if with_witness :
@@ -644,6 +644,9 @@ def serialize(self, with_witness=False):
644644 r += self .tx .serialize_without_witness ()
645645 return r
646646
647+ def serialize_without_witness (self ):
648+ return self .serialize (with_witness = False )
649+
647650 def serialize_with_witness (self ):
648651 return self .serialize (with_witness = True )
649652
@@ -683,7 +686,7 @@ def serialize(self, with_witness=False):
683686 if with_witness :
684687 r += ser_vector (self .prefilled_txn , "serialize_with_witness" )
685688 else :
686- r += ser_vector (self .prefilled_txn )
689+ r += ser_vector (self .prefilled_txn , "serialize_without_witness" )
687690 return r
688691
689692 def __repr__ (self ):
@@ -814,13 +817,13 @@ def deserialize(self, f):
814817 self .blockhash = deser_uint256 (f )
815818 self .transactions = deser_vector (f , CTransaction )
816819
817- def serialize (self , with_witness = False ):
820+ def serialize (self , with_witness = True ):
818821 r = b""
819822 r += ser_uint256 (self .blockhash )
820823 if with_witness :
821824 r += ser_vector (self .transactions , "serialize_with_witness" )
822825 else :
823- r += ser_vector (self .transactions )
826+ r += ser_vector (self .transactions , "serialize_without_witness" )
824827 return r
825828
826829 def __repr__ (self ):
@@ -1020,7 +1023,7 @@ def deserialize(self, f):
10201023 self .block .deserialize (f )
10211024
10221025 def serialize (self ):
1023- return self .block .serialize ()
1026+ return self .block .serialize (with_witness = False )
10241027
10251028 def __repr__ (self ):
10261029 return "msg_block(block=%s)" % (repr (self .block ))
@@ -1291,7 +1294,7 @@ def deserialize(self, f):
12911294
12921295 def serialize (self ):
12931296 r = b""
1294- r += self .block_transactions .serialize ()
1297+ r += self .block_transactions .serialize (with_witness = False )
12951298 return r
12961299
12971300 def __repr__ (self ):
0 commit comments