diff --git a/FireWalletBrowser.bsdesign b/FireWalletBrowser.bsdesign index 78b228b..d89b3ef 100644 Binary files a/FireWalletBrowser.bsdesign and b/FireWalletBrowser.bsdesign differ diff --git a/main.py b/main.py index fed77a7..dc456af 100644 --- a/main.py +++ b/main.py @@ -1508,57 +1508,6 @@ def api_hsd(function): return jsonify({"result": account_module.getBlockHeight()}) return jsonify({"error": "Invalid function", "result": "Invalid function"}), 400 - -@app.route('/api/v1/transactions', methods=["GET"]) -def api_transactions(): - # 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"}) - - # Get the page parameter - page = request.args.get('page') - try: - page = int(page) - except: - page = 1 - - if page < 1: - page = 1 - - # Check for force refresh parameter - force_refresh = request.args.get('refresh') == 'true' - - # Create a cache key based on account and page - cache_key = f"{account}_{page}" - - # Check if data is in cache and not expired - current_time = time.time() - if not force_refresh and cache_key in tx_cache and (current_time - tx_cache[cache_key]['time'] < TX_CACHE_TIMEOUT): - transactions = tx_cache[cache_key]['data'] - txCount = len(transactions) - transactions_html = tx_cache[cache_key]['html'] - else: - # Fetch transactions from account module - transactions = account_module.getTransactions(account, page) - txCount = len(transactions) - transactions_html = render.transactions(transactions) - - # Store in cache - tx_cache[cache_key] = { - 'data': transactions, - 'html': transactions_html, - 'time': current_time - } - - return jsonify({ - "html": transactions_html, - "txCount": txCount, - "page": page - }) @app.route('/api/v1/wallet/', methods=["GET"]) def api_wallet(function): @@ -1610,6 +1559,49 @@ def api_wallet(function): return jsonify({"result": domains}) + if function == "transactions": + # Get the page parameter + page = request.args.get('page') + try: + page = int(page) + except: + page = 1 + + if page < 1: + page = 1 + + # Check for force refresh parameter + force_refresh = request.args.get('refresh') == 'true' + + # Create a cache key based on account and page + cache_key = f"{account}_{page}" + + # Check if data is in cache and not expired + current_time = time.time() + if not force_refresh and cache_key in tx_cache and (current_time - tx_cache[cache_key]['time'] < TX_CACHE_TIMEOUT): + transactions = tx_cache[cache_key]['data'] + txCount = len(transactions) + transactions_html = tx_cache[cache_key]['html'] + else: + # Fetch transactions from account module + transactions = account_module.getTransactions(account, page) + txCount = len(transactions) + transactions_html = render.transactions(transactions) + + # Store in cache + tx_cache[cache_key] = { + 'data': transactions, + 'html': transactions_html, + 'time': current_time + } + + return jsonify({ + "html": transactions_html, + "txCount": txCount, + "page": page + }) + + if function == "icon": # Check if there is an icon if not os.path.exists(f'user_data/images'): diff --git a/templates/tx.html b/templates/tx.html index 92b9bda..f719967 100644 --- a/templates/tx.html +++ b/templates/tx.html @@ -119,7 +119,7 @@ const loadingRow = document.getElementById('loading-row'); // Fetch transactions - fetch(`/api/v1/transactions?page=${page}`) + fetch(`/api/v1/wallet/transactions?page=${page}`) .then(response => response.json()) .then(data => { if (data.error) {