"
- content += ""
+ content += f""
content += ""
content += ""
return render_template("message.html", account=account,
-
title="xPub Key",
- content=""+xpub+"" + content)
+ content=f"{xpub}{content}")
return redirect("/settings?error=Invalid action")
@@ -1215,6 +1222,9 @@ def upload_image():
return redirect("/login?message=Not logged in")
account = request.cookies.get("account")
+ account = account_module.check_account(account)
+ if not account:
+ return redirect("/logout")
if not os.path.exists('user_data/images'):
os.mkdir('user_data/images')
@@ -1224,11 +1234,12 @@ def upload_image():
file = request.files['image']
if file.filename == '':
return redirect("/settings?error=No file selected")
- if file:
- filepath = os.path.join(f'user_data/images/{account.split(":")[0]}.{file.filename.split(".")[-1]}')
+ if file and file.filename:
+ filepath = os.path.join(f'user_data/images/{account}.{file.filename.split(".")[-1]}')
file.save(filepath)
return redirect("/settings?success=File uploaded successfully")
+ return redirect("/settings?error=An error occurred")
def latestVersion(branch):
result = requests.get(f"https://git.woodburn.au/api/v1/repos/nathanwoodburn/firewalletbrowser/branches")
@@ -1265,6 +1276,12 @@ def login_post():
account = request.form.get("account")
password = request.form.get("password")
+ if account == None or password == None:
+ wallets = account_module.listWallets()
+ wallets = render.wallets(wallets)
+ return render_template("login.html",
+ error="Invalid account or password",wallets=wallets)
+
# Check if the account is valid
if account.count(":") > 0:
wallets = account_module.listWallets()
@@ -1280,8 +1297,6 @@ def login_post():
wallets = render.wallets(wallets)
return render_template("login.html",
error="Invalid account or password",wallets=wallets)
-
-
# Set the cookie
response = make_response(redirect("/"))
response.set_cookie("account", account)
@@ -1300,6 +1315,11 @@ def register():
password = request.form.get("password")
repeatPassword = request.form.get("password_repeat")
+ if account == None or password == None or repeatPassword == None:
+ return render_template("register.html",
+ error="Invalid account or password",
+ name=account,password=password,password_repeat=repeatPassword)
+
# Check if the passwords match
if password != repeatPassword:
return render_template("register.html",
@@ -1329,10 +1349,8 @@ def register():
# Set the cookie
- response = make_response(render_template("message.html",
-
- title="Account Created",
- content="Your account has been created. Here is your seed phrase. Please write it down and keep it safe as it will not be shown again
" + response['seed']))
+ response = make_response(render_template("message.html",title="Account Created",
+ content=f"Your account has been created. Here is your seed phrase. Please write it down and keep it safe as it will not be shown again
{response['seed']}"))
response.set_cookie("account", account+":"+password)
return response
@@ -1344,6 +1362,12 @@ def import_wallet():
repeatPassword = request.form.get("password_repeat")
seed = request.form.get("seed")
+ if account == None or password == None or repeatPassword == None or seed == None:
+ return render_template("import-wallet.html",
+ error="Invalid account, password or seed",
+ name=account,password=password,password_repeat=repeatPassword,
+ seed=seed)
+
# Check if the passwords match
if password != repeatPassword:
return render_template("import-wallet.html",
@@ -1560,6 +1584,7 @@ def api_hsd(function):
stats = domainInfo['info']['stats'] if 'stats' in domainInfo['info'] else {}
state = domainInfo['info']['state']
next_action = ""
+ next = ""
if state == 'CLOSED':
if not domainInfo['info']['registered']:
if account_module.isOwnDomain(account,domain):
@@ -1638,7 +1663,10 @@ def api_wallet(function):
return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account"))
- password = request.cookies.get("account").split(":")[1]
+ if not account:
+ return jsonify({"error": "Invalid account"})
+
+ password = request.cookies.get("account","").split(":")[1]
if not account:
return jsonify({"error": "Invalid account"})
@@ -1672,7 +1700,7 @@ def api_wallet(function):
if function == "domains":
domains = account_module.getDomains(account)
- if 'error' in domains:
+ if type(domains) == dict and 'error' in domains:
return jsonify({"result": [], "error": domains['error']})
# Add nameRender to each domain
@@ -1683,7 +1711,7 @@ def api_wallet(function):
if function == "transactions":
# Get the page parameter
- page = request.args.get('page')
+ page = request.args.get('page', 1)
try:
page = int(page)
except:
@@ -1759,7 +1787,7 @@ def api_wallet_mobile(function):
return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account"))
- password = request.cookies.get("account").split(":")[1]
+ password = request.cookies.get("account","").split(":")[1]
if not account:
return jsonify({"error": "Invalid account"})
@@ -1821,7 +1849,11 @@ def renderDomain(name: str) -> str:
#region Assets and default pages
@app.route('/qr/')
def qr(data):
- return send_file(qrcode(data, mode="raw"), mimetype="image/png")
+
+ output = qrcode(data, mode="raw")
+ if output is None:
+ return jsonify({"error": "Invalid data"}), 400
+ return send_file(output, mimetype="image/png")
# Theme
@app.route('/assets/css/styles.min.css')
diff --git a/plugin.py b/plugin.py
index b162a6e..ec4b923 100644
--- a/plugin.py
+++ b/plugin.py
@@ -148,11 +148,14 @@ def getPluginData(pluginStr: str):
def getPluginFunctions(plugin: str):
- plugin = import_module(plugin.replace("/","."))
- return plugin.functions
+ imported_plugin = import_module(plugin.replace("/","."))
+ return imported_plugin.functions
-def runPluginFunction(plugin: str, function: str, params: dict, authentication: str):
+def runPluginFunction(plugin: str, function: str, params: dict, authentication: (str|None)):
+ if not authentication:
+ return {"error": "Authentication required"}
+
plugin_module = import_module(plugin.replace("/","."))
if function not in plugin_module.functions:
return {"error": "Function not found"}
@@ -189,13 +192,13 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
def getPluginFunctionInputs(plugin: str, function: str):
- plugin = import_module(plugin.replace("/","."))
- return plugin.functions[function]["params"]
+ imported_plugin = import_module(plugin.replace("/","."))
+ return imported_plugin.functions[function]["params"]
def getPluginFunctionReturns(plugin: str, function: str):
- plugin = import_module(plugin.replace("/","."))
- return plugin.functions[function]["returns"]
+ imported_plugin = import_module(plugin.replace("/","."))
+ return imported_plugin.functions[function]["returns"]
def getDomainFunctions():
diff --git a/render.py b/render.py
index a0be33f..0ddf765 100644
--- a/render.py
+++ b/render.py
@@ -7,10 +7,8 @@ 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_API = os.getenv("HSD_API","")
+HSD_IP = os.getenv("HSD_IP","localhost")
HSD_NETWORK = os.getenv("HSD_NETWORK")
HSD_WALLET_PORT = 12039
@@ -560,7 +558,6 @@ def renderDomainAsync(namehash: str) -> None:
if namehash in cache:
return
-
# Fetch the name outside the lock (network call)
name = hsd.rpc_getNameByHash(namehash)
if name["error"] is None:
@@ -576,7 +573,7 @@ def renderDomainAsync(namehash: str) -> None:
with open(NAMEHASH_CACHE, 'w') as f:
json.dump(cache, f)
- return rendered
+ return
else:
print(f"Error fetching name for hash {namehash}: {name['error']}", flush=True)
diff --git a/server.py b/server.py
index b49ab0e..396a7a7 100644
--- a/server.py
+++ b/server.py
@@ -17,8 +17,8 @@ def gunicornServer():
def load_config(self):
for key, value in self.options.items():
- if key in self.cfg.settings and value is not None:
- self.cfg.set(key.lower(), value)
+ if key in self.cfg.settings and value is not None: # type: ignore
+ self.cfg.set(key.lower(), value) # type: ignore
def load(self):
return self.application