fireindexer-front/hsd.py

50 lines
1.1 KiB
Python
Raw Normal View History

2025-02-05 18:08:31 +11:00
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")
print(f"Using HSD_URL: {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):
2025-02-05 18:37:13 +11:00
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()