"""What the scripts share: the keys, kept outside this folder and never printed, and the SEND prompt.""" import json import os import sys from eth_account import Account sys.stdout.reconfigure(encoding="utf-8", errors="replace") KEYS = os.path.join(os.path.expanduser("~"), ".orblivion") EXPLORER = "https://robin.etherscan.io" def load(name): """The account in ~/.orblivion/.json. The key itself is never printed.""" with open(os.path.join(KEYS, name + ".json"), encoding="utf-8") as f: return Account.from_key(json.load(f)["private_key"]) def confirm(*lines): """Nothing real is sent unless SEND is typed.""" print() for line in lines: print(line) if input("Type SEND to go ahead: ").strip() != "SEND": sys.exit("Not sent.") def amount(atoms, decimals): return atoms / 10 ** decimals def tx(h): return f"{EXPLORER}/tx/{h}"