From fd2e18d65592d8449914fd3eab60b6bbe7996262 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 29 Dec 2023 12:50:15 +1100 Subject: [PATCH] feat: Add open --- account.py | 19 ++++++++++++++++++- main.py | 25 +++++++++++++++++++++---- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/account.py b/account.py index 1db55d4..ee418b5 100644 --- a/account.py +++ b/account.py @@ -249,4 +249,21 @@ def bid(account,domain,bid,blind): return { "error": str(e) } - \ No newline at end of file + + +def openAuction(account,domain): + account_name = check_account(account) + password = ":".join(account.split(":")[1:]) + + if account_name == False: + return { + "error": "Invalid account" + } + + try: + response = hsw.sendOPEN(account_name,password,domain) + return response + except Exception as e: + return { + "error": str(e) + } \ No newline at end of file diff --git a/main.py b/main.py index 8f44b7a..27680d7 100644 --- a/main.py +++ b/main.py @@ -14,6 +14,10 @@ app = Flask(__name__) qrcode = QRcode(app) +# Change this if network fees change +fees = 0.02 + + @app.route('/') def index(): # Check if the user is logged in @@ -68,8 +72,8 @@ def send_page(): account = account_module.check_account(request.cookies.get("account")) max = account_module.getBalance(account)['available'] - # Subtract approx fee of 0.02 - max = max - 0.02 + # Subtract approx fee + max = max - fees max = round(max, 2) message = '' @@ -117,7 +121,7 @@ def send(): if amount <= 0: return redirect("/send?message=Invalid amount&address=" + address + "&amount=" + str(amount)) - if amount > account_module.getBalance(account)['available'] - 0.02: + if amount > account_module.getBalance(account)['available'] - fees: return redirect("/send?message=Not enough funds to transfer&address=" + address + "&amount=" + str(amount)) # Send the transaction @@ -358,7 +362,6 @@ def auction(domain): raw=domainInfo,state=state, next=next, next_action=next_action, bids=bids,error=message) - @app.route('/auction//scan') def rescan_auction(domain): # Check if the user is logged in @@ -428,6 +431,20 @@ def bid_confirm(domain): return redirect("/success?tx=" + response['hash']) +@app.route('/auction//open') +def open_auction(domain): + # Check if the user is logged in + if request.cookies.get("account") is None: + return redirect("/login") + + + if not account_module.check_account(request.cookies.get("account")): + return redirect("/logout") + + domain = domain.lower() + response = account_module.openAuction(request.cookies.get("account"),domain) + return redirect("/success?tx=" + response['hash']) + #endregion