input_script: return txin.scriptSig if available. replace txin.is_coinbase with type. fixes #2321

This commit is contained in:
ThomasV 2017-03-21 09:08:16 +01:00
parent fdee755198
commit 1d84029173
6 changed files with 14 additions and 13 deletions

View File

@ -242,7 +242,7 @@ class TxDialog(QDialog, MessageBoxMixin):
i_text.setMaximumHeight(100)
cursor = i_text.textCursor()
for x in self.tx.inputs():
if x.get('is_coinbase'):
if x['type'] == 'coinbase':
cursor.insertText('coinbase')
else:
prevout_hash = x.get('prevout_hash')

View File

@ -409,15 +409,14 @@ def parse_input(vds):
prevout_hash = hash_encode(vds.read_bytes(32))
prevout_n = vds.read_uint32()
scriptSig = vds.read_bytes(vds.read_compact_size())
d['scriptSig'] = scriptSig.encode('hex')
sequence = vds.read_uint32()
d['scriptSig'] = scriptSig.encode('hex')
d['prevout_hash'] = prevout_hash
d['prevout_n'] = prevout_n
d['sequence'] = sequence
if prevout_hash == '00'*32:
d['is_coinbase'] = True
d['type'] = 'coinbase'
else:
d['is_coinbase'] = False
d['prevout_hash'] = prevout_hash
d['prevout_n'] = prevout_n
d['sequence'] = sequence
d['pubkeys'] = []
d['signatures'] = {}
d['address'] = None
@ -637,6 +636,8 @@ class Transaction:
@classmethod
def input_script(self, txin, estimate_size=False):
if txin.get('scriptSig'):
return txin['scriptSig']
_type = txin['type']
pubkeys, sig_list = self.get_siglist(txin, estimate_size)
script = ''.join(push_script(x) for x in sig_list)
@ -796,7 +797,7 @@ class Transaction:
r = 0
s = 0
for txin in self.inputs():
if txin.get('is_coinbase'):
if txin['type'] == 'coinbase':
continue
signatures = filter(None, txin.get('signatures',[]))
s += len(signatures)

View File

@ -582,13 +582,13 @@ class Abstract_Wallet(PrintError):
return addr
def add_transaction(self, tx_hash, tx):
is_coinbase = tx.inputs()[0].get('is_coinbase') == True
is_coinbase = tx.inputs()[0]['type'] == 'coinbase'
with self.transaction_lock:
# add inputs
self.txi[tx_hash] = d = {}
for txi in tx.inputs():
addr = txi.get('address')
if not txi.get('is_coinbase'):
if txi['type'] != 'coinbase':
prevout_hash = txi['prevout_hash']
prevout_n = txi['prevout_n']
ser = prevout_hash + ':%d'%prevout_n

View File

@ -366,7 +366,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
# Build hasharray from inputs
for i, txin in enumerate(tx.inputs()):
if txin.get('is_coinbase'):
if txin['type'] == 'coinbase':
self.give_error("Coinbase not supported") # should never happen
if txin['type'] in ['p2sh']:

View File

@ -275,7 +275,7 @@ class Ledger_KeyStore(Hardware_KeyStore):
# Fetch inputs of the transaction to sign
derivations = self.get_tx_derivations(tx)
for txin in tx.inputs():
if txin.get('is_coinbase'):
if txin['type'] == 'coinbase':
self.give_error("Coinbase not supported") # should never happen
if txin['type'] in ['p2sh']:

View File

@ -259,7 +259,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
inputs = []
for txin in tx.inputs():
txinputtype = self.types.TxInputType()
if txin.get('is_coinbase'):
if txin['type'] == 'coinbase':
prev_hash = "\0"*32
prev_index = 0xffffffff # signed int -1
else: