mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pytest: Test the mindepth customizations of fundchannel and hook
Just test that we can customize, and we'll add mindepth=0 support in the next couple of commits.
This commit is contained in:
34
tests/plugins/zeroconf-selective.py
Executable file
34
tests/plugins/zeroconf-selective.py
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/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']:
|
||||
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',
|
||||
'A node_id to allow zeroconf channels from',
|
||||
'03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f'
|
||||
)
|
||||
|
||||
plugin.add_option(
|
||||
'zeroconf-mindepth',
|
||||
0,
|
||||
'Number of confirmations to require from allowlisted peers',
|
||||
)
|
||||
|
||||
plugin.run()
|
||||
Reference in New Issue
Block a user