Files
palladum-lightning/tests/plugins/zeroconf-selective.py
Rusty Russell 7893c878b1 pytest: use _ not - in plugin options to zeroconf-selective.py.
This allows us to specify:

	l2.rpc.plugin_start(plugin_path, zeroconf_allow=l1.info['id'])

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-13 14:20:28 +09:30

35 lines
945 B
Python
Executable File

#!/usr/bin/env python3
"""Use the openchannel hook to selectively opt-into zeroconf
"""
from pyln.client import Plugin
plugin = Plugin()
@plugin.hook('openchannel')
def on_openchannel(openchannel, plugin, **kwargs):
plugin.log(repr(openchannel))
mindepth = int(plugin.options['zeroconf_mindepth']['value'])
if openchannel['id'] == plugin.options['zeroconf_allow']['value'] or plugin.options['zeroconf_allow']['value'] == 'any':
plugin.log(f"This peer is in the zeroconf allowlist, setting mindepth={mindepth}")
return {'result': 'continue', 'mindepth': mindepth}
else:
return {'result': 'continue'}
plugin.add_option(
'zeroconf_allow',
'03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f',
'A node_id to allow zeroconf channels from',
)
plugin.add_option(
'zeroconf_mindepth',
0,
'Number of confirmations to require from allowlisted peers',
)
plugin.run()