Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This python script edits chancoin.conf to make the Chancoin wallet ready to use with ChanCoin-for-4chan
- #Script made by "Mario", 4CHN donations are appreciated: CZxqjvqZuftemXBGRvuMeBmBSS3PCPYfUy
- #Youtube Channel :) https://www.youtube.com/channel/UCnNd7sE78-apQrrqRitRQEQ
- import os
- import re
- from pathlib import Path
- AppdataLocation= os.getenv('APPDATA')
- ChancoinFolder=Path(AppdataLocation + "\chancoin")
- if ChancoinFolder.is_dir():
- ConfLocation= Path(AppdataLocation + "\chancoin\chancoin.conf")
- if not ConfLocation.is_file():
- print("\nchancoin.conf doesn't exist, creating a new file...")
- ConfFile=open(ConfLocation,"w")
- ConfFile.write("rpcuser=username\nrpcpassword=password\nrpcallowip=127.0.0.1\nrpcport=43814\nserver=1")
- else:
- ConfFile=open(ConfLocation,"r")
- ConfData=ConfFile.read()
- ConfFile.close()
- ConfFile=open(ConfLocation,"w")
- print("\nchancoin.conf found, editing the parameters...")
- if re.search(r"rpcuser(\s)*=(.)*",ConfData):
- ConfData=re.sub(r"rpcuser(\s)*=(.)*", "rpcuser=username", ConfData)
- else:
- ConfData = ConfData + "\nrpcuser=username"
- print(ConfData)
- if re.search(r"rpcpassword(\s)*=(.)*",ConfData):
- ConfData=re.sub(r"rpcpassword(\s)*=(.)*", "rpcpassword=password", ConfData)
- else:
- ConfData = ConfData + "\nrpcpassword=password"
- if re.search(r"rpcallowip(\s)*=(.)*",ConfData):
- ConfData=re.sub(r"rpcallowip(\s)*=(.)*", "rpcallowip=127.0.0.1", ConfData)
- else:
- ConfData = ConfData + "\nrpcallowip=127.0.0.1"
- if re.search(r"rpcport(\s)*=(.)*",ConfData):
- ConfData=re.sub(r"rpcport(\s)*=(.)*", "rpcport=43814", ConfData)
- else:
- ConfData = ConfData + "\nrpcport=43814"
- if re.search(r"server(\s)*=(.)*",ConfData):
- ConfData=re.sub(r"server(\s)*=(.)*", "server=1", ConfData)
- else:
- ConfData = ConfData + "\nserver=1\n"
- ConfFile.write(ConfData)
- ConfFile.close()
- print("\nChancoin's wallet is now configured to accept RPC connections, please restart your wallet!")
- else:
- print("\nChancoin's folder doesn't exist in Appdata, have you ever run the wallet?")
- input("\nPress ENTER to exit...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement