fireindexer-front/hsd.py
Nathan Woodburn 194b9c7d2e
All checks were successful
Build Docker / BuildImage (push) Successful in 42s
feat: Add initial front design
2025-02-06 22:50:56 +11:00

50 lines
1.2 KiB
Python

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()