File tree 1 file changed +13
-10
lines changed 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -161,16 +161,19 @@ def __init__(self,
161
161
service_url = ('%s://%s:%d' %
162
162
('http' , conf ['rpchost' ], conf ['rpcport' ]))
163
163
164
- cookie_file = os .path .dirname (btc_conf_file )
165
- cookie_file = os .path .join (cookie_file , ".cookie" )
166
- with open (cookie_file , 'r' ) as fd :
167
- authpair = fd .read ()
168
-
169
- if 'rpcpassword' in conf :
170
- authpair = "%s:%s" % (conf ['rpcuser' ], conf ['rpcpassword' ])
171
-
172
- if authpair is None :
173
- raise ValueError ('The value of rpcpassword not specified in the configuration file: %s' % btc_conf_file )
164
+ cookie_dir = os .path .dirname (btc_conf_file )
165
+ if bitcoin .params .NAME != "mainnet" :
166
+ cookie_dir = os .path .join (cookie_dir , bitcoin .params .NAME )
167
+ cookie_file = os .path .join (cookie_dir , ".cookie" )
168
+ try :
169
+ with open (cookie_file , 'r' ) as fd :
170
+ authpair = fd .read ()
171
+ except IOError as err :
172
+ if 'rpcpassword' in conf :
173
+ authpair = "%s:%s" % (conf ['rpcuser' ], conf ['rpcpassword' ])
174
+
175
+ else :
176
+ raise ValueError ('Cookie file unusable (%s) and rpcpassword not specified in the configuration file: %r' % (err , btc_conf_file ))
174
177
175
178
self .__service_url = service_url
176
179
self .__url = urlparse .urlparse (service_url )
You can’t perform that action at this time.
0 commit comments