Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/avatools.py
Show All 26 Lines | |||||
) | ) | ||||
from .p2p import P2PInterface, p2p_lock | from .p2p import P2PInterface, p2p_lock | ||||
from .test_node import TestNode | from .test_node import TestNode | ||||
from .util import ( | from .util import ( | ||||
assert_equal, | assert_equal, | ||||
satoshi_round, | satoshi_round, | ||||
wait_until, | wait_until, | ||||
) | ) | ||||
from .wallet_util import bytes_to_wif | |||||
def create_coinbase_stakes( | def create_coinbase_stakes( | ||||
node: TestNode, | node: TestNode, | ||||
blockhashes: List[str], | blockhashes: List[str], | ||||
priv_key: str, | priv_key: str, | ||||
amount: Optional[str] = None) -> List[Dict[str, Any]]: | amount: Optional[str] = None) -> List[Dict[str, Any]]: | ||||
"""Returns a list of dictionaries representing stakes, in a format | """Returns a list of dictionaries representing stakes, in a format | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | def get_ava_p2p_interface( | ||||
""" | """ | ||||
n = AvaP2PInterface() | n = AvaP2PInterface() | ||||
node.add_p2p_connection( | node.add_p2p_connection( | ||||
n, services=services) | n, services=services) | ||||
n.wait_for_verack() | n.wait_for_verack() | ||||
n.nodeid = node.getpeerinfo()[-1]['id'] | n.nodeid = node.getpeerinfo()[-1]['id'] | ||||
return n | return n | ||||
def gen_proof(node, coinbase_utxos=1): | |||||
blockhashes = node.generate(coinbase_utxos) | |||||
privkey = ECKey() | |||||
privkey.generate() | |||||
pubkey = privkey.get_pubkey() | |||||
stakes = create_coinbase_stakes( | |||||
node, blockhashes, node.get_deterministic_priv_key().key) | |||||
proof_hex = node.buildavalancheproof( | |||||
42, 2000000000, pubkey.get_bytes().hex(), stakes) | |||||
return bytes_to_wif(privkey.get_bytes()), FromHex( | |||||
AvalancheProof(), proof_hex) |