-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinuit.py
executable file
·129 lines (103 loc) · 3.15 KB
/
inuit.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
#!/usr/bin/env python
"""
inuit
Cold storage crypto-currency address generator
"""
import os.path
import sys
import encrypt.database as database
import io.list as list
import num.rand as rand
import system.address as address
import system.alts as alts
import system.data as data
import system.dbCreate as dbCreate
from system.settings import passW
passW = passW()
#build the database if it doesn't exist
if not os.path.isfile('igloo.dat') and not os.path.isfile('iceblock'):
passW.setPass()
dbCreate.buildDB()
else:
if not os.path.isfile('igloo.dat') and os.path.isfile('iceblock'):
#decrypt the database if the encrypted version exists
database.decrypt(passW)
else:
#otherwise get the password so that password encryption can take place
print('It looks like your database wasn\'t encrypted the last time you used inuit')
passW.getPass()
try:
while True:
print('')
command = raw_input('Enter command >> ').strip().split()
if len(command) < 1:
continue
elif command[0].lower() == 'exit':
database.encrypt(passW)
sys.exit()
elif command[0].lower() == 'help':
list.help()
continue
elif command[0].lower() == 'setpass':
dbCreate.setPwd(2)
continue
elif command[0].lower() == 'dumpprivkey':
if len(command) < 2:
print('dumpprivkey requires an address as its first parameter')
continue
address.dumpPrivKey(command[1])
continue
elif command[0].lower() == 'entropycheck':
rand.platformCheck()
continue
elif command[0].lower() == 'listaddr':
if len(command) < 2:
print('listaddr requires a currency abbreviation as its first parameter')
continue
list.showAddresses(command[1])
continue
elif command[0].lower() == 'listcur':
list.showCurrencies()
continue
elif command[0].lower() == 'addcur':
if len(command) < 2:
print('addcur requires a currency abbreviation as its first parameter')
continue
alts.addAlt(command[1])
continue
elif command[0].lower() == 'editcur':
if len(command) < 2:
print('editcur requires a currency abbreviation as its first parameter')
continue
alts.editAlt(command[1])
continue
elif command[0].lower() == 'importcur':
data.importAlts()
continue
elif command[0].lower() == 'exportcur':
data.exportAlts()
continue
elif command[0].lower() == 'gen':
if len(command) < 2:
print('gen requires a currency abbreviation as its first parameter')
continue
address.generate(command[1])
continue
#a couple of unit test functions here.
#the first generates address and priv keys for all currencies in the system
#the second does the same but with BIP38 encryption which it also tests
elif command[0].lower() == 'genall':
data.genAll()
continue
elif command[0].lower() == 'bipall':
data.genAll(True)
continue
else:
print(command[0] + ' was not recognised as a command')
continue
except:
#naughty I know but this should ensure that the database gets encrypted if an unforeseen error occurs
if str(sys.exc_info()[0]) != '<type \'exceptions.SystemExit\'>':
print('An unforeseen error occurred. Attempting to encrypt database.')
database.encrypt(passW)
sys.exit()