input_script: return txin.scriptSig if available. replace txin.is_coinbase with type. fixes #2321
This commit is contained in:
parent
fdee755198
commit
1d84029173
|
@ -242,7 +242,7 @@ class TxDialog(QDialog, MessageBoxMixin):
|
||||||
i_text.setMaximumHeight(100)
|
i_text.setMaximumHeight(100)
|
||||||
cursor = i_text.textCursor()
|
cursor = i_text.textCursor()
|
||||||
for x in self.tx.inputs():
|
for x in self.tx.inputs():
|
||||||
if x.get('is_coinbase'):
|
if x['type'] == 'coinbase':
|
||||||
cursor.insertText('coinbase')
|
cursor.insertText('coinbase')
|
||||||
else:
|
else:
|
||||||
prevout_hash = x.get('prevout_hash')
|
prevout_hash = x.get('prevout_hash')
|
||||||
|
|
|
@ -409,15 +409,14 @@ def parse_input(vds):
|
||||||
prevout_hash = hash_encode(vds.read_bytes(32))
|
prevout_hash = hash_encode(vds.read_bytes(32))
|
||||||
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['scriptSig'] = scriptSig.encode('hex')
|
|
||||||
sequence = vds.read_uint32()
|
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:
|
if prevout_hash == '00'*32:
|
||||||
d['is_coinbase'] = True
|
d['type'] = 'coinbase'
|
||||||
else:
|
else:
|
||||||
d['is_coinbase'] = False
|
|
||||||
d['prevout_hash'] = prevout_hash
|
|
||||||
d['prevout_n'] = prevout_n
|
|
||||||
d['sequence'] = sequence
|
|
||||||
d['pubkeys'] = []
|
d['pubkeys'] = []
|
||||||
d['signatures'] = {}
|
d['signatures'] = {}
|
||||||
d['address'] = None
|
d['address'] = None
|
||||||
|
@ -637,6 +636,8 @@ class Transaction:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def input_script(self, txin, estimate_size=False):
|
def input_script(self, txin, estimate_size=False):
|
||||||
|
if txin.get('scriptSig'):
|
||||||
|
return txin['scriptSig']
|
||||||
_type = txin['type']
|
_type = txin['type']
|
||||||
pubkeys, sig_list = self.get_siglist(txin, estimate_size)
|
pubkeys, sig_list = self.get_siglist(txin, estimate_size)
|
||||||
script = ''.join(push_script(x) for x in sig_list)
|
script = ''.join(push_script(x) for x in sig_list)
|
||||||
|
@ -796,7 +797,7 @@ class Transaction:
|
||||||
r = 0
|
r = 0
|
||||||
s = 0
|
s = 0
|
||||||
for txin in self.inputs():
|
for txin in self.inputs():
|
||||||
if txin.get('is_coinbase'):
|
if txin['type'] == 'coinbase':
|
||||||
continue
|
continue
|
||||||
signatures = filter(None, txin.get('signatures',[]))
|
signatures = filter(None, txin.get('signatures',[]))
|
||||||
s += len(signatures)
|
s += len(signatures)
|
||||||
|
|
|
@ -582,13 +582,13 @@ class Abstract_Wallet(PrintError):
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
def add_transaction(self, tx_hash, tx):
|
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:
|
with self.transaction_lock:
|
||||||
# add inputs
|
# add inputs
|
||||||
self.txi[tx_hash] = d = {}
|
self.txi[tx_hash] = d = {}
|
||||||
for txi in tx.inputs():
|
for txi in tx.inputs():
|
||||||
addr = txi.get('address')
|
addr = txi.get('address')
|
||||||
if not txi.get('is_coinbase'):
|
if txi['type'] != 'coinbase':
|
||||||
prevout_hash = txi['prevout_hash']
|
prevout_hash = txi['prevout_hash']
|
||||||
prevout_n = txi['prevout_n']
|
prevout_n = txi['prevout_n']
|
||||||
ser = prevout_hash + ':%d'%prevout_n
|
ser = prevout_hash + ':%d'%prevout_n
|
||||||
|
|
|
@ -366,7 +366,7 @@ class DigitalBitbox_KeyStore(Hardware_KeyStore):
|
||||||
|
|
||||||
# Build hasharray from inputs
|
# Build hasharray from inputs
|
||||||
for i, txin in enumerate(tx.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
|
self.give_error("Coinbase not supported") # should never happen
|
||||||
|
|
||||||
if txin['type'] in ['p2sh']:
|
if txin['type'] in ['p2sh']:
|
||||||
|
|
|
@ -275,7 +275,7 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
||||||
# Fetch inputs of the transaction to sign
|
# Fetch inputs of the transaction to sign
|
||||||
derivations = self.get_tx_derivations(tx)
|
derivations = self.get_tx_derivations(tx)
|
||||||
for txin in tx.inputs():
|
for txin in tx.inputs():
|
||||||
if txin.get('is_coinbase'):
|
if txin['type'] == 'coinbase':
|
||||||
self.give_error("Coinbase not supported") # should never happen
|
self.give_error("Coinbase not supported") # should never happen
|
||||||
|
|
||||||
if txin['type'] in ['p2sh']:
|
if txin['type'] in ['p2sh']:
|
||||||
|
|
|
@ -259,7 +259,7 @@ class TrezorCompatiblePlugin(HW_PluginBase):
|
||||||
inputs = []
|
inputs = []
|
||||||
for txin in tx.inputs():
|
for txin in tx.inputs():
|
||||||
txinputtype = self.types.TxInputType()
|
txinputtype = self.types.TxInputType()
|
||||||
if txin.get('is_coinbase'):
|
if txin['type'] == 'coinbase':
|
||||||
prev_hash = "\0"*32
|
prev_hash = "\0"*32
|
||||||
prev_index = 0xffffffff # signed int -1
|
prev_index = 0xffffffff # signed int -1
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue