From 0164a9c3f2ad1c7beceb9757b1f6127520e4a012 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 7 Jul 2025 12:20:16 +1000 Subject: [PATCH] fix: Remove Niami API requirement for searching for domains --- account.py | 18 ++++++++++++++++++ domainLookup.py | 29 ----------------------------- main.py | 13 +++++++------ 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/account.py b/account.py index d92d15d..f98db89 100644 --- a/account.py +++ b/account.py @@ -472,6 +472,24 @@ def getDomain(domain: str): } return response['result'] +def getAddressFromCoin(coinhash: str, coinindex = 0): + # Get the address from the hash + response = requests.get(f"http://x:{HSD_API}@{HSD_IP}:{HSD_NODE_PORT}/coin/{coinhash}/{coinindex}") + if response.status_code != 200: + return { + "error": { + "message": "Error getting address from coin" + } + } + data = response.json() + if 'address' not in data: + return { + "error": { + "message": "Error getting address from coin" + } + } + return data['address'] + def renewDomain(account, domain): account_name = check_account(account) diff --git a/domainLookup.py b/domainLookup.py index cbe454b..8ac30a7 100644 --- a/domainLookup.py +++ b/domainLookup.py @@ -138,35 +138,6 @@ def resolve_TLSA_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"): tlsa = r.answer[0][0] return tlsa - -def niami_info(domain: str): - response = requests.get(f"https://api.niami.io/hsd/{domain}") - if response.status_code != 200: - return False - - response = response.json() - if response["data"]["owner_tx_data"] is not None: - output = { - "owner": response["data"]["owner_tx_data"]["address"] - } - else: - output = { - "owner": None - } - - if 'dnsData' in response["data"]: - output["dns"] = response["data"]["dnsData"] - else: - output["dns"] = [] - - transactions = requests.get(f"https://api.niami.io/txs/{domain}") - if transactions.status_code != 200: - return False - - transactions = transactions.json() - output["txs"] = transactions["txs"] - return output - def emoji_to_punycode(emoji): try: diff --git a/main.py b/main.py index 8141251..a3fab1d 100644 --- a/main.py +++ b/main.py @@ -464,15 +464,17 @@ def search(): - domain_info = domainLookup.niami_info(search_term) + domain_info = account_module.getDomain(search_term) owner = 'Unknown' dns = [] txs = [] if domain_info: - owner = domain_info['owner'] - dns = domain_info['dns'] - txs = domain_info['txs'] + # Check if info and info.owner + if 'info' in domain_info and 'owner' in domain_info['info']: + owner = account_module.getAddressFromCoin(domain_info['info']['owner']['hash'],domain_info['info']['owner']['index']) + + dns = account_module.getDNS(search_term) own_domains = account_module.getDomains(account) own_domains = [x['name'] for x in own_domains] @@ -481,13 +483,12 @@ def search(): owner = "You" dns = render.dns(dns) - txs = render.txs(txs) return render_template("search.html", account=account, rendered=renderDomain(search_term), search_term=search_term,domain=domain['info']['name'], raw=domain,state=state, next=next, owner=owner, - dns=dns, txs=txs,plugins=plugins) + dns=dns,plugins=plugins) @app.route('/manage/') def manage(domain: str):