mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-28 05:13:03 +02:00
test: introduce helper to create random P2WPKH scriptPubKeys
This commit is contained in:
parent
aa26797f69
commit
6fc2cd3f09
@ -28,6 +28,7 @@ from test_framework.script import (
|
||||
OP_NOP,
|
||||
SIGHASH_ALL,
|
||||
)
|
||||
from test_framework.script_util import key_to_p2wpkh_script
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_greater_than_or_equal,
|
||||
@ -207,6 +208,14 @@ class MiniWallet:
|
||||
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):
|
||||
"""Build a transaction that spends parent_txid.vout[n] and produces one output with
|
||||
amount = parent_value with a fee deducted.
|
||||
|
Loading…
x
Reference in New Issue
Block a user