mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-02 16:59:44 +01:00
test: introduce script_util helper for creating P2PK scripts
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
"""Useful Script constants and utils."""
|
||||
from test_framework.script import (
|
||||
CScript,
|
||||
hash160,
|
||||
sha256,
|
||||
OP_0,
|
||||
OP_DUP,
|
||||
OP_HASH160,
|
||||
OP_CHECKSIG,
|
||||
OP_DUP,
|
||||
OP_EQUAL,
|
||||
OP_EQUALVERIFY,
|
||||
OP_HASH160,
|
||||
hash160,
|
||||
sha256,
|
||||
)
|
||||
|
||||
# To prevent a "tx-size-small" policy rule error, a transaction has to have a
|
||||
@@ -36,6 +36,11 @@ DUMMY_P2WPKH_SCRIPT = CScript([b'a' * 21])
|
||||
DUMMY_2_P2WPKH_SCRIPT = CScript([b'b' * 21])
|
||||
|
||||
|
||||
def key_to_p2pk_script(key):
|
||||
key = check_key(key)
|
||||
return CScript([key, OP_CHECKSIG])
|
||||
|
||||
|
||||
def keyhash_to_p2pkh_script(hash):
|
||||
assert len(hash) == 20
|
||||
return CScript([OP_DUP, OP_HASH160, hash, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
|
||||
Reference in New Issue
Block a user