10 from click
import command, option, ClickException
14 from typing
import Optional
18 @option(
"--eth-addr-file", help=
"Address output filename")
19 @option(
"--eth-private-key-file", help=
"Private key output filename")
20 @option(
"--use-private-key", help=
"Use existing private key")
22 eth_addr_file: Optional[str],
23 eth_private_key_file: Optional[str],
24 use_private_key: Optional[str]) ->
None:
26 Locally generate a new Ethereum private key and address file, and write
27 them to the current directory.
30 "*** WARNING: this address should not be used in production ***\n")
32 eth_addr_file = eth_addr_file
or ETH_ADDRESS_DEFAULT
33 eth_private_key_file = eth_private_key_file
or ETH_PRIVATE_KEY_FILE_DEFAULT
36 eth_private_key = bytes.fromhex(use_private_key)
40 if len(eth_private_key) != 32:
41 raise ClickException(
"invalid private key length")
47 f
"{eth_address}: written to {eth_addr_file}, "
48 f
"private key to {eth_private_key_file}")
53 Simple private key generation function. Not for production use.
55 return Web3.sha3(os.urandom(4096))