This repository has been archived by the owner on Mar 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
registration_proccessor_with_ico.py
162 lines (141 loc) · 7.92 KB
/
registration_proccessor_with_ico.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env python3
from blockcypher import create_forwarding_address_with_details
import json
from random import choice
import xlsxwriter
import time
import traceback, logging
from piston.steem import (
Steem,
AccountExistsException,
BroadcastingError
)
config = json.load(open('config.json'))
creator = config["registory"]
wif = config["wif"]
steem = Steem(node='ws://127.0.0.1:8090', nobroadcast=False, wif=wif)
workbook_name = 'acccounts_list_ico_' + str(int(time.time())) + '.xlsx'
ico_workbook = xlsxwriter.Workbook(workbook_name)
ico_worksheet = ico_workbook.add_worksheet()
ico_worksheet.write(0, 0, "Account name")
ico_worksheet.write(0, 1, "Status")
ico_worksheet.write(0, 2, "Account password")
ico_worksheet.write(0, 3, "Account ico address")
ico_worksheet.set_column('A:F', 35)
blockcypher = json.load(open('blockcypher.json'))
api_key = blockcypher["api_key"]
registration_list = json.load(open('registration_list_ico.json'))
# registration_list = json.load(open('step_four_pre_registration_list.json'))
logs = []
registered_list = []
non_registered_list = []
logs_exception = []
registered_list_exception = []
non_registered_list_exception = []
processed_accounts = 0
charsets = [
'abcdefghijklmnopqrstuvwxyz',
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'0123456789',
]
def generate_password(length=32):
pwd = []
charset = choice(charsets)
while len(pwd) < length:
pwd.append(choice(charset))
charset = choice(list(set(charsets) - set([charset])))
return "".join(pwd)
try:
print("[-] Started accounts process creation")
for account in registration_list:
processed_accounts += 1
account_address = create_forwarding_address_with_details(destination_address='3CWicRKHQqcj1N6fT1pC9J3hUzHw1KyPv3',
api_key=api_key,
callback_url='')
account_address = account_address['input_address']
metadata = {"ico_address":str(account_address), "type":"b"}
random_string = generate_password(32)
try:
registration_log = steem.create_account(account_name=account,
json_meta=metadata,
creator=creator,
password=random_string,
storekeys=False)
created_account = {
'account' : account,
'password' : random_string,
'address' : account_address
}
logs.append(registration_log)
registered_list.append(created_account)
ico_worksheet.write(processed_accounts, 0, str(account))
ico_worksheet.write(processed_accounts, 1, str("Created"))
ico_worksheet.write(processed_accounts, 2, str(random_string))
ico_worksheet.write(processed_accounts, 3, str(account_address))
registered_list_exception = registered_list
logs_exception = logs
print('[+][{3}] Successfully registered account: {0} [{2}] with password -> {1}'.format(account, random_string, account_address, processed_accounts))
except AccountExistsException:
non_registered_list.append(account)
print('[-][{1}] Already registered account: {0}'.format(account, processed_accounts))
ico_worksheet.write(processed_accounts, 0, str(account))
ico_worksheet.write(processed_accounts, 1, str("Not created [exists]"))
non_registered_list_exception = non_registered_list
time.sleep(2)
pass
except BroadcastingError:
non_registered_list.append(account)
print('[-][{1}] Account name: {0} is invalid'.format(account, processed_accounts))
ico_worksheet.write(processed_accounts, 0, str(account))
ico_worksheet.write(processed_accounts, 1, str("Not created [invalid]"))
non_registered_list_exception = non_registered_list
pass
except KeyboardInterrupt as e:
print("[!] Raised keyboard interrupt, going to save progress...")
json.dump(logs_exception, open('registration_logs_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
json.dump(registered_list, open('registered_accounts_credentials_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
json.dump(non_registered_list, open('non_registered_accounts_list_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
print("[!] Saved progress after keyboard interrupt")
raise
except Exception as e:
print("[!] Raised unrecognized error, going to save progress...")
logging.error(traceback.format_exc())
json.dump(logs_exception, open('registration_logs_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
json.dump(registered_list_exception, open('registered_accounts_credentials_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
json.dump(non_registered_list_exception, open('non_registered_accounts_list_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
print("[!] Saved progress with error")
else:
json.dump(logs, open('registration_logs_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
json.dump(registered_list, open('registered_accounts_credentials_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
json.dump(non_registered_list, open('non_registered_accounts_list_ico_' + str(int(time.time())) + '.json', 'w'),
indent=4,
sort_keys=True,
separators=(',', ':'))
print("[-] Finished accounts process creation")
finally:
ico_workbook.close()
print("[*] Script finished")