feat: Add estimated expiry

This commit is contained in:
Nathan Woodburn 2025-02-04 16:47:30 +11:00
parent 5445a31a76
commit 27613bc1aa
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -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 += "</tbody></table></div></div>"
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}