feat: Add more code cleanup
All checks were successful
Build Docker / Build Image (push) Successful in 51s

This commit is contained in:
2025-08-25 12:36:11 +10:00
parent a619d78efd
commit 599c0df00c
3 changed files with 25 additions and 18 deletions

View File

@@ -10,10 +10,8 @@ import time
dotenv.load_dotenv()
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
@@ -47,9 +45,7 @@ cacheTime = 3600
# Verify the connection
response = hsd.getInfo()
EXCLUDE = ["primary"]
if os.getenv("EXCLUDE") is not None:
EXCLUDE = os.getenv("EXCLUDE").split(",")
EXCLUDE = os.getenv("EXCLUDE","primary").split(",")
def hsdConnected():
@@ -426,6 +422,12 @@ def check_hip2(domain: str):
def send(account, address, amount):
account_name = check_account(account)
password = ":".join(account.split(":")[1:])
if not account_name:
return {
"error": {
"message": "Invalid account"
}
}
response = hsw.rpc_selectWallet(account_name)
if response['error'] is not None:
return {
@@ -730,9 +732,13 @@ def getPendingFinalizes(account, password):
pending = []
try:
for output in tx['outputs']:
if output['covenant']['type'] != 10:
if type(output) != dict:
continue
if output['covenant']['action'] != "FINALIZE":
if not 'covenant' in output:
continue
if output['covenant'].get("type") != 10:
continue
if output['covenant'].get('action') != "FINALIZE":
continue
nameHash = output['covenant']['items'][0]
# Try to get the name from hash

View File

@@ -13,6 +13,7 @@ import httpx
from requests_doh import DNSOverHTTPSSession, add_dns_provider
import requests
import urllib3
from cryptography.x509.oid import ExtensionOID
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) # Disable insecure request warnings (since we are manually verifying the certificate)
@@ -59,7 +60,7 @@ def hip2(domain: str):
domains = []
for ext in cert_obj.extensions:
if ext.oid == x509.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
if ext.oid == ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
san_list = ext.value.get_values_for_type(x509.DNSName)
domains.extend(san_list)
@@ -133,7 +134,7 @@ def wallet_txt(domain: str, doh_url="https://hnsdoh.com/dns-query"):
wallet_record = "No WALLET record found"
for ans in r.answer:
raw = ans[0].to_wire()
raw = ans[0].to_wire() # type: ignore
try:
data = raw[1:].decode("utf-8", errors="ignore")
except UnicodeDecodeError:
@@ -155,7 +156,7 @@ def resolve_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):
q = dns.message.make_query(query_name, dns.rdatatype.A)
r = dns.query.https(q, doh_url, session=client)
ip = r.answer[0][0].address
ip = r.answer[0][0].address # type: ignore
return ip
def resolve_TLSA_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):

View File

@@ -148,8 +148,8 @@ 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|None)):
@@ -192,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():