@@ -220,7 +220,8 @@ def __init__(self, stdout: Optional[io.TextIOBase] = None,
220
220
invoice_features : Optional [Union [int , str , bytes ]] = None ,
221
221
custom_msgs : Optional [List [int ]] = None ):
222
222
self .methods = {
223
- 'init' : Method ('init' , self ._init , MethodType .RPCMETHOD )
223
+ 'init' : Method ('init' , self ._init , MethodType .RPCMETHOD ),
224
+ 'setconfig' : Method ('setconfig' , self ._set_config , MethodType .RPCMETHOD )
224
225
}
225
226
226
227
self .options : Dict [str , Dict [str , Any ]] = {}
@@ -389,7 +390,8 @@ def decorator(f: Callable[..., None]) -> Callable[..., None]:
389
390
def add_option (self , name : str , default : Optional [str ],
390
391
description : Optional [str ],
391
392
opt_type : str = "string" , deprecated : bool = False ,
392
- multi : bool = False ) -> None :
393
+ multi : bool = False ,
394
+ dynamic = False ) -> None :
393
395
"""Add an option that we'd like to register with lightningd.
394
396
395
397
Needs to be called before `Plugin.run`, otherwise we might not
@@ -414,18 +416,19 @@ def add_option(self, name: str, default: Optional[str],
414
416
'value' : None ,
415
417
'multi' : multi ,
416
418
'deprecated' : deprecated ,
419
+ "dynamic" : dynamic
417
420
}
418
421
419
422
def add_flag_option (self , name : str , description : str ,
420
- deprecated : bool = False ) -> None :
423
+ deprecated : bool = False , dynamic : bool = False ) -> None :
421
424
"""Add a flag option that we'd like to register with lightningd.
422
425
423
426
Needs to be called before `Plugin.run`, otherwise we might not
424
427
end up getting it set.
425
428
426
429
"""
427
430
self .add_option (name , None , description , opt_type = "flag" ,
428
- deprecated = deprecated )
431
+ deprecated = deprecated , dynamic = dynamic )
429
432
430
433
def add_notification_topic (self , topic : str ):
431
434
"""Announce that the plugin will emit notifications for the topic.
@@ -784,7 +787,7 @@ def print_usage(self):
784
787
""" )
785
788
786
789
for method in self .methods .values ():
787
- if method .name in ['init' , 'getmanifest' ]:
790
+ if method .name in ['init' , 'getmanifest' , 'setconfig' ]:
788
791
# Skip internal methods provided by all plugins
789
792
continue
790
793
@@ -864,7 +867,7 @@ def _getmanifest(self, **kwargs) -> JSONType:
864
867
hooks = []
865
868
for method in self .methods .values ():
866
869
# Skip the builtin ones, they don't get reported
867
- if method .name in ['getmanifest' , 'init' ]:
870
+ if method .name in ['getmanifest' , 'init' , 'setconfig' ]:
868
871
continue
869
872
870
873
if method .mtype == MethodType .HOOK :
@@ -970,6 +973,12 @@ def verify_bool(d: Dict[str, JSONType], key: str) -> bool:
970
973
return self ._exec_func (self .child_init , request )
971
974
return None
972
975
976
+ def _set_config (self , ** _ ) -> None :
977
+ """Called when the value of a dynamic option is changed
978
+ For now we don't do anything.
979
+ """
980
+ pass
981
+
973
982
974
983
class PluginStream (object ):
975
984
"""Sink that turns everything that is written to it into a notification.
0 commit comments