Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bitcoin/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __init__(self, rpc_error):


class RawProxy(object):
# FIXME: need a CChainParams rather than hard-coded service_port
def __init__(self, service_url=None,
service_port=None,
btc_conf_file=None,
Expand All @@ -79,7 +78,8 @@ def __init__(self, service_url=None,

# Extract contents of bitcoin.conf to build service_url
with open(btc_conf_file, 'r') as fd:
conf = {}
# Bitcoin Core accepts empty rpcuser, not specified in btc_conf_file
conf = {'rpcuser': ""}
for line in fd.readlines():
if '#' in line:
line = line[:line.index('#')]
Expand All @@ -100,6 +100,9 @@ def __init__(self, service_url=None,
else:
raise ValueError('Unknown rpcssl value %r' % conf['rpcssl'])

if 'rpcpassword' not in conf:
raise ValueError('The value of rpcpassword not specified in the configuration file: %s' % btc_conf_file)

service_url = ('%s://%s:%s@localhost:%d' %
('https' if conf['rpcssl'] else 'http',
conf['rpcuser'], conf['rpcpassword'],
Expand All @@ -108,7 +111,10 @@ def __init__(self, service_url=None,
self.__service_url = service_url
self.__url = urlparse.urlparse(service_url)
if self.__url.port is None:
port = 80
if self.__url.scheme == 'https':
port = httplib.HTTPS_PORT
else:
port = httplib.HTTP_PORT
else:
port = self.__url.port
self.__id_count = 0
Expand Down