mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-20 01:19:49 +00:00
handle coinbase transactions explicitly
This commit is contained in:
parent
ace15d3e7e
commit
86917c2ff3
2 changed files with 36 additions and 28 deletions
|
@ -192,8 +192,11 @@ class TxDialog(QDialog):
|
||||||
|
|
||||||
vbox.addWidget(QLabel(_("Inputs")))
|
vbox.addWidget(QLabel(_("Inputs")))
|
||||||
def format_input(x):
|
def format_input(x):
|
||||||
_hash = x.get('prevout_hash')
|
if x.get('is_coinbase'):
|
||||||
return _hash[0:16] + '...' + _hash[-8:] + ":%d"%x.get('prevout_n') + u'\t' + "%s"%x.get('address')
|
return 'coinbase'
|
||||||
|
else:
|
||||||
|
_hash = x.get('prevout_hash')
|
||||||
|
return _hash[0:16] + '...' + _hash[-8:] + ":%d"%x.get('prevout_n') + u'\t' + "%s"%x.get('address')
|
||||||
lines = map(format_input, self.tx.inputs )
|
lines = map(format_input, self.tx.inputs )
|
||||||
i_text = QTextEdit()
|
i_text = QTextEdit()
|
||||||
i_text.setText('\n'.join(lines))
|
i_text.setText('\n'.join(lines))
|
||||||
|
|
|
@ -314,10 +314,14 @@ def get_address_from_input_script(bytes):
|
||||||
match = [ opcodes.OP_PUSHDATA4, opcodes.OP_PUSHDATA4 ]
|
match = [ opcodes.OP_PUSHDATA4, opcodes.OP_PUSHDATA4 ]
|
||||||
if match_decoded(decoded, match):
|
if match_decoded(decoded, match):
|
||||||
sig = decoded[0][1].encode('hex')
|
sig = decoded[0][1].encode('hex')
|
||||||
assert sig[-2:] == '01'
|
|
||||||
sig = sig[:-2]
|
|
||||||
pubkey = decoded[1][1].encode('hex')
|
pubkey = decoded[1][1].encode('hex')
|
||||||
return [pubkey], {pubkey:sig}, public_key_to_bc_address(pubkey.decode('hex'))
|
if sig[-2:] == '01':
|
||||||
|
sig = sig[:-2]
|
||||||
|
return [pubkey], {pubkey:sig}, public_key_to_bc_address(pubkey.decode('hex'))
|
||||||
|
else:
|
||||||
|
print_error("cannot find address in input script", bytes.encode('hex'))
|
||||||
|
return [], {}, "(None)"
|
||||||
|
|
||||||
|
|
||||||
# p2sh transaction, 2 of n
|
# p2sh transaction, 2 of n
|
||||||
match = [ opcodes.OP_0 ]
|
match = [ opcodes.OP_0 ]
|
||||||
|
@ -580,21 +584,27 @@ class Transaction:
|
||||||
|
|
||||||
def parse_input(self, vds):
|
def parse_input(self, vds):
|
||||||
d = {}
|
d = {}
|
||||||
d['prevout_hash'] = hash_encode(vds.read_bytes(32))
|
prevout_hash = hash_encode(vds.read_bytes(32))
|
||||||
d['prevout_n'] = vds.read_uint32()
|
prevout_n = vds.read_uint32()
|
||||||
scriptSig = vds.read_bytes(vds.read_compact_size())
|
scriptSig = vds.read_bytes(vds.read_compact_size())
|
||||||
d['sequence'] = vds.read_uint32()
|
sequence = vds.read_uint32()
|
||||||
|
|
||||||
if scriptSig:
|
if prevout_hash == '00'*32:
|
||||||
pubkeys, signatures, address = get_address_from_input_script(scriptSig)
|
d['is_coinbase'] = True
|
||||||
else:
|
else:
|
||||||
pubkeys = []
|
d['is_coinbase'] = False
|
||||||
signatures = {}
|
d['prevout_hash'] = prevout_hash
|
||||||
address = None
|
d['prevout_n'] = prevout_n
|
||||||
|
d['sequence'] = sequence
|
||||||
d['address'] = address
|
if scriptSig:
|
||||||
d['pubkeys'] = pubkeys
|
pubkeys, signatures, address = get_address_from_input_script(scriptSig)
|
||||||
d['signatures'] = signatures
|
else:
|
||||||
|
pubkeys = []
|
||||||
|
signatures = {}
|
||||||
|
address = None
|
||||||
|
d['address'] = address
|
||||||
|
d['pubkeys'] = pubkeys
|
||||||
|
d['signatures'] = signatures
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
@ -688,19 +698,14 @@ class Transaction:
|
||||||
|
|
||||||
|
|
||||||
def get_input_info(self):
|
def get_input_info(self):
|
||||||
|
keys = ['prevout_hash', 'prevout_n', 'address', 'KeyID', 'scriptPubKey', 'redeemScript', 'redeemPubkey', 'pubkeys', 'signatures', 'is_coinbase']
|
||||||
info = []
|
info = []
|
||||||
for i in self.inputs:
|
for i in self.inputs:
|
||||||
item = {
|
item = {}
|
||||||
'prevout_hash':i['prevout_hash'],
|
for k in keys:
|
||||||
'prevout_n':i['prevout_n'],
|
v = i.get(k)
|
||||||
'address':i.get('address'),
|
if v is not None:
|
||||||
'KeyID':i.get('KeyID'),
|
item[k] = v
|
||||||
'scriptPubKey':i.get('scriptPubKey'),
|
|
||||||
'redeemScript':i.get('redeemScript'),
|
|
||||||
'redeemPubkey':i.get('redeemPubkey'),
|
|
||||||
'pubkeys':i.get('pubkeys'),
|
|
||||||
'signatures':i.get('signatures',{}),
|
|
||||||
}
|
|
||||||
info.append(item)
|
info.append(item)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue