From 45fdaa2de48a5993d84e94343ef7d593f25262e2 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Mon, 8 Apr 2024 11:44:50 +1000 Subject: [PATCH] feat: Add tx count plugin and fixed dns error --- account.py | 6 ++++++ main.py | 3 --- plugins/txcount.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 plugins/txcount.py diff --git a/account.py b/account.py index 75295ec..5b3dde1 100644 --- a/account.py +++ b/account.py @@ -305,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/main.py b/main.py index 33b36bc..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, 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