fix: Remove Niami API requirement for searching for domains
All checks were successful
Build Docker / Build Image (push) Successful in 2m36s
All checks were successful
Build Docker / Build Image (push) Successful in 2m36s
This commit is contained in:
18
account.py
18
account.py
@@ -472,6 +472,24 @@ def getDomain(domain: str):
|
|||||||
}
|
}
|
||||||
return response['result']
|
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):
|
def renewDomain(account, domain):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
|
|||||||
@@ -138,35 +138,6 @@ def resolve_TLSA_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):
|
|||||||
tlsa = r.answer[0][0]
|
tlsa = r.answer[0][0]
|
||||||
return tlsa
|
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):
|
def emoji_to_punycode(emoji):
|
||||||
try:
|
try:
|
||||||
|
|||||||
13
main.py
13
main.py
@@ -464,15 +464,17 @@ def search():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
domain_info = domainLookup.niami_info(search_term)
|
domain_info = account_module.getDomain(search_term)
|
||||||
owner = 'Unknown'
|
owner = 'Unknown'
|
||||||
dns = []
|
dns = []
|
||||||
txs = []
|
txs = []
|
||||||
|
|
||||||
if domain_info:
|
if domain_info:
|
||||||
owner = domain_info['owner']
|
# Check if info and info.owner
|
||||||
dns = domain_info['dns']
|
if 'info' in domain_info and 'owner' in domain_info['info']:
|
||||||
txs = domain_info['txs']
|
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 = account_module.getDomains(account)
|
||||||
own_domains = [x['name'] for x in own_domains]
|
own_domains = [x['name'] for x in own_domains]
|
||||||
@@ -481,13 +483,12 @@ def search():
|
|||||||
owner = "You"
|
owner = "You"
|
||||||
|
|
||||||
dns = render.dns(dns)
|
dns = render.dns(dns)
|
||||||
txs = render.txs(txs)
|
|
||||||
|
|
||||||
return render_template("search.html", account=account,
|
return render_template("search.html", account=account,
|
||||||
rendered=renderDomain(search_term),
|
rendered=renderDomain(search_term),
|
||||||
search_term=search_term,domain=domain['info']['name'],
|
search_term=search_term,domain=domain['info']['name'],
|
||||||
raw=domain,state=state, next=next, owner=owner,
|
raw=domain,state=state, next=next, owner=owner,
|
||||||
dns=dns, txs=txs,plugins=plugins)
|
dns=dns,plugins=plugins)
|
||||||
|
|
||||||
@app.route('/manage/<domain>')
|
@app.route('/manage/<domain>')
|
||||||
def manage(domain: str):
|
def manage(domain: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user