import requests import os import dotenv dotenv.load_dotenv() HSD_IP = '127.0.0.1' HSD_PORT = 12037 HSD_API_KEY = '' if os.getenv("HSD_IP"): HSD_IP = os.getenv("HSD_IP") if os.getenv("HSD_PORT"): HSD_PORT = os.getenv("HSD_PORT") if os.getenv("HSD_API_KEY"): HSD_API_KEY = os.getenv("HSD_API_KEY") HSD_URL = f'http://x:{HSD_API_KEY}@{HSD_IP}:{HSD_PORT}' if os.getenv("HSD_URL"): HSD_URL = os.getenv("HSD_URL") def get_tx(txid): return requests.get(f"{HSD_URL}/tx/{txid}").json() def get_block(blockhash): return requests.get(f"{HSD_URL}/block/{blockhash}").json() def get_name(name): return requests.post(HSD_URL, json={"method": "getnameinfo", "params": [name]}).json() def get_name_resource(name): return requests.post(HSD_URL, json={"method": "getnameresource", "params": [name]}).json() def get_address(address): return requests.get(f"{HSD_URL}/tx/address/{address}").json() def get_mempool(): return requests.get(f"{HSD_URL}/mempool").json() def get_mempool_info(): return requests.post(HSD_URL, json={"method": "getmempoolinfo"}).json() def get_name_from_hash(hash): return requests.post(HSD_URL, json={"method": "getnamebyhash", "params": [hash]}).json()