From da9354cb23ba57ba8abd3e56ebb34ab3b4558764 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Thu, 21 Nov 2024 15:40:02 +1100 Subject: [PATCH] fix: Hide expired domains --- account.py | 19 ++++++++++++++++++- example.env | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/account.py b/account.py index 5b3dde1..7a37793 100644 --- a/account.py +++ b/account.py @@ -15,6 +15,9 @@ ip = os.getenv("hsd_ip") if ip is None: ip = "localhost" +show_expired = os.getenv("show_expired") +if show_expired is None: + show_expired = False hsd = api.hsd(APIKEY,ip) hsw = api.hsw(APIKEY,ip) @@ -179,7 +182,21 @@ def getDomains(account,own=True): else: response = requests.get(f"http://x:{APIKEY}@{ip}:12039/wallet/{account}/name") info = response.json() - return info + + if show_expired: + return info + + # Remove any expired domains + domains = [] + for domain in info: + if 'stats' in domain: + if 'daysUntilExpire' in domain['stats']: + if domain['stats']['daysUntilExpire'] < 0: + continue + domains.append(domain) + + + return domains def getTransactions(account): # Get the transactions diff --git a/example.env b/example.env index 4b8ae7a..96a6a46 100644 --- a/example.env +++ b/example.env @@ -1,3 +1,4 @@ hsd_api=123480615465636893475aCwyaae6s45 hsd_ip=localhost -theme=black \ No newline at end of file +theme=black +show_expired=false \ No newline at end of file