feat: Add reveal info

This commit is contained in:
Nathan Woodburn 2023-12-29 13:57:20 +11:00
parent fd2e18d655
commit 448f06ad36
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
3 changed files with 48 additions and 13 deletions

View File

@ -203,18 +203,36 @@ def getDNS(domain: str):
def getNodeSync():
response = hsd.getInfo()
return response['chain']['progress']*100
sync = response['chain']['progress']*100
sync = round(sync, 2)
return sync
def getBids(account, domain):
response = hsw.getWalletBidsByName(domain,account)
return response
def getReveals(account,domain):
return hsw.getWalletRevealsByName(domain,account)
def getRevealTX(reveal):
prevout = reveal['prevout']
hash = prevout['hash']
index = prevout['index']
tx = hsd.getTxByHash(hash)
revealAddress = tx['outputs'][index]['address']
for input in tx['inputs']:
if input['coin']['address'] == revealAddress:
return input['prevout']['hash']
return False
def rescan_auction(account,domain):
# Get height of the start of the auction
response = hsw.rpc_selectWallet(account)
response = hsd.rpc_getNameInfo(domain)
if 'result' not in response:
return {
@ -224,9 +242,8 @@ def rescan_auction(account,domain):
return {
"error": "Not in auction"
}
height = response['result']['info']['stats']['bidPeriodStart']
height = response['result']['info']['height']-1
response = hsw.rpc_importName(domain,height)
return response

10
main.py
View File

@ -324,7 +324,13 @@ def auction(domain):
bids = "No bids found"
next_action = f'<a href="/auction/{domain}/scan">Rescan Auction</a>'
else:
bids = render.bids(bids)
reveals = account_module.getReveals(account,search_term)
for reveal in reveals:
# Get TX
revealInfo = account_module.getRevealTX(reveal)
reveal['bid'] = revealInfo
print(revealInfo)
bids = render.bids(bids,reveals)
if state == 'CLOSED':
@ -515,4 +521,4 @@ def page_not_found(e):
#endregion
if __name__ == '__main__':
app.run(debug=True)
app.run(debug=True,host='0.0.0.0')

View File

@ -1,4 +1,5 @@
import datetime
import json
def domains(domains):
@ -135,22 +136,33 @@ def timestamp_to_readable_time(timestamp):
readable_time = dt_object.strftime("%H:%M:%S %d %b %Y")
return readable_time
def bids(data):
def bids(bids,reveals):
html = ''
for bid in data:
for bid in bids:
lockup = bid['lockup']
lockup = lockup / 1000000
lockup = round(lockup, 2)
html += "<tr>"
html += f"<td>{lockup} HNS</td>"
# TODO If revealed
html += f"<td>Hidden until reveal</td>"
html += f"<td>Hidden until reveal</td>"
revealed = False
for reveal in reveals:
if reveal['bid'] == bid['prevout']['hash']:
revealed = True
value = reveal['value']
value = value / 1000000
value = round(value, 2)
html += f"<td>{value} HNS</td>"
bidValue = lockup - value
bidValue = round(bidValue, 2)
html += f"<td>{bidValue} HNS</td>"
break
if not revealed:
html += f"<td>Hidden until reveal</td>"
html += f"<td>Hidden until reveal</td>"
if bid['own']:
html += "<td>You</td>"
else:
html += "<td>Unknown</td>"
html += "</tr>"
return html