forked from nathanwoodburn/firewalletbrowser
fix: Remove Niami API requirement for searching for domains
This commit is contained in:
18
account.py
18
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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
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'
|
||||
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/<domain>')
|
||||
def manage(domain: str):
|
||||
|
||||
Reference in New Issue
Block a user