electrum

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

commit f7212a473291618ec02e59c35e06d0d391412b97
parent 33a32be576002de26808a1b5878d41924e982dc8
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 21 Mar 2017 14:33:42 +0100

fix input_script and remove unused method inputs_without_script

Diffstat:
Mlib/tests/test_transaction.py | 4----
Mlib/transaction.py | 14+++-----------
2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/lib/tests/test_transaction.py b/lib/tests/test_transaction.py @@ -86,9 +86,6 @@ class TestTransaction(unittest.TestCase): self.assertTrue(tx.has_address('1446oU3z268EeFgfcwJv6X2VBXHfoYxfuD')) self.assertFalse(tx.has_address('1CQj15y1N7LDHp7wTt28eoD1QhHgFgxECH')) - # Commenting out broken test until we know why inputs_without_script() is not returnng anything. - #self.assertEquals(tx.inputs_without_script(), set(x_pubkey for i in expected['inputs'] for x_pubkey in i['x_pubkeys'])) - self.assertEquals(tx.serialize(), unsigned_blob) tx.update_signatures(signed_blob) @@ -126,7 +123,6 @@ class TestTransaction(unittest.TestCase): self.assertEquals(tx.deserialize(), None) self.assertEquals(tx.as_dict(), {'hex': signed_blob, 'complete': True, 'final': True}) - self.assertEquals(tx.inputs_without_script(), set()) self.assertEquals(tx.serialize(), signed_blob) tx.update_signatures(signed_blob) diff --git a/lib/transaction.py b/lib/transaction.py @@ -636,9 +636,9 @@ class Transaction: @classmethod def input_script(self, txin, estimate_size=False): - if txin.get('scriptSig'): - return txin['scriptSig'] _type = txin['type'] + if _type == 'coinbase': + return txin['scriptSig'] pubkeys, sig_list = self.get_siglist(txin, estimate_size) script = ''.join(push_script(x) for x in sig_list) if _type == 'p2pk': @@ -651,7 +651,7 @@ class Transaction: elif _type == 'p2pkh': script += push_script(pubkeys[0]) elif _type == 'p2wpkh-p2sh': - redeem_script = segwit_script(pubkeys[0]) + redeem_script = txin.get('redeemScript') or segwit_script(pubkeys[0]) return push_script(redeem_script) elif _type == 'address': script += push_script(pubkeys[0]) @@ -808,14 +808,6 @@ class Transaction: s, r = self.signature_count() return r == s - def inputs_without_script(self): - out = set() - for i, txin in enumerate(self.inputs()): - if txin.get('scriptSig') == '': - out.add(i) - return out - - def sign(self, keypairs): for i, txin in enumerate(self.inputs()): num = txin['num_sig']