feat: Add open

This commit is contained in:
Nathan Woodburn 2023-12-29 12:50:15 +11:00
parent 9e02fd7774
commit fd2e18d655
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
2 changed files with 39 additions and 5 deletions

View File

@ -250,3 +250,20 @@ def bid(account,domain,bid,blind):
"error": str(e) "error": str(e)
} }
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)
}

25
main.py
View File

@ -14,6 +14,10 @@ app = Flask(__name__)
qrcode = QRcode(app) qrcode = QRcode(app)
# Change this if network fees change
fees = 0.02
@app.route('/') @app.route('/')
def index(): def index():
# Check if the user is logged in # Check if the user is logged in
@ -68,8 +72,8 @@ def send_page():
account = account_module.check_account(request.cookies.get("account")) account = account_module.check_account(request.cookies.get("account"))
max = account_module.getBalance(account)['available'] max = account_module.getBalance(account)['available']
# Subtract approx fee of 0.02 # Subtract approx fee
max = max - 0.02 max = max - fees
max = round(max, 2) max = round(max, 2)
message = '' message = ''
@ -117,7 +121,7 @@ def send():
if amount <= 0: if amount <= 0:
return redirect("/send?message=Invalid amount&address=" + address + "&amount=" + str(amount)) 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)) return redirect("/send?message=Not enough funds to transfer&address=" + address + "&amount=" + str(amount))
# Send the transaction # Send the transaction
@ -358,7 +362,6 @@ def auction(domain):
raw=domainInfo,state=state, next=next, raw=domainInfo,state=state, next=next,
next_action=next_action, bids=bids,error=message) next_action=next_action, bids=bids,error=message)
@app.route('/auction/<domain>/scan') @app.route('/auction/<domain>/scan')
def rescan_auction(domain): def rescan_auction(domain):
# Check if the user is logged in # Check if the user is logged in
@ -428,6 +431,20 @@ def bid_confirm(domain):
return redirect("/success?tx=" + response['hash']) return redirect("/success?tx=" + response['hash'])
@app.route('/auction/<domain>/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 #endregion