def geth_create_account(datadir, privkey):
"""
Create an account in `datadir` -- since we're not interested
in the rewards, we don't care about the created address.
Args:
datadir (str): the datadir in which the account is created
"""
keyfile_path = os.path.join(datadir, 'keyfile')
with open(keyfile_path, 'w') as handler:
handler.write(hexlify(privkey))
create = subprocess.Popen(
['geth', '--datadir', datadir, 'account', 'import', keyfile_path],
stdin=subprocess.PIPE,
universal_newlines=True
)
create.stdin.write(DEFAULT_PASSPHRASE + os.linesep)
time.sleep(.1)
create.stdin.write(DEFAULT_PASSPHRASE + os.linesep)
create.communicate()
assert create.returncode == 0
评论列表
文章目录