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
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
This commit is contained in:
@@ -929,11 +929,14 @@ def getNodeSync():
|
|||||||
return sync
|
return sync
|
||||||
|
|
||||||
|
|
||||||
def getWalletStatus():
|
def getWalletStatus(verbose: bool = False):
|
||||||
response = hsw.rpc_getWalletInfo()
|
response = hsw.rpc_getWalletInfo()
|
||||||
|
|
||||||
if 'error' in response and response['error'] is not None:
|
if 'error' in response and response['error'] is not None:
|
||||||
return "Error"
|
return "Error"
|
||||||
|
|
||||||
|
if verbose:
|
||||||
|
return response.get('result', {})
|
||||||
# return response
|
# return response
|
||||||
walletHeight = response['result']['height']
|
walletHeight = response['result']['height']
|
||||||
# Get the current block height
|
# Get the current block height
|
||||||
|
|||||||
39
main.py
39
main.py
@@ -1607,7 +1607,17 @@ def plugin_function(ptype,plugin,function):
|
|||||||
#region API Routes
|
#region API Routes
|
||||||
@app.route('/api/v1/hsd/<function>', methods=["GET"])
|
@app.route('/api/v1/hsd/<function>', methods=["GET"])
|
||||||
def api_hsd(function):
|
def api_hsd(function):
|
||||||
# Check if the user is logged in
|
|
||||||
|
if function == "sync":
|
||||||
|
return jsonify({"result": account_module.getNodeSync()})
|
||||||
|
if function == "version":
|
||||||
|
return jsonify({"result": account_module.hsdVersion(False)})
|
||||||
|
if function == "height":
|
||||||
|
return jsonify({"result": account_module.getBlockHeight()})
|
||||||
|
if function == "mempool":
|
||||||
|
return jsonify({"result": account_module.getMempoolTxs()})
|
||||||
|
|
||||||
|
# Check if the user is logged in for all other functions
|
||||||
account = None
|
account = None
|
||||||
if request.cookies.get("account") is not None:
|
if request.cookies.get("account") is not None:
|
||||||
account = account_module.check_account(request.cookies.get("account"))
|
account = account_module.check_account(request.cookies.get("account"))
|
||||||
@@ -1618,17 +1628,10 @@ def api_hsd(function):
|
|||||||
|
|
||||||
if not account:
|
if not account:
|
||||||
return jsonify({"error": "Not logged in"})
|
return jsonify({"error": "Not logged in"})
|
||||||
|
|
||||||
if function == "sync":
|
if function == "mempoolBids": # This is a heavy function so only allow for logged in users
|
||||||
return jsonify({"result": account_module.getNodeSync()})
|
|
||||||
if function == "version":
|
|
||||||
return jsonify({"result": account_module.hsdVersion(False)})
|
|
||||||
if function == "height":
|
|
||||||
return jsonify({"result": account_module.getBlockHeight()})
|
|
||||||
if function == "mempool":
|
|
||||||
return jsonify({"result": account_module.getMempoolTxs()})
|
|
||||||
if function == "mempoolBids":
|
|
||||||
return jsonify({"result": account_module.getMempoolBids()})
|
return jsonify({"result": account_module.getMempoolBids()})
|
||||||
|
|
||||||
if function == "nextAuctionState":
|
if function == "nextAuctionState":
|
||||||
# Get the domain from the query parameters
|
# Get the domain from the query parameters
|
||||||
domain = request.args.get('domain')
|
domain = request.args.get('domain')
|
||||||
@@ -1712,7 +1715,13 @@ def api_hsd_mobile(function):
|
|||||||
|
|
||||||
@app.route('/api/v1/wallet/<function>', methods=["GET"])
|
@app.route('/api/v1/wallet/<function>', methods=["GET"])
|
||||||
def api_wallet(function):
|
def api_wallet(function):
|
||||||
# Check if the user is logged in
|
|
||||||
|
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
|
account = None
|
||||||
password = None
|
password = None
|
||||||
if request.cookies.get("account") is not None:
|
if request.cookies.get("account") is not None:
|
||||||
@@ -1727,9 +1736,9 @@ def api_wallet(function):
|
|||||||
if not account:
|
if not account:
|
||||||
return jsonify({"error": "Not logged in"})
|
return jsonify({"error": "Not logged in"})
|
||||||
|
|
||||||
if function == "sync":
|
if function == "balance":
|
||||||
return jsonify({"result": account_module.getWalletStatus()})
|
return jsonify({"result": account_module.getBalance(account)})
|
||||||
|
|
||||||
if function == "available":
|
if function == "available":
|
||||||
return jsonify({"result": account_module.getBalance(account)['available']})
|
return jsonify({"result": account_module.getBalance(account)['available']})
|
||||||
if function == "total":
|
if function == "total":
|
||||||
|
|||||||
Reference in New Issue
Block a user