feat: Add more code cleanup
All checks were successful
Build Docker / Build Image (push) Successful in 51s
All checks were successful
Build Docker / Build Image (push) Successful in 51s
This commit is contained in:
24
account.py
24
account.py
@@ -10,10 +10,8 @@ import time
|
|||||||
|
|
||||||
dotenv.load_dotenv()
|
dotenv.load_dotenv()
|
||||||
|
|
||||||
HSD_API = os.getenv("HSD_API")
|
HSD_API = os.getenv("HSD_API","")
|
||||||
HSD_IP = os.getenv("HSD_IP")
|
HSD_IP = os.getenv("HSD_IP","localhost")
|
||||||
if HSD_IP is None:
|
|
||||||
HSD_IP = "localhost"
|
|
||||||
|
|
||||||
HSD_NETWORK = os.getenv("HSD_NETWORK")
|
HSD_NETWORK = os.getenv("HSD_NETWORK")
|
||||||
HSD_WALLET_PORT = 12039
|
HSD_WALLET_PORT = 12039
|
||||||
@@ -47,9 +45,7 @@ cacheTime = 3600
|
|||||||
# Verify the connection
|
# Verify the connection
|
||||||
response = hsd.getInfo()
|
response = hsd.getInfo()
|
||||||
|
|
||||||
EXCLUDE = ["primary"]
|
EXCLUDE = os.getenv("EXCLUDE","primary").split(",")
|
||||||
if os.getenv("EXCLUDE") is not None:
|
|
||||||
EXCLUDE = os.getenv("EXCLUDE").split(",")
|
|
||||||
|
|
||||||
|
|
||||||
def hsdConnected():
|
def hsdConnected():
|
||||||
@@ -426,6 +422,12 @@ def check_hip2(domain: str):
|
|||||||
def send(account, address, amount):
|
def send(account, address, amount):
|
||||||
account_name = check_account(account)
|
account_name = check_account(account)
|
||||||
password = ":".join(account.split(":")[1:])
|
password = ":".join(account.split(":")[1:])
|
||||||
|
if not account_name:
|
||||||
|
return {
|
||||||
|
"error": {
|
||||||
|
"message": "Invalid account"
|
||||||
|
}
|
||||||
|
}
|
||||||
response = hsw.rpc_selectWallet(account_name)
|
response = hsw.rpc_selectWallet(account_name)
|
||||||
if response['error'] is not None:
|
if response['error'] is not None:
|
||||||
return {
|
return {
|
||||||
@@ -730,9 +732,13 @@ def getPendingFinalizes(account, password):
|
|||||||
pending = []
|
pending = []
|
||||||
try:
|
try:
|
||||||
for output in tx['outputs']:
|
for output in tx['outputs']:
|
||||||
if output['covenant']['type'] != 10:
|
if type(output) != dict:
|
||||||
continue
|
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
|
continue
|
||||||
nameHash = output['covenant']['items'][0]
|
nameHash = output['covenant']['items'][0]
|
||||||
# Try to get the name from hash
|
# Try to get the name from hash
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import httpx
|
|||||||
from requests_doh import DNSOverHTTPSSession, add_dns_provider
|
from requests_doh import DNSOverHTTPSSession, add_dns_provider
|
||||||
import requests
|
import requests
|
||||||
import urllib3
|
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)
|
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 = []
|
domains = []
|
||||||
for ext in cert_obj.extensions:
|
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)
|
san_list = ext.value.get_values_for_type(x509.DNSName)
|
||||||
domains.extend(san_list)
|
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"
|
wallet_record = "No WALLET record found"
|
||||||
for ans in r.answer:
|
for ans in r.answer:
|
||||||
raw = ans[0].to_wire()
|
raw = ans[0].to_wire() # type: ignore
|
||||||
try:
|
try:
|
||||||
data = raw[1:].decode("utf-8", errors="ignore")
|
data = raw[1:].decode("utf-8", errors="ignore")
|
||||||
except UnicodeDecodeError:
|
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)
|
q = dns.message.make_query(query_name, dns.rdatatype.A)
|
||||||
r = dns.query.https(q, doh_url, session=client)
|
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
|
return ip
|
||||||
|
|
||||||
def resolve_TLSA_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):
|
def resolve_TLSA_with_doh(query_name, doh_url="https://hnsdoh.com/dns-query"):
|
||||||
|
|||||||
12
plugin.py
12
plugin.py
@@ -148,8 +148,8 @@ def getPluginData(pluginStr: str):
|
|||||||
|
|
||||||
|
|
||||||
def getPluginFunctions(plugin: str):
|
def getPluginFunctions(plugin: str):
|
||||||
plugin = import_module(plugin.replace("/","."))
|
imported_plugin = import_module(plugin.replace("/","."))
|
||||||
return plugin.functions
|
return imported_plugin.functions
|
||||||
|
|
||||||
|
|
||||||
def runPluginFunction(plugin: str, function: str, params: dict, authentication: (str|None)):
|
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):
|
def getPluginFunctionInputs(plugin: str, function: str):
|
||||||
plugin = import_module(plugin.replace("/","."))
|
imported_plugin = import_module(plugin.replace("/","."))
|
||||||
return plugin.functions[function]["params"]
|
return imported_plugin.functions[function]["params"]
|
||||||
|
|
||||||
|
|
||||||
def getPluginFunctionReturns(plugin: str, function: str):
|
def getPluginFunctionReturns(plugin: str, function: str):
|
||||||
plugin = import_module(plugin.replace("/","."))
|
imported_plugin = import_module(plugin.replace("/","."))
|
||||||
return plugin.functions[function]["returns"]
|
return imported_plugin.functions[function]["returns"]
|
||||||
|
|
||||||
|
|
||||||
def getDomainFunctions():
|
def getDomainFunctions():
|
||||||
|
|||||||
Reference in New Issue
Block a user