MCPcopy Create free account
hub / github.com/ElementsProject/elements / get_generate_key

Function get_generate_key

test/functional/test_framework/wallet_util.py:66–87  ·  view source on GitHub ↗

Generate a fresh key Returns a named tuple of privkey, pubkey and all address and scripts.

()

Source from the content-addressed store, hash-verified

64 )
65
66def get_generate_key():
67 """Generate a fresh key
68
69 Returns a named tuple of privkey, pubkey and all address and scripts."""
70 blinding_eckey = ECKey()
71 blinding_eckey.generate()
72 blinding_privkey = bytes_to_wif(blinding_eckey.get_bytes())
73 eckey = ECKey()
74 eckey.generate()
75 privkey = bytes_to_wif(eckey.get_bytes())
76 pubkey = eckey.get_pubkey().get_bytes().hex()
77 return Key(privkey=privkey,
78 pubkey=pubkey,
79 p2pkh_script=key_to_p2pkh_script(pubkey).hex(),
80 p2pkh_addr=key_to_p2pkh(pubkey),
81 p2wpkh_script=key_to_p2wpkh_script(pubkey).hex(),
82 p2wpkh_addr=key_to_p2wpkh(pubkey),
83 p2sh_p2wpkh_script=script_to_p2sh_script(key_to_p2wpkh_script(pubkey)).hex(),
84 p2sh_p2wpkh_redeem_script=key_to_p2wpkh_script(pubkey).hex(),
85 p2sh_p2wpkh_addr=key_to_p2sh_p2wpkh(pubkey),
86 blinding_privkey=blinding_privkey,
87 )
88
89def generate_keypair(compressed=True, wif=False):
90 """Generate a new random keypair and return the corresponding ECKey /

Callers 4

prepare_walletsMethod · 0.90
run_testMethod · 0.90
run_testMethod · 0.90

Calls 13

generateMethod · 0.95
get_bytesMethod · 0.95
get_pubkeyMethod · 0.95
ECKeyClass · 0.90
key_to_p2pkh_scriptFunction · 0.90
key_to_p2pkhFunction · 0.90
key_to_p2wpkh_scriptFunction · 0.90
key_to_p2wpkhFunction · 0.90
script_to_p2sh_scriptFunction · 0.90
key_to_p2sh_p2wpkhFunction · 0.90
bytes_to_wifFunction · 0.85
hexMethod · 0.80

Tested by 1