import datetime import json import urllib.parse from flask import render_template from domainLookup import punycode_to_emoji import os from handywrapper import api import threading HSD_API = os.getenv("HSD_API") HSD_IP = os.getenv("HSD_IP") if HSD_IP is None: HSD_IP = "localhost" HSD_NETWORK = os.getenv("HSD_NETWORK") HSD_WALLET_PORT = 12039 HSD_NODE_PORT = 12037 if not HSD_NETWORK: HSD_NETWORK = "main" else: HSD_NETWORK = HSD_NETWORK.lower() if HSD_NETWORK == "simnet": HSD_WALLET_PORT = 15039 HSD_NODE_PORT = 15037 elif HSD_NETWORK == "testnet": HSD_WALLET_PORT = 13039 HSD_NODE_PORT = 13037 elif HSD_NETWORK == "regtest": HSD_WALLET_PORT = 14039 HSD_NODE_PORT = 14037 hsd = api.hsd(HSD_API, HSD_IP, HSD_NODE_PORT) # Get Explorer URL TX_EXPLORER_URL = os.getenv("EXPLORER_TX") if TX_EXPLORER_URL is None: TX_EXPLORER_URL = "https://shakeshift.com/transaction/" NAMEHASH_CACHE = 'user_data/namehash_cache.json' CACHE_LOCK = threading.Lock() def domains(domains, mobile=False): html = '' for domain in domains: expires = domain['stats'] if 'daysUntilExpire' in expires: expires = expires['daysUntilExpire'] else: expires = "No expiration date" paid = domain['value'] paid = paid / 1000000 # Handle punycodes name = renderDomain(domain['name']) link = f'/manage/{domain["name"]}' link_action = "Manage" if domain['registered'] == False: link_action = "Register" link = f'/auction/{domain["name"]}/register' if not mobile: html += f'
Returns: {returns}
' html += f'Returns: {returns}
' html += f'' html += f'' return html def plugin_output(outputs, returns): html = '' for returnOutput in returns: if returnOutput not in outputs: continue html += f'{output}
' elif returns[returnOutput]["type"] == "tx": html += render_template('components/tx.html', tx=output) elif returns[returnOutput]["type"] == "dns": output = json.loads(output) html += render_template('components/dns-output.html', dns=dns(output)) html += f'