1
0

plugin ConfigVars: define vars less dynamically

and restore ability to have different internal ConfigVar name and user-visible "key"
(Keys are hard to change as that breaks compat, but it is nice to be able to change
the internal var name, to reorganise stuff sometimes. After new ConfigVars are added,
sometimes we get better insight into how the older ones should have been named.)

follow-up https://github.com/spesmilo/electrum/pull/9648
This commit is contained in:
SomberNight
2025-03-19 14:52:13 +00:00
parent 0266832650
commit b132e357a3
4 changed files with 16 additions and 23 deletions

View File

@@ -290,11 +290,7 @@ class Plugins(DaemonThread):
else:
zipfile = zipimport.zipimporter(metadata['path'])
init_spec = zipfile.find_spec(name)
module = self.exec_module_from_spec(init_spec, base_name)
# import config vars
if hasattr(module, 'config_vars'):
for cv in module.config_vars:
setattr(SimpleConfig, cv.key().upper(), cv)
self.exec_module_from_spec(init_spec, base_name)
if name == "trustedcoin":
# removes trustedcoin after loading to not show it in the list of plugins
del self.internal_plugin_metadata[name]

View File

@@ -1,6 +1,5 @@
from electrum.simple_config import ConfigVar
config_vars = [
ConfigVar('payserver_port', default=8080, type_=int),
ConfigVar('payserver_root', default='/r', type_=str),
ConfigVar('payserver_allow_create_invoice', default=False, type_=bool),
]
from electrum.simple_config import ConfigVar, SimpleConfig
SimpleConfig.PAYSERVER_PORT = ConfigVar('payserver_port', default=8080, type_=int)
SimpleConfig.PAYSERVER_ROOT = ConfigVar('payserver_root', default='/r', type_=str)
SimpleConfig.PAYSERVER_ALLOW_CREATE_INVOICE = ConfigVar('payserver_allow_create_invoice', default=False, type_=bool)

View File

@@ -1,6 +1,5 @@
from electrum.simple_config import ConfigVar
config_vars = [
ConfigVar('swapserver_port', default=None, type_=int),
ConfigVar('swapserver_fee_millionths', default=5000, type_=int),
ConfigVar('swapserver_ann_pow_nonce', default=0, type_=int),
]
from electrum.simple_config import ConfigVar, SimpleConfig
SimpleConfig.SWAPSERVER_PORT = ConfigVar('swapserver_port', default=None, type_=int)
SimpleConfig.SWAPSERVER_FEE_MILLIONTHS = ConfigVar('swapserver_fee_millionths', default=5000, type_=int)
SimpleConfig.SWAPSERVER_ANN_POW_NONCE = ConfigVar('swapserver_ann_pow_nonce', default=0, type_=int)

View File

@@ -1,6 +1,5 @@
from electrum.simple_config import ConfigVar
config_vars = [
ConfigVar('watchtower_server_port', default=None, type_=int),
ConfigVar('watchtower_server_user', default=None, type_=str),
ConfigVar('watchtower_server_password', default=None, type_=str),
]
from electrum.simple_config import ConfigVar, SimpleConfig
SimpleConfig.WATCHTOWER_SERVER_PORT = ConfigVar('watchtower_server_port', default=None, type_=int)
SimpleConfig.WATCHTOWER_SERVER_USER = ConfigVar('watchtower_server_user', default=None, type_=str)
SimpleConfig.WATCHTOWER_SERVER_PASSWORD = ConfigVar('watchtower_server_password', default=None, type_=str)