Browse Source

fix input_script and remove unused method inputs_without_script

283 2.8.2
ThomasV 8 years ago
parent
commit
f7212a4732
  1. 4
      lib/tests/test_transaction.py
  2. 14
      lib/transaction.py

4
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)

14
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']

Loading…
Cancel
Save