diff --git a/pybtc/blockchain.py b/pybtc/blockchain.py index 2d59f6f..ff731c9 100644 --- a/pybtc/blockchain.py +++ b/pybtc/blockchain.py @@ -335,7 +335,7 @@ class Transaction(): 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') ninputs = to_var_int(self.tx_in_count) inputs = [] @@ -377,7 +377,9 @@ class Transaction(): 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 sighash = self.sighash_segwit(sighash_type, input_index, scriptCode, amount) + print(sighash) signature = sign_message(sighash, private_key) + sighash_type.to_bytes(1,'little') + print(signature) self.witness[input_index] = Witness([signature, pubkey]) self.recalculate_txid()