MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / get_auth_cookie

Function get_auth_cookie

test/functional/test_framework/util.py:317–337  ·  view source on GitHub ↗
(datadir)

Source from the content-addressed store, hash-verified

315 f.write(option + "\n")
316
317def get_auth_cookie(datadir):
318 user = None
319 password = None
320 if os.path.isfile(os.path.join(datadir, "bitcoingold.conf")):
321 with open(os.path.join(datadir, "bitcoingold.conf"), 'r', encoding='utf8') as f:
322 for line in f:
323 if line.startswith("rpcuser="):
324 assert user is None # Ensure that there is only one rpcuser line
325 user = line.split("=")[1].strip("\n")
326 if line.startswith("rpcpassword="):
327 assert password is None # Ensure that there is only one rpcpassword line
328 password = line.split("=")[1].strip("\n")
329 if os.path.isfile(os.path.join(datadir, "regtest", ".cookie")):
330 with open(os.path.join(datadir, "regtest", ".cookie"), 'r', encoding="ascii") as f:
331 userpass = f.read()
332 split_userpass = userpass.split(':')
333 user = split_userpass[0]
334 password = split_userpass[1]
335 if user is None or password is None:
336 raise ValueError("No RPC credentials")
337 return user, password
338
339# If a cookie file exists in the given datadir, delete it.
340def delete_cookie_file(datadir):

Callers 2

run_testMethod · 0.90
rpc_urlFunction · 0.85

Calls 2

joinMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected