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