@@ -55,7 +55,6 @@ def __init__(self, rpc_error):
5555
5656
5757class RawProxy (object ):
58- # FIXME: need a CChainParams rather than hard-coded service_port
5958 def __init__ (self , service_url = None ,
6059 service_port = None ,
6160 btc_conf_file = None ,
@@ -79,7 +78,8 @@ def __init__(self, service_url=None,
7978
8079 # Extract contents of bitcoin.conf to build service_url
8180 with open (btc_conf_file , 'r' ) as fd :
82- conf = {}
81+ # Bitcoin Core accepts empty rpcuser, not specified in btc_conf_file
82+ conf = {'rpcuser' : "" }
8383 for line in fd .readlines ():
8484 if '#' in line :
8585 line = line [:line .index ('#' )]
@@ -100,6 +100,9 @@ def __init__(self, service_url=None,
100100 else :
101101 raise ValueError ('Unknown rpcssl value %r' % conf ['rpcssl' ])
102102
103+ if 'rpcpassword' not in conf :
104+ raise ValueError ('The value of rpcpassword not specified in the configuration file: %s' % btc_conf_file )
105+
103106 service_url = ('%s://%s:%s@localhost:%d' %
104107 ('https' if conf ['rpcssl' ] else 'http' ,
105108 conf ['rpcuser' ], conf ['rpcpassword' ],
@@ -108,7 +111,10 @@ def __init__(self, service_url=None,
108111 self .__service_url = service_url
109112 self .__url = urlparse .urlparse (service_url )
110113 if self .__url .port is None :
111- port = 80
114+ if self .__url .scheme == 'https' :
115+ port = httplib .HTTPS_PORT
116+ else :
117+ port = httplib .HTTP_PORT
112118 else :
113119 port = self .__url .port
114120 self .__id_count = 0
0 commit comments