mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pylightning: Warn users of plugins that may break due to extra args
We recently noticed that the way we unpack the call arguments for hooks and notifications in pylightning breaks pretty quickly once you start changing the hook and notification params. If you add params they will not get mapped correctly causing the plugin to error out. This can be fixed by adding a `VAR_KEYWORD` argument to the calbacks, i.e., by adding a single `**kwargs` argument at the end of the signature. This commit adds a check that such a catch-all argument exists, and emits a warning if it doesn't. It also fixes up the plugins that we ship ourselves. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
e808aaa1bb
commit
9d4148ce68
@@ -13,7 +13,7 @@ plugin = Plugin()
|
||||
|
||||
|
||||
@plugin.hook('peer_connected')
|
||||
def on_connected(peer, plugin):
|
||||
def on_connected(peer, plugin, **kwargs):
|
||||
if peer['id'] in plugin.reject_ids:
|
||||
print("{} is in reject list, disconnecting".format(peer['id']))
|
||||
return {'result': 'disconnect', 'error_message': 'You are in reject list'}
|
||||
|
||||
Reference in New Issue
Block a user