import json from os.path import isfile # Money # {username: [balance, OpenKey], ...} class users(): def read(): if not isfile("users.json"): sys('echo "{}" > users.json') with open('users.json', 'r') as openfile: data = json.load(openfile) return data def write(data): js = json.dumps(data, indent=4) with open("users.json", "w") as outfile: outfile.write(js) # Mining + Registrations # Hash is encrypted! # [ {"PrevHash": "00043dsafd", "nonce": 1,"date": , "OpenKey": "762eagdfgtars5e34"}, ...] class mine(): def read(): if not isfile("mine.json"): #sys('echo "[]" > mine.json') mine.write([]) with open('mine.json', 'r') as openfile: data = json.load(openfile) return data def write(data): js = json.dumps(data, indent=4) with open("mine.json", "w") as outfile: outfile.write(js) # Pay + Registrations? # Hash is encrypted! # [ {"Payer": "user32532", "Receiver": "user64582", "OpenKey": "762eagdfgtars5e34", "PrevHash": "fsd2675ads"} , ...] class pay(): def read(): if not isfile("pay.json"): sys('echo "[]" > pay.json') with open('pay.json', 'r') as openfile: data = json.load(openfile) return data def write(data): js = json.dumps(data, indent=4) with open("pay.json", "w") as outfile: outfile.write(js) # Ways # [bore.pub:5423, bore.pub:2239, ...] class ways(): def read(): if not isfile("ways.json"): sys('echo "[]" > ways.json') with open('ways.json', 'r') as openfile: data = json.load(openfile) return data def write(data): js = json.dumps(data, indent=4) with open("ways.json", "w") as outfile: outfile.write(js)