Last active
June 21, 2019 15:47
-
-
Save s4w3d0ff/615c9674ddf194e9a4e0 to your computer and use it in GitHub Desktop.
Opens a bitcoin.conf and puts contents into a dict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def readCfg(location): | |
# Make sure file exists... | |
if not os.path.exists(location): | |
return False | |
with open(location) as f: | |
cfg= {} | |
for line in f: | |
line = line.strip() | |
# Ignore invalid lines | |
if line and not line.startswith("#") and '=' in line: | |
cfg[line.split('=', 1)[0]] = line.split('=', 1)[1] | |
return cfg | |
if __name__ == "__main__": | |
cfg = readCfg('/home/user/.bitcoin/bitcoin.conf') | |
print(" %s ( :3 )" % cfg['rpcpassword']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment