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","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' # Validate cache version if os.path.exists(NAMEHASH_CACHE): with open(NAMEHASH_CACHE, 'r') as f: cache = json.load(f) if not isinstance(cache, dict): print("Invalid namehash cache format. Resetting cache.") with open(NAMEHASH_CACHE, 'w') as f: json.dump({}, f) # Check if cache entries are valid for key in cache: if not cache[key].startswith("
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'