1
0

bitcoin.py: dedupe pubkeyhash_to_p2pkh_script

This commit is contained in:
SomberNight
2019-07-31 01:18:51 +02:00
parent a10dc04b28
commit 8390da9b7b
2 changed files with 11 additions and 8 deletions

View File

@@ -909,14 +909,12 @@ class Transaction:
return preimage_script
pubkeys, x_pubkeys = self.get_sorted_pubkeys(txin)
if txin['type'] == 'p2pkh':
return bitcoin.address_to_script(txin['address'])
elif txin['type'] in ['p2sh', 'p2wsh', 'p2wsh-p2sh']:
if txin['type'] in ['p2sh', 'p2wsh', 'p2wsh-p2sh']:
return multisig_script(pubkeys, txin['num_sig'])
elif txin['type'] in ['p2wpkh', 'p2wpkh-p2sh']:
elif txin['type'] in ['p2pkh', 'p2wpkh', 'p2wpkh-p2sh']:
pubkey = pubkeys[0]
pkh = bh2u(hash_160(bfh(pubkey)))
return '76a9' + push_script(pkh) + '88ac'
return bitcoin.pubkeyhash_to_p2pkh_script(pkh)
elif txin['type'] == 'p2pk':
pubkey = pubkeys[0]
return bitcoin.public_key_to_p2pk_script(pubkey)