feat: Add reveal
This commit is contained in:
parent
448f06ad36
commit
fa75ea3570
23
account.py
23
account.py
@ -221,14 +221,25 @@ def getRevealTX(reveal):
|
|||||||
hash = prevout['hash']
|
hash = prevout['hash']
|
||||||
index = prevout['index']
|
index = prevout['index']
|
||||||
tx = hsd.getTxByHash(hash)
|
tx = hsd.getTxByHash(hash)
|
||||||
revealAddress = tx['outputs'][index]['address']
|
return tx['inputs'][index]['prevout']['hash']
|
||||||
|
|
||||||
for input in tx['inputs']:
|
|
||||||
if input['coin']['address'] == revealAddress:
|
|
||||||
return input['prevout']['hash']
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
|
def revealAuction(account,domain):
|
||||||
|
account_name = check_account(account)
|
||||||
|
password = ":".join(account.split(":")[1:])
|
||||||
|
|
||||||
|
if account_name == False:
|
||||||
|
return {
|
||||||
|
"error": "Invalid account"
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
response = hsw.sendREVEAL(account_name,password,domain)
|
||||||
|
return response
|
||||||
|
except Exception as e:
|
||||||
|
return {
|
||||||
|
"error": str(e)
|
||||||
|
}
|
||||||
|
|
||||||
def rescan_auction(account,domain):
|
def rescan_auction(account,domain):
|
||||||
# Get height of the start of the auction
|
# Get height of the start of the auction
|
||||||
|
33
main.py
33
main.py
@ -351,8 +351,6 @@ def auction(domain):
|
|||||||
elif state == 'OPENING':
|
elif state == 'OPENING':
|
||||||
next = "Bidding opens in ~" + str(domainInfo['info']['stats']['blocksUntilBidding']) + " blocks"
|
next = "Bidding opens in ~" + str(domainInfo['info']['stats']['blocksUntilBidding']) + " blocks"
|
||||||
elif state == 'BIDDING':
|
elif state == 'BIDDING':
|
||||||
#! Check if the user has scanned the auction
|
|
||||||
|
|
||||||
next = "Reveal in ~" + str(domainInfo['info']['stats']['blocksUntilReveal']) + " blocks"
|
next = "Reveal in ~" + str(domainInfo['info']['stats']['blocksUntilReveal']) + " blocks"
|
||||||
elif state == 'REVEAL':
|
elif state == 'REVEAL':
|
||||||
next = "Reveal ends in ~" + str(domainInfo['info']['stats']['blocksUntilClose']) + " blocks"
|
next = "Reveal ends in ~" + str(domainInfo['info']['stats']['blocksUntilClose']) + " blocks"
|
||||||
@ -395,9 +393,20 @@ def bid(domain):
|
|||||||
return redirect("/logout")
|
return redirect("/logout")
|
||||||
|
|
||||||
domain = domain.lower()
|
domain = domain.lower()
|
||||||
|
bid = request.args.get("bid")
|
||||||
|
blind = request.args.get("blind")
|
||||||
|
|
||||||
|
if bid is "":
|
||||||
|
bid = 0
|
||||||
|
if blind is "":
|
||||||
|
blind = 0
|
||||||
|
|
||||||
|
if bid+blind == 0:
|
||||||
|
return redirect("/auction/" + domain+ "?message=Invalid bid amount")
|
||||||
|
|
||||||
|
|
||||||
# Show confirm page
|
# Show confirm page
|
||||||
total = float(request.args.get('bid')) + float(request.args.get('blind'))
|
total = float(bid) + float(blind)
|
||||||
|
|
||||||
action = f"Bid on {domain}/"
|
action = f"Bid on {domain}/"
|
||||||
content = f"Are you sure you want to bid on {domain}/?"
|
content = f"Are you sure you want to bid on {domain}/?"
|
||||||
@ -433,7 +442,7 @@ def bid_confirm(domain):
|
|||||||
float(request.args.get('blind')))
|
float(request.args.get('blind')))
|
||||||
print(response)
|
print(response)
|
||||||
if 'error' in response:
|
if 'error' in response:
|
||||||
return redirect("/auction/" + domain + "?message=" + response['error'])
|
return redirect("/auction/" + domain + "?message=" + response['error']['message'])
|
||||||
|
|
||||||
return redirect("/success?tx=" + response['hash'])
|
return redirect("/success?tx=" + response['hash'])
|
||||||
|
|
||||||
@ -451,6 +460,22 @@ def open_auction(domain):
|
|||||||
response = account_module.openAuction(request.cookies.get("account"),domain)
|
response = account_module.openAuction(request.cookies.get("account"),domain)
|
||||||
return redirect("/success?tx=" + response['hash'])
|
return redirect("/success?tx=" + response['hash'])
|
||||||
|
|
||||||
|
@app.route('/auction/<domain>/reveal')
|
||||||
|
def reveal_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.revealAuction(request.cookies.get("account"),domain)
|
||||||
|
if 'error' in response:
|
||||||
|
return redirect("/auction/" + domain + "?message=" + response['error']['message'])
|
||||||
|
return redirect("/success?tx=" + response['hash'])
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user