Merge pull request #2872 from SomberNight/p2pk_output_1
fix: p2pk output serialisation
This commit is contained in:
commit
302dd3912d
|
@ -357,6 +357,10 @@ def address_to_scripthash(addr):
|
||||||
h = sha256(bytes.fromhex(script))[0:32]
|
h = sha256(bytes.fromhex(script))[0:32]
|
||||||
return bytes(reversed(h)).hex()
|
return bytes(reversed(h)).hex()
|
||||||
|
|
||||||
|
def public_key_to_p2pk_script(pubkey):
|
||||||
|
script = push_script(pubkey)
|
||||||
|
script += 'ac' # op_checksig
|
||||||
|
return script
|
||||||
|
|
||||||
__b58chars = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
__b58chars = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||||
assert len(__b58chars) == 58
|
assert len(__b58chars) == 58
|
||||||
|
|
|
@ -624,10 +624,9 @@ class Transaction:
|
||||||
elif output_type == TYPE_ADDRESS:
|
elif output_type == TYPE_ADDRESS:
|
||||||
return bitcoin.address_to_script(addr)
|
return bitcoin.address_to_script(addr)
|
||||||
elif output_type == TYPE_PUBKEY:
|
elif output_type == TYPE_PUBKEY:
|
||||||
return addr
|
return bitcoin.public_key_to_p2pk_script(addr)
|
||||||
else:
|
else:
|
||||||
raise TypeError('Unknown output type')
|
raise TypeError('Unknown output type')
|
||||||
return script
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_siglist(self, txin, estimate_size=False):
|
def get_siglist(self, txin, estimate_size=False):
|
||||||
|
@ -714,6 +713,9 @@ class Transaction:
|
||||||
pubkey = txin['pubkeys'][0]
|
pubkey = txin['pubkeys'][0]
|
||||||
pkh = bh2u(bitcoin.hash_160(bfh(pubkey)))
|
pkh = bh2u(bitcoin.hash_160(bfh(pubkey)))
|
||||||
return '76a9' + push_script(pkh) + '88ac'
|
return '76a9' + push_script(pkh) + '88ac'
|
||||||
|
elif txin['type'] == 'p2pk':
|
||||||
|
pubkey = txin['pubkeys'][0]
|
||||||
|
return bitcoin.public_key_to_p2pk_script(pubkey)
|
||||||
else:
|
else:
|
||||||
raise TypeError('Unknown txin type', txin['type'])
|
raise TypeError('Unknown txin type', txin['type'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue