Segwit deserialize True by default
This commit is contained in:
parent
1b20ae72bd
commit
f50a475370
@ -335,7 +335,7 @@ class Transaction():
|
|||||||
return 'Transaction object [%s] [%s]'% (hexlify(self.hash[::-1]),id(self))
|
return 'Transaction object [%s] [%s]'% (hexlify(self.hash[::-1]),id(self))
|
||||||
|
|
||||||
|
|
||||||
def serialize(self, segwit = False, hex = False):
|
def serialize(self, segwit = True, hex = False):
|
||||||
version = self.version.to_bytes(4,'little')
|
version = self.version.to_bytes(4,'little')
|
||||||
ninputs = to_var_int(self.tx_in_count)
|
ninputs = to_var_int(self.tx_in_count)
|
||||||
inputs = []
|
inputs = []
|
||||||
@ -377,7 +377,9 @@ class Transaction():
|
|||||||
scriptCode += b'\x14' + pubkey_hash160 + OPCODE["OP_EQUALVERIFY"] + OPCODE["OP_CHECKSIG"]
|
scriptCode += b'\x14' + pubkey_hash160 + OPCODE["OP_EQUALVERIFY"] + OPCODE["OP_CHECKSIG"]
|
||||||
self.tx_in[input_index].sig_script = Script(b'\x16\x00\x14' + pubkey_hash160) # P2WPKHredeemScript
|
self.tx_in[input_index].sig_script = Script(b'\x16\x00\x14' + pubkey_hash160) # P2WPKHredeemScript
|
||||||
sighash = self.sighash_segwit(sighash_type, input_index, scriptCode, amount)
|
sighash = self.sighash_segwit(sighash_type, input_index, scriptCode, amount)
|
||||||
|
print(sighash)
|
||||||
signature = sign_message(sighash, private_key) + sighash_type.to_bytes(1,'little')
|
signature = sign_message(sighash, private_key) + sighash_type.to_bytes(1,'little')
|
||||||
|
print(signature)
|
||||||
self.witness[input_index] = Witness([signature, pubkey])
|
self.witness[input_index] = Witness([signature, pubkey])
|
||||||
self.recalculate_txid()
|
self.recalculate_txid()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user