diff --git a/account.py b/account.py index ee418b5..f691e13 100644 --- a/account.py +++ b/account.py @@ -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 diff --git a/main.py b/main.py index 27680d7..b84a2d2 100644 --- a/main.py +++ b/main.py @@ -324,7 +324,13 @@ def auction(domain): bids = "No bids found" next_action = f'Rescan Auction' 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) \ No newline at end of file + app.run(debug=True,host='0.0.0.0') \ No newline at end of file diff --git a/render.py b/render.py index 2ca71c0..645bb66 100644 --- a/render.py +++ b/render.py @@ -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 += "" html += f"{lockup} HNS" - # TODO If revealed - html += f"Hidden until reveal" - html += f"Hidden until reveal" + 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"{value} HNS" + bidValue = lockup - value + bidValue = round(bidValue, 2) + html += f"{bidValue} HNS" + break + if not revealed: + html += f"Hidden until reveal" + html += f"Hidden until reveal" if bid['own']: html += "You" else: html += "Unknown" - html += "" return html \ No newline at end of file