create coinbase transaction
This commit is contained in:
parent
a5de8d2c2d
commit
aa63120489
@ -600,19 +600,20 @@ class Block():
|
|||||||
self.target = None
|
self.target = None
|
||||||
self.fee = 0
|
self.fee = 0
|
||||||
self.witness_root_hash = None
|
self.witness_root_hash = None
|
||||||
if txs[0].coinbase:
|
if txs:
|
||||||
if version > 1:
|
if txs[0].coinbase:
|
||||||
self.height = int.from_bytes(txs[0].tx_in[0].sig_script.raw[1:5], "little")
|
if version > 1:
|
||||||
self.coinbase = txs[0].tx_in[0].sig_script.raw[5:]
|
self.height = int.from_bytes(txs[0].tx_in[0].sig_script.raw[1:5], "little")
|
||||||
else:
|
self.coinbase = txs[0].tx_in[0].sig_script.raw[5:]
|
||||||
self.coinbase = txs[0].tx_in[0].sig_script.raw
|
else:
|
||||||
try:
|
self.coinbase = txs[0].tx_in[0].sig_script.raw
|
||||||
for out in txs[0].tx_out:
|
try:
|
||||||
if out.pk_script.ntype == 3:
|
for out in txs[0].tx_out:
|
||||||
if b'\xaa!\xa9\xed' == out.pk_script.data[:4]:
|
if out.pk_script.ntype == 3:
|
||||||
self.witness_root_hash = out.pk_script.data[4:36]
|
if b'\xaa!\xa9\xed' == out.pk_script.data[:4]:
|
||||||
except:
|
self.witness_root_hash = out.pk_script.data[4:36]
|
||||||
pass
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def calculate_commitment(self, witness = None):
|
def calculate_commitment(self, witness = None):
|
||||||
wtxid_list = [b"\x00" * 32,]
|
wtxid_list = [b"\x00" * 32,]
|
||||||
|
|||||||
@ -439,7 +439,8 @@ def merkle_branches(tx_hash_list):
|
|||||||
if len(new_hash_list) > 1:
|
if len(new_hash_list) > 1:
|
||||||
tx_hash_list = new_hash_list
|
tx_hash_list = new_hash_list
|
||||||
else:
|
else:
|
||||||
branches.append(new_hash_list.pop(0))
|
if new_hash_list:
|
||||||
|
branches.append(new_hash_list.pop(0))
|
||||||
return branches
|
return branches
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user