Compare commits

..

7 Commits

3 changed files with 115 additions and 2 deletions

View File

@@ -7,4 +7,7 @@ Go to Plugins > Custom Plugin Manager
Import this URL:
```
https://git.woodburn.au/nathanwoodburn/multi-wallet-plugin.git
```
```
## Screenshots
![Functions](image.png)

BIN
image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@@ -2,6 +2,7 @@ import json
import account
import os
import time
import datetime
# Plugin Data
info = {
@@ -39,6 +40,56 @@ functions = {
}
}
},
"find": {
"name": "Find domain wallet",
"type": "default",
"description": "Find which wallet owns a domain",
"params": {
"domain": {
"name": "List of Domain to find",
"type": "text"
}
},
"returns": {
"result":
{
"name": "Result",
"type": "text"
}
}
},
"expiring": {
"name": "Expiring Domains",
"type": "default",
"description": "List domains that are expiring and their wallet",
"params": {
"days": {
"name": "Days until expiry (default 30)",
"type": "number"
}
},
"returns": {
"result":
{
"name": "Result",
"type": "text"
}
}
},
"export": {
"name": "Export Domains",
"type": "default",
"description": "Export domains to a file",
"params": {
},
"returns": {
"result":
{
"name": "result.csv",
"type": "file"
}
}
},
"dash": {
"name": "Dashboard widget",
"type": "dashboard",
@@ -102,6 +153,49 @@ def balance(params, authentication):
return {"result": balances}
def expiring(params, authentication):
days = params['days']
if days == None or days == '':
days = 30
else:
days = int(days)
wallets = account.listWallets()
expiring = ''
for wallet in wallets:
walletExpiring = []
domains = account.getDomains(wallet)
for domain in domains:
if 'stats' in domain and 'daysUntilExpire' in domain['stats']:
if domain['stats']['daysUntilExpire'] <= days and domain['stats']['daysUntilExpire'] >= 0:
walletExpiring.append({"domain": domain['name'], "wallet": wallet, "days": domain['stats']['daysUntilExpire']})
if len(walletExpiring) > 0:
expiring += f"<div class='row'><div class='col-md-12'><h3>Expiring Domains in {wallet}</h3><table class='table table-striped'><thead><tr><th>Domain</th><th>Days Until Expiration</th></tr></thead><tbody>"
for domain in walletExpiring:
expiring += f"<tr><td>{domain['domain']}</td><td>{domain['days']}</td></tr>"
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,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']:
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,N/A,{domain['value']/1000000},{wallet}"
return {"result": result}
def dash(params, authentication):
with open("user_data/multiwallet.json", "r") as f:
multiwallet = json.load(f)
@@ -143,6 +237,22 @@ def domains(params, authentication):
domains.append(f"Total: {total}")
return {"result": domains}
def find(params, authentication):
wallets = account.listWallets()
domain_owners = {}
for wallet in wallets:
domains = account.getDomains(wallet)
for domain in domains:
if domain['name'] in params['domain'].split(","):
domain_owners[domain['name']] = wallet
if len(domain_owners) > 0:
result = ''
for domain, wallet in domain_owners.items():
result += f"{domain}: {wallet}<br>"
return {"result": result}
else:
return {"result": "Not found"}
def enable(params, authentication):
with open("user_data/multiwallet.json", "r") as f:
multiwallet = json.load(f)
@@ -157,4 +267,4 @@ def disable(params, authentication):
multiwallet['enabled'] = False
with open("user_data/multiwallet.json", "w") as f:
json.dump(multiwallet, f)
return {"result": "Success"}
return {"result": "Success"}