4 ### Automatic seeding over HTTP
7 ### http://www.gnu.org/licenses/agpl-3.0.en.html
18 sources = ['http://dalexhz1.cloudapp.net', 'http://dalexhz2.cloudapp.net', 'http://dalexhz4.cloudapp.net', 'http://dalexhz5.cloudapp.net']
19 data = urllib2.urlopen(random.choice(sources))
21 if 'norpc' in sys.argv:
22 for node in json.load(data):
26 ### This module is required to function properly:
27 ### https://github.com/jgarzik/python-bitcoinrpc
30 from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
31 from socket import error as socket_error
35 if platform.system() == 'Windows':
36 folder = os.path.join(os.path.join(os.environ['APPDATA'], 'NovaCoin'))
38 if platform.system() == 'Darwin':
39 folder = os.path.expanduser('~/Library/Application Support/NovaCoin/')
41 folder = os.path.expanduser('~/.novacoin')
43 return os.path.join(folder, 'novacoin.conf')
45 conf_path = confFile()
46 if not os.path.exists(conf_path):
47 parser.error('''Novacoin configuration file not found. Manually enter your RPC password.\r\n'''
48 '''If you actually haven't created a configuration file, you should create one at %s with the text like this:\r\n'''
51 '''rpcuser=yourname\r\n'''
52 '''rpcpassword=%x\r\n'''
54 '''Keep that password secret! After creating the file, restart Novacoin.''' % (conf_path, random.randrange(2**128)))
56 conf = open(conf_path, 'rb').read()
59 for line in conf.splitlines(True):
61 line = line[:line.index('#')]
64 k, v = line.split('=', 1)
65 contents[k.strip()] = v.strip()
67 if 'rpcpassword' not in contents.keys():
69 '''RPC password is not found in the %s file.''' % (conf_path))
72 rpcpassword = contents['rpcpassword']
74 rpclisten = '127.0.0.1'
76 if 'rpcport' in contents.keys():
77 rpcport = contents['rpcport']
79 if 'rpcuser' in contents.keys():
80 rpcuser = contents['rpcuser']
82 if 'rpclisten' in contents.keys():
83 rpcuser = contents['rpclisten']
85 url = "http://"+rpcuser+":"+rpcpassword+"@"+rpclisten+":"+rpcport+"/"
87 access = AuthServiceProxy(url)
89 for node in json.load(data):
92 access.addnode(node, 'add')
93 except socket_error, e:
94 if e.errno == errno.ECONNREFUSED:
95 print 'Unable to communicate with Novacoin RPC'
97 except JSONRPCException, e: