From 27613bc1aa1a904e40fd02590549bba6c0b6a756 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 4 Feb 2025 16:47:30 +1100 Subject: [PATCH] feat: Add estimated expiry --- multi-wallet.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/multi-wallet.py b/multi-wallet.py index 3b094fe..7c6fceb 100644 --- a/multi-wallet.py +++ b/multi-wallet.py @@ -2,6 +2,7 @@ import json import account import os import time +import datetime # Plugin Data info = { @@ -157,16 +158,23 @@ def expiring(params, authentication): expiring += "" return {"result": expiring} +def BlocksToDate(blocks): + date = datetime.datetime.now() + datetime.timedelta(minutes=blocks*10) + return date.strftime("%Y-%m-%d %H:%M:%S") + def export(params, authentication): wallets = account.listWallets() - result = "name,expiry,value,wallet" + result = "name,expiry,expiryBlock,value,wallet" + currentBlock = account.getBlockHeight() + for wallet in wallets: domains = account.getDomains(wallet) for domain in domains: if 'stats' in domain and 'renewalPeriodEnd' in domain['stats']: - result += f"\n{domain['name']},{domain['stats']['renewalPeriodEnd']},{domain['value']/1000000},{wallet}" + expiryBlock = domain['stats']['renewalPeriodEnd'] + result += f"\n{domain['name']}{BlocksToDate(expiryBlock - currentBlock)},{expiryBlock},{domain['value']/1000000},{wallet}" else: - result += f"\n{domain['name']},N/A,{domain['value']/1000000},{wallet}" + result += f"\n{domain['name']},N/A,N/A,{domain['value']/1000000},{wallet}" return {"result": result}