diff --git a/.gitignore b/.gitignore index 9a72b84..397f345 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ templates/assets/css/styles.min.css ignore/ plugins/signatures.json + +.venv/ diff --git a/FireWalletBrowser.bsdesign b/FireWalletBrowser.bsdesign index dab157a..9abefb7 100644 Binary files a/FireWalletBrowser.bsdesign and b/FireWalletBrowser.bsdesign differ diff --git a/account.py b/account.py index bd7e663..5b3dde1 100644 --- a/account.py +++ b/account.py @@ -138,6 +138,8 @@ def getBalance(account: str): if domain['state'] == "CLOSED": domainValue += domain['value'] total = total - (domainValue/1000000) + locked = locked - (domainValue/1000000) + # Only keep 2 decimal places total = round(total, 2) @@ -303,6 +305,12 @@ def getDNS(domain: str): return { "error": response['error']['message'] } + if 'result' not in response: + return { + "error": "No DNS records" + } + if 'records' not in response['result']: + return [] return response['result']['records'] diff --git a/domainLookup.py b/domainLookup.py index d04aeb0..85289ff 100644 --- a/domainLookup.py +++ b/domainLookup.py @@ -168,4 +168,10 @@ def emoji_to_punycode(emoji): try: return emoji.encode("idna").decode("ascii") except Exception as e: - return "" \ No newline at end of file + return emoji + +def punycode_to_emoji(punycode): + try: + return punycode.encode("ascii").decode("idna") + except Exception as e: + return punycode \ No newline at end of file diff --git a/main.py b/main.py index 5dc8331..f039e08 100644 --- a/main.py +++ b/main.py @@ -101,9 +101,6 @@ def index(): functionOutput = plugins_module.runPluginFunction(function["plugin"],function["function"],{},request.cookies.get("account")) plugins += render.plugin_output_dash(functionOutput,plugins_module.getPluginFunctionReturns(function["plugin"],function["function"])) - - - return render_template("index.html", account=account, available=available, total=total, pending=pending, domains=domains, domainsMobile=domainsMobile, plugins=plugins, @@ -1047,6 +1044,8 @@ def settings(): branch = info['refs'] if branch != "main": branch = f"({branch})" + else: + branch = "" last_commit = info['author_date'] # import to time from format "2024-02-13 11:24:03" last_commit = datetime.datetime.strptime(last_commit, "%Y-%m-%d %H:%M:%S") diff --git a/plugins/automations.py b/plugins/automations.py index e601ffa..9324224 100644 --- a/plugins/automations.py +++ b/plugins/automations.py @@ -3,7 +3,7 @@ import account import requests import threading import os -import datetime +import time APIKEY = os.environ.get("hsd_api") ip = os.getenv("hsd_ip") @@ -37,45 +37,47 @@ functions = { } } -started = 0 +started = False # Main entry point only lets the main function run every 5 mins def automation(params, authentication): global started - now = datetime.datetime.now().timestamp() - # Add 5 mins - now = now - 300 - if now < started: - return {"Status": "Waiting before checking for new actions"} - started = datetime.datetime.now().timestamp() + + if started: + return {"Status": "Auto Renews running"} + started = True threading.Thread(target=automations_background, args=(authentication,)).start() - return {"Status": "Checking for actions"} + return {"Status": "Started Auto Renews"} # Background function to run the automations def automations_background(authentication): - print("Running automations") - # Get account details - account_name = account.check_account(authentication) - password = ":".join(authentication.split(":")[1:]) + while True: + print("Running automations") + # Get account details + account_name = account.check_account(authentication) + password = ":".join(authentication.split(":")[1:]) - if account_name == False: - return { - "error": { - "message": "Invalid account" + if account_name == False: + return { + "error": { + "message": "Invalid account" + } } - } - try: - # Try to select and login to the wallet - response = account.hsw.rpc_selectWallet(account_name) - if response['error'] is not None: - return - response = account.hsw.rpc_walletPassphrase(password,10) - if response['error'] is not None: - return - # Try to send the batch of all renew, reveal and redeem actions - requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["RENEW"]]]}) - requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["REVEAL"]]]}) - requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["REDEEM"]]]}) - except Exception as e: - print(e) \ No newline at end of file + try: + # Try to select and login to the wallet + response = account.hsw.rpc_selectWallet(account_name) + if response['error'] is not None: + return + response = account.hsw.rpc_walletPassphrase(password,10) + if response['error'] is not None: + return + # Try to send the batch of all renew, reveal and redeem actions + requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["RENEW"]]]}) + requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["REVEAL"]]]}) + requests.post(f"http://x:{APIKEY}@{ip}:12039",json={"method": "sendbatch","params": [[["REDEEM"]]]}) + except Exception as e: + print(e) + + # Sleep for 5 mins before running again + time.sleep(300) \ No newline at end of file diff --git a/plugins/txcount.py b/plugins/txcount.py new file mode 100644 index 0000000..7a1fcf8 --- /dev/null +++ b/plugins/txcount.py @@ -0,0 +1,35 @@ +import json +import account +import requests + +# Plugin Data +info = { + "name": "TX Count", + "description": "Plugin for checking how many txs are in a wallet", + "version": "1.0", + "author": "Nathan.Woodburn/" +} + +# Functions +functions = { + "main":{ + "name": "List TXs", + "type": "default", + "description": "Get TXs", + "params": {}, + "returns": { + "txs": + { + "name": "Transactions", + "type": "text" + } + } + } +} + +def main(params, authentication): + wallet = authentication.split(":")[0] + txs = account.getTransactions(wallet) + + return {"txs": f'Total TXs: {len(txs)}'} + \ No newline at end of file diff --git a/plugins/varo.py b/plugins/varo.py index 1ea52b8..f9cb972 100644 --- a/plugins/varo.py +++ b/plugins/varo.py @@ -17,7 +17,7 @@ functions = { "status":{ "name": "Check connection", "type": "dashboard", - "description": "You need tp set varo_instance to the ICANN domain of the chosen Varo instance and varo_api to your varo API key before you can connect", + "description": "You need to set varo_instance to the ICANN domain of the chosen Varo instance and varo_api to your varo API key before you can connect", "params": {}, "returns": { "status": diff --git a/render.py b/render.py index eb35f5c..2229394 100644 --- a/render.py +++ b/render.py @@ -2,14 +2,11 @@ import datetime import json import urllib.parse from flask import render_template +from domainLookup import punycode_to_emoji def domains(domains, mobile=False): html = '' for domain in domains: - owner = domain['owner'] - if 'index' in owner: - if owner['index'] == 0: - continue expires = domain['stats'] if 'daysUntilExpire' in expires: expires = expires['daysUntilExpire'] @@ -17,12 +14,17 @@ def domains(domains, mobile=False): expires = "No expiration date" paid = domain['value'] paid = paid / 1000000 - + + # Handle punycodes + name = domain['name'] + emoji = punycode_to_emoji(name) + if emoji != name: + name = f'{emoji} ({name})' if not mobile: - html += f'