From e506b6bbdd47fd81828e909451073b2aa8533a39 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 29 Jan 2025 14:41:04 +1100 Subject: [PATCH] feat: Add toggle for dashboard widget --- public_info.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/public_info.py b/public_info.py index 54012da..61412f3 100644 --- a/public_info.py +++ b/public_info.py @@ -1,6 +1,7 @@ import json import account import requests +import os # Plugin Data info = { @@ -27,9 +28,17 @@ functions = { } } -def main(params, authentication): - info = account.hsd.getInfo() +if not os.path.exists("user_data/public_info.json"): + with open("user_data/public_info.json", "w") as f: + json.dump({"enabled": False}, f) +def main(params, authentication): + with open("user_data/public_info.json", "r") as f: + multiwallet = json.load(f) + if not multiwallet['enabled']: + return {"status": None} + + info = account.hsd.getInfo() status = f"Version: {info['version']}
Inbound Connections: {info['pool']['inbound']}
Outbound Connections: {info['pool']['outbound']}
" if info['pool']['public']['listen']: status += f"Public Node: Yes
Host: {info['pool']['public']['host']}
Port: {info['pool']['public']['port']}
" @@ -38,4 +47,19 @@ def main(params, authentication): status += f"Agent: {info['pool']['agent']}
Services: {info['pool']['services']}
" return {"status": status} - \ No newline at end of file + +def enable(params, authentication): + with open("user_data/public_info.json", "r") as f: + multiwallet = json.load(f) + multiwallet['enabled'] = True + with open("user_data/public_info.json", "w") as f: + json.dump(multiwallet, f) + return {"result": "Success"} + +def disable(params, authentication): + with open("user_data/public_info.json", "r") as f: + multiwallet = json.load(f) + multiwallet['enabled'] = False + with open("user_data/public_info.json", "w") as f: + json.dump(multiwallet, f) + return {"result": "Success"} \ No newline at end of file