electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1d840291731832488ceb1328326e8e63667aaabc
parent fdee755198ccc82f1e76703f32c1d64f85dc3a8d
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 21 Mar 2017 09:08:16 +0100

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

Diffstat:
Mgui/qt/transaction_dialog.py | 2+-
Mlib/transaction.py | 15++++++++-------
Mlib/wallet.py | 4++--
Mplugins/digitalbitbox/digitalbitbox.py | 2+-
Mplugins/ledger/ledger.py | 2+-
Mplugins/trezor/plugin.py | 2+-
6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py @@ -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') diff --git a/lib/transaction.py b/lib/transaction.py @@ -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) diff --git a/lib/wallet.py b/lib/wallet.py @@ -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 diff --git a/plugins/digitalbitbox/digitalbitbox.py b/plugins/digitalbitbox/digitalbitbox.py @@ -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']: diff --git a/plugins/ledger/ledger.py b/plugins/ledger/ledger.py @@ -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']: diff --git a/plugins/trezor/plugin.py b/plugins/trezor/plugin.py @@ -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: