@@ -158,13 +158,19 @@ def __init__(self,
158
158
conf ['rpcport' ] = int (conf .get ('rpcport' , service_port ))
159
159
conf ['rpchost' ] = conf .get ('rpcconnect' , 'localhost' )
160
160
161
- if 'rpcpassword' not in conf :
162
- raise ValueError ('The value of rpcpassword not specified in the configuration file: %s' % btc_conf_file )
161
+ service_url = ('%s://%s:%d' %
162
+ ('http' , conf ['rpchost' ], conf ['rpcport' ]))
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 ()
163
168
164
- service_url = ('%s://%s:%s@%s:%d' %
165
- ('http' ,
166
- conf ['rpcuser' ], conf ['rpcpassword' ],
167
- conf ['rpchost' ], conf ['rpcport' ]))
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 )
168
174
169
175
self .__service_url = service_url
170
176
self .__url = urlparse .urlparse (service_url )
@@ -177,7 +183,6 @@ def __init__(self,
177
183
else :
178
184
port = self .__url .port
179
185
self .__id_count = 0
180
- authpair = "%s:%s" % (self .__url .username , self .__url .password )
181
186
authpair = authpair .encode ('utf8' )
182
187
self .__auth_header = b"Basic " + base64 .b64encode (authpair )
183
188
0 commit comments