Hi, if you are interested, I am using the library with an interface like this that automatically finds credentials:
def __init__(self, datadir='~/.bitcoin', rpcurl='127.0.0.1', rpcuser=None, rpcpassword=None, rpcport=None):
if '://' in rpcurl:
dummy, rpcurl = rpcurl.split('://', 1)
if '/' in rpcurl:
rpcurl, dummy = rpcurl.split('/', 1)
if '@' in rpcurl:
if rpcuser is not None:
raise Exception('user specified in rpcurl and parameter list')
rpcuser, rpcurl = rpcurl.split('@', 1)
if ':' in rpcuser:
if rpcpassword is not None:
raise Exception('password specified in rpcurl and parameter list')
rpcuser, rpcpassword = rpcuser.split(':', 1)
if ':' in rpcurl:
if rpcport is not None:
raise DatacoinException('port specified in rpcurl and parameter list')
rpcurl, rpcport = rpcurl.split(':', 1)
rpcurl = 'http://{}'.format(rpcurl)
if rpcport is not None:
rpcurl += ':{}'.format(rpcport)
if rpcpassword is None and rpcuser is None:
datadir = os.path.expanduser(datadir)
cookiefn = os.path.join(datadir, '.cookie')
if os.path.exists(cookiefn):
with open(cookiefn) as cookiefile:
rpcuser, rpcpassword = cookiefile.read().split(':', 1)
Hi, if you are interested, I am using the library with an interface like this that automatically finds credentials: