@@ -452,10 +452,10 @@ def serialize_with_witness(self):
452
452
r += struct .pack ("<I" , self .nLockTime )
453
453
return r
454
454
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.
457
457
def serialize (self ):
458
- return self .serialize_without_witness ()
458
+ return self .serialize_with_witness ()
459
459
460
460
# Recalculate the txid (transaction hash without witness)
461
461
def rehash (self ):
@@ -471,7 +471,7 @@ def calc_sha256(self, with_witness=False):
471
471
472
472
if self .sha256 is None :
473
473
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' )
475
475
476
476
def is_valid (self ):
477
477
self .calc_sha256 ()
@@ -568,7 +568,7 @@ def serialize(self, with_witness=False):
568
568
if with_witness :
569
569
r += ser_vector (self .vtx , "serialize_with_witness" )
570
570
else :
571
- r += ser_vector (self .vtx )
571
+ r += ser_vector (self .vtx , "serialize_without_witness" )
572
572
return r
573
573
574
574
# Calculate the merkle root given a vector of transaction hashes
@@ -635,7 +635,7 @@ def deserialize(self, f):
635
635
self .tx = CTransaction ()
636
636
self .tx .deserialize (f )
637
637
638
- def serialize (self , with_witness = False ):
638
+ def serialize (self , with_witness = True ):
639
639
r = b""
640
640
r += ser_compact_size (self .index )
641
641
if with_witness :
@@ -644,6 +644,9 @@ def serialize(self, with_witness=False):
644
644
r += self .tx .serialize_without_witness ()
645
645
return r
646
646
647
+ def serialize_without_witness (self ):
648
+ return self .serialize (with_witness = False )
649
+
647
650
def serialize_with_witness (self ):
648
651
return self .serialize (with_witness = True )
649
652
@@ -683,7 +686,7 @@ def serialize(self, with_witness=False):
683
686
if with_witness :
684
687
r += ser_vector (self .prefilled_txn , "serialize_with_witness" )
685
688
else :
686
- r += ser_vector (self .prefilled_txn )
689
+ r += ser_vector (self .prefilled_txn , "serialize_without_witness" )
687
690
return r
688
691
689
692
def __repr__ (self ):
@@ -814,13 +817,13 @@ def deserialize(self, f):
814
817
self .blockhash = deser_uint256 (f )
815
818
self .transactions = deser_vector (f , CTransaction )
816
819
817
- def serialize (self , with_witness = False ):
820
+ def serialize (self , with_witness = True ):
818
821
r = b""
819
822
r += ser_uint256 (self .blockhash )
820
823
if with_witness :
821
824
r += ser_vector (self .transactions , "serialize_with_witness" )
822
825
else :
823
- r += ser_vector (self .transactions )
826
+ r += ser_vector (self .transactions , "serialize_without_witness" )
824
827
return r
825
828
826
829
def __repr__ (self ):
@@ -1020,7 +1023,7 @@ def deserialize(self, f):
1020
1023
self .block .deserialize (f )
1021
1024
1022
1025
def serialize (self ):
1023
- return self .block .serialize ()
1026
+ return self .block .serialize (with_witness = False )
1024
1027
1025
1028
def __repr__ (self ):
1026
1029
return "msg_block(block=%s)" % (repr (self .block ))
@@ -1291,7 +1294,7 @@ def deserialize(self, f):
1291
1294
1292
1295
def serialize (self ):
1293
1296
r = b""
1294
- r += self .block_transactions .serialize ()
1297
+ r += self .block_transactions .serialize (with_witness = False )
1295
1298
return r
1296
1299
1297
1300
def __repr__ (self ):
0 commit comments