forked from bitphage/golos-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_account.py
More file actions
executable file
·59 lines (47 loc) · 1.72 KB
/
create_account.py
File metadata and controls
executable file
·59 lines (47 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
import sys
import json
import argparse
import logging
import yaml
from golos import Steem
from golosbase.account import PasswordKey, PublicKey, PrivateKey
import functions
log = logging.getLogger('functions')
def main():
parser = argparse.ArgumentParser(
description='Create account',
epilog='Report bugs to: https://github.com/bitfag/golos-scripts/issues')
parser.add_argument('-d', '--debug', action='store_true',
help='enable debug output')
parser.add_argument('-c', '--config', default='./common.yml',
help='specify custom path for config file')
parser.add_argument('-p', '--password',
help='manually specify a password')
parser.add_argument('creator',
help='parent account who will create child account')
parser.add_argument('account',
help='new account name')
args = parser.parse_args()
# create logger
if args.debug == True:
log.setLevel(logging.DEBUG)
else:
log.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s")
handler.setFormatter(formatter)
log.addHandler(handler)
# parse config
with open(args.config, 'r') as ymlfile:
conf = yaml.load(ymlfile)
golos = Steem(nodes=conf['nodes_old'], keys=conf['keys'])
# random password
if args.password:
password = args.password
else:
password = functions.generate_password()
print('password: {}\n'.format(password))
golos.create_account(args.account, creator=args.creator, password=password)
if __name__ == '__main__':
main()