test: introduce helper to create random P2WPKH scriptPubKeys
This commit is contained in:
1 parent
aa26797f69
commit
6fc2cd3f09
1 file changed
+9
@@ -28,6 +28,7 @@ from test_framework.script import (
|
|||||||
OP_NOP,
|
OP_NOP,
|
||||||
SIGHASH_ALL,
|
SIGHASH_ALL,
|
||||||
)
|
)
|
||||||
|
from test_framework.script_util import key_to_p2wpkh_script
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
assert_greater_than_or_equal,
|
assert_greater_than_or_equal,
|
||||||
@@ -207,6 +208,14 @@ class MiniWallet:
|
|||||||
return txid
|
return txid
|
||||||
|
|
||||||
|
|
||||||
|
def random_p2wpkh():
|
||||||
|
"""Generate a random P2WPKH scriptPubKey. Can be used when a random destination is needed,
|
||||||
|
but no compiled wallet is available (e.g. as replacement to the getnewaddress RPC)."""
|
||||||
|
key = ECKey()
|
||||||
|
key.generate()
|
||||||
|
return key_to_p2wpkh_script(key.get_pubkey().get_bytes())
|
||||||
|
|
||||||
|
|
||||||
def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_locking_script=None, fee=DEFAULT_FEE):
|
def make_chain(node, address, privkeys, parent_txid, parent_value, n=0, parent_locking_script=None, fee=DEFAULT_FEE):
|
||||||
"""Build a transaction that spends parent_txid.vout[n] and produces one output with
|
"""Build a transaction that spends parent_txid.vout[n] and produces one output with
|
||||||
amount = parent_value with a fee deducted.
|
amount = parent_value with a fee deducted.
|
||||||
|
|||||||
Reference in new issue
Block a user