fix input_script and remove unused method inputs_without_script
This commit is contained in:
@@ -86,9 +86,6 @@ class TestTransaction(unittest.TestCase):
|
|||||||
self.assertTrue(tx.has_address('1446oU3z268EeFgfcwJv6X2VBXHfoYxfuD'))
|
self.assertTrue(tx.has_address('1446oU3z268EeFgfcwJv6X2VBXHfoYxfuD'))
|
||||||
self.assertFalse(tx.has_address('1CQj15y1N7LDHp7wTt28eoD1QhHgFgxECH'))
|
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)
|
self.assertEquals(tx.serialize(), unsigned_blob)
|
||||||
|
|
||||||
tx.update_signatures(signed_blob)
|
tx.update_signatures(signed_blob)
|
||||||
@@ -126,7 +123,6 @@ class TestTransaction(unittest.TestCase):
|
|||||||
self.assertEquals(tx.deserialize(), None)
|
self.assertEquals(tx.deserialize(), None)
|
||||||
self.assertEquals(tx.as_dict(), {'hex': signed_blob, 'complete': True, 'final': True})
|
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)
|
self.assertEquals(tx.serialize(), signed_blob)
|
||||||
|
|
||||||
tx.update_signatures(signed_blob)
|
tx.update_signatures(signed_blob)
|
||||||
|
|||||||
@@ -636,9 +636,9 @@ 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']
|
||||||
|
if _type == 'coinbase':
|
||||||
|
return txin['scriptSig']
|
||||||
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)
|
||||||
if _type == 'p2pk':
|
if _type == 'p2pk':
|
||||||
@@ -651,7 +651,7 @@ class Transaction:
|
|||||||
elif _type == 'p2pkh':
|
elif _type == 'p2pkh':
|
||||||
script += push_script(pubkeys[0])
|
script += push_script(pubkeys[0])
|
||||||
elif _type == 'p2wpkh-p2sh':
|
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)
|
return push_script(redeem_script)
|
||||||
elif _type == 'address':
|
elif _type == 'address':
|
||||||
script += push_script(pubkeys[0])
|
script += push_script(pubkeys[0])
|
||||||
@@ -808,14 +808,6 @@ class Transaction:
|
|||||||
s, r = self.signature_count()
|
s, r = self.signature_count()
|
||||||
return r == s
|
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):
|
def sign(self, keypairs):
|
||||||
for i, txin in enumerate(self.inputs()):
|
for i, txin in enumerate(self.inputs()):
|
||||||
num = txin['num_sig']
|
num = txin['num_sig']
|
||||||
|
|||||||
Reference in New Issue
Block a user