-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfigure.py
More file actions
158 lines (96 loc) · 3.85 KB
/
configure.py
File metadata and controls
158 lines (96 loc) · 3.85 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
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
#!/usr/bin/env python3
# coding: UTF-8
import configparser
import pathlib
import sys
from cryptonode import cryptoNode, eccoinNode, bitcoinNode, moneroNode, cryptoNodeException
################################################################################
def getEccoinDataDir():
if sys.platform == "win32":
return pathlib.Path.home() / 'AppData/Roaming/eccoin'
if sys.platform == "darwin":
return pathlib.Path.home() / 'Library/Application Support/eccoin'
if sys.platform.startswith('linux'):
return pathlib.Path.home() / '.eccoin'
if sys.platform == "cygwin":
return pathlib.Path.home() / '.eccoin'
################################################################################
def loadConfigurationECC(coins, service_id = 1, respond_id = None):
rpcCheckKeys = {'rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword'}
eccConfigFile = getEccoinDataDir() / 'eccoin.conf'
parser = configparser.ConfigParser(strict=False)
try:
with open(eccConfigFile) as stream:
parser.read_string("[default]\n" + stream.read()) # ConfigParser expects Windows style .INI format
except FileNotFoundError:
print('{} file is missing'.format(eccConfigFile))
return False
if all (key in parser['default'] for key in rpcCheckKeys):
rpc_address = '{}:{}'.format(parser['default']['rpcconnect'], parser['default']['rpcport'])
coins.append(eccoinNode('ecc', rpc_address, parser['default']['rpcuser'], parser['default']['rpcpassword'], service_id, respond_id))
return True
else:
print('eccoin.conf missing one or more of rpcconnect, rpcport, rpcuser, rpcpassword')
return False
################################################################################
def loadConfigurationAlt(coins, conf):
rpcCheckKeys = {'rpcconnect', 'rpcport', 'rpcuser', 'rpcpassword'}
parser = configparser.ConfigParser()
try:
with open(conf) as stream:
parser.read_string(stream.read())
except FileNotFoundError:
createTemplateAltConf(conf)
return True
for symbol in parser.sections():
if all (key in parser[symbol] for key in rpcCheckKeys):
rpc_address = '{}:{}'.format(parser[symbol]['rpcconnect'], parser[symbol]['rpcport'])
if symbol == 'xmr':
rpc_daemon = '{}:{}'.format(parser[symbol]['daemonconnect'], parser[symbol]['daemonport'])
try:
coins.append(moneroNode(symbol, rpc_address, rpc_daemon, parser[symbol]['rpcuser'], parser[symbol]['rpcpassword']))
except cryptoNodeException as error:
print(str(error))
return False
else:
coins.append(bitcoinNode(symbol, rpc_address, parser[symbol]['rpcuser'], parser[symbol]['rpcpassword']))
return True
################################################################################
def createTemplateAltConf(conf):
output = [ '# Example ecchat.conf for adding extra altcoin full node wallets\n',
'# \n',
'# Note - Do not add your ecc config here. It is read directly from eccoin.conf\n',
'# \n',
'# [btc]\n',
'# rpcuser=username\n',
'# rpcpassword=password\n',
'# rpcport=8332\n',
'# rpcconnect=127.0.0.1\n',
'# \n',
'# [ltc]\n',
'# rpcuser=username\n',
'# rpcpassword=password\n',
'# rpcport=9332\n',
'# rpcconnect=127.0.0.1\n',
'# \n',
'# [xmr]\n',
'# rpcuser=username\n',
'# rpcpassword=password\n',
'# rpcport=18082\n',
'# rpcconnect=127.0.0.1\n',
'# daemonport=18081\n',
'# daemonconnect=127.0.0.1\n',
'# \n',
'# [doge]\n',
'# rpcuser=username\n',
'# rpcpassword=password\n',
'# rpcport=22555\n',
'# rpcconnect=127.0.0.1\n',
'# \n',
]
try:
with open(conf, "a") as stream:
stream.writelines(output)
except:
pass
################################################################################