6 Commits

Author SHA1 Message Date
d33336a643 fix: Correct missing sorting for date
All checks were successful
Tests and Linting / Tests-Linting (3.11) (push) Successful in 35s
Tests and Linting / Tests-Linting (3.10) (push) Successful in 43s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 44s
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 51s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 1m0s
2025-09-24 12:32:06 +10:00
be760ddc8b fix: Try new sorting method again
All checks were successful
Tests and Linting / Tests-Linting (3.11) (push) Successful in 37s
Tests and Linting / Tests-Linting (3.10) (push) Successful in 43s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 45s
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 54s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 1m0s
2025-09-24 12:29:14 +10:00
1b53c2a905 fix: Try a new sorting method
All checks were successful
Tests and Linting / Tests-Linting (3.10) (push) Successful in 29s
Tests and Linting / Tests-Linting (3.11) (push) Successful in 30s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 33s
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 39s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 48s
2025-09-24 12:23:48 +10:00
5f46f1e3bf fix: Try to sort unknown domains together
All checks were successful
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 3m0s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 3m1s
Tests and Linting / Tests-Linting (3.11) (push) Successful in 3m10s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 3m15s
Tests and Linting / Tests-Linting (3.10) (push) Successful in 3m20s
2025-09-24 12:04:06 +10:00
d9e847a995 feat: Add support for verbose sync status and don't require auth for some api routes
All checks were successful
Tests and Linting / Tests-Linting (3.11) (push) Successful in 28s
Tests and Linting / Tests-Linting (3.10) (push) Successful in 30s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 30s
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 45s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 48s
2025-09-16 22:16:29 +10:00
15d919ca97 feat: Add option to use http basic auth for api routes
All checks were successful
Build Docker / Build Images (map[dockerfile:Dockerfile.hsd tag_suffix:-hsd target:hsd]) (push) Successful in 3m2s
Build Docker / Build Images (map[dockerfile:Dockerfile tag_suffix: target:default]) (push) Successful in 3m8s
Tests and Linting / Tests-Linting (3.11) (push) Successful in 3m12s
Tests and Linting / Tests-Linting (3.13) (push) Successful in 3m19s
Tests and Linting / Tests-Linting (3.10) (push) Successful in 3m24s
This shoudl make it easier to use curl to access info
2025-09-16 16:42:09 +10:00
4 changed files with 55 additions and 28 deletions

Binary file not shown.

View File

@@ -119,6 +119,8 @@ def check_account(cookie: str | None):
return False
account = cookie.split(":")[0]
if len(account) < 1:
return False
# Check if the account is valid
info = hsw.getAccountInfo(account, 'default')
if 'error' in info:
@@ -927,11 +929,14 @@ def getNodeSync():
return sync
def getWalletStatus():
def getWalletStatus(verbose: bool = False):
response = hsw.rpc_getWalletInfo()
if 'error' in response and response['error'] is not None:
return "Error"
if verbose:
return response.get('result', {})
# return response
walletHeight = response['result']['height']
# Get the current block height
@@ -1571,6 +1576,12 @@ def getMempoolBids():
def rescan():
try:
response = hsw.walletRescan(0)
if 'success' in response and response['success'] is False:
return {
"error": {
"message": "Rescan already in progress"
}
}
return response
except Exception as e:
return {

62
main.py
View File

@@ -1607,14 +1607,7 @@ def plugin_function(ptype,plugin,function):
#region API Routes
@app.route('/api/v1/hsd/<function>', methods=["GET"])
def api_hsd(function):
# Check if the user is logged in
if request.cookies.get("account") is None:
return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account"))
if not account:
return jsonify({"error": "Invalid account"})
if function == "sync":
return jsonify({"result": account_module.getNodeSync()})
if function == "version":
@@ -1623,8 +1616,22 @@ def api_hsd(function):
return jsonify({"result": account_module.getBlockHeight()})
if function == "mempool":
return jsonify({"result": account_module.getMempoolTxs()})
if function == "mempoolBids":
# Check if the user is logged in for all other functions
account = None
if request.cookies.get("account") is not None:
account = account_module.check_account(request.cookies.get("account"))
# Allow login using http basic auth
if account is None and request.authorization is not None:
account = account_module.check_account(f"{request.authorization.username}:{request.authorization.password}")
if not account:
return jsonify({"error": "Not logged in"})
if function == "mempoolBids": # This is a heavy function so only allow for logged in users
return jsonify({"result": account_module.getMempoolBids()})
if function == "nextAuctionState":
# Get the domain from the query parameters
domain = request.args.get('domain')
@@ -1708,21 +1715,30 @@ def api_hsd_mobile(function):
@app.route('/api/v1/wallet/<function>', methods=["GET"])
def api_wallet(function):
# Check if the user is logged in
if request.cookies.get("account") is None:
if function == "sync":
# Check if arg verbose is set
verbose = request.args.get('verbose', 'false').lower() == 'true'
return jsonify({"result": account_module.getWalletStatus(verbose)})
# Check if the user is logged in for all other functions
account = None
password = None
if request.cookies.get("account") is not None:
account = account_module.check_account(request.cookies.get("account"))
password = request.cookies.get("account","").split(":")[1]
# Allow login using http basic auth
if account is None and request.authorization is not None:
account = account_module.check_account(f"{request.authorization.username}:{request.authorization.password}")
password = request.authorization.password
if not account:
return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account"))
if not account:
return jsonify({"error": "Invalid account"})
if function == "balance":
return jsonify({"result": account_module.getBalance(account)})
password = request.cookies.get("account","").split(":")[1]
if not account:
return jsonify({"error": "Invalid account"})
if function == "sync":
return jsonify({"result": account_module.getWalletStatus()})
if function == "available":
return jsonify({"result": account_module.getBalance(account)['available']})
if function == "total":
@@ -2021,8 +2037,8 @@ def get_alerts(account:str) -> list:
wallet_status = account_module.getWalletStatus()
if wallet_status != "Ready":
alerts.append({
"name": "Wallet",
"output": f"The wallet is not synced ({wallet_status}). Please wait for it to sync."
"name": "Wallet Not Synced",
"output": "Please wait for it to sync."
})
# Try to read from notifications sqlite database
if os.path.exists("user_data/notifications.db"):

File diff suppressed because one or more lines are too long