4 ### Automatic seeding over HTTP
7 ### http://www.gnu.org/licenses/agpl-3.0.en.html
17 sources = ['http://dalexhz1.cloudapp.net', 'http://dalexhz2.cloudapp.net', 'http://dalexhz4.cloudapp.net', 'http://dalexhz5.cloudapp.net']
18 data = urllib.request.urlopen(random.choice(sources)).readall();
20 if 'norpc' in sys.argv:
21 for node in json.loads(data.decode()):
25 ### This module is required to function properly:
26 ### https://github.com/jgarzik/python-bitcoinrpc
29 from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
30 from socket import error as socket_error
34 if platform.system() == 'Windows':
35 folder = os.path.join(os.path.join(os.environ['APPDATA'], 'NovaCoin'))
37 if platform.system() == 'Darwin':
38 folder = os.path.expanduser('~/Library/Application Support/NovaCoin/')
40 folder = os.path.expanduser('~/.novacoin')
42 return os.path.join(folder, 'novacoin.conf')
44 conf_path = confFile()
45 if not os.path.exists(conf_path):
46 parser.error('''Novacoin configuration file not found. Manually enter your RPC password.\r\n'''
47 '''If you actually haven't created a configuration file, you should create one at %s with the text like this:\r\n'''
50 '''rpcuser=yourname\r\n'''
51 '''rpcpassword=%x\r\n'''
53 '''Keep that password secret! After creating the file, restart Novacoin.''' % (conf_path, random.randrange(2**128)))
55 conf = open(conf_path, 'rb').read()
58 for line in conf.splitlines(True):
59 if line.startswith(b'#'):
60 line = line[:line.index('#')]
61 if not line.__contains__(b'='):
63 k, v = line.split(b'=', 1)
64 contents[k.strip()] = v.strip()
68 if b'rpcpassword' not in contents.keys():
69 print('''RPC password is not found in the %s file.''' % (conf_path))
72 if b'rpcuser' not in contents.keys():
73 print('''RPC user is not found in the %s file.''' % (conf_path))
76 rpcuser = contents[b'rpcuser'].decode()
77 rpcpassword = contents[b'rpcpassword'].decode()
79 rpclisten = '127.0.0.1'
81 if b'rpcport' in contents.keys():
82 rpcport = contents[b'rpcport'].decode()
83 if b'rpclisten' in contents.keys():
84 rpcuser = contents[b'rpclisten'].decode()
86 access = AuthServiceProxy("http://"+rpcuser+":"+rpcpassword+"@"+rpclisten+":"+rpcport+"/")
88 for node in json.loads(data.decode()):
89 print ('Adding', node)
91 access.addnode(node, 'add')
92 except socket_error as e:
93 if e.errno == errno.ECONNREFUSED:
94 print ('Unable to communicate with Novacoin RPC')
96 except JSONRPCException as e:
98 print ('Already added')