2020-08-21 12:38:51 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Plugin to test openchannel_hook
|
|
|
|
|
|
|
|
Will simply accept any channel. Useful fot testing chained hook.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from pyln.client import Plugin
|
2020-12-15 00:33:31 +01:00
|
|
|
from pyln.testing.utils import env
|
2020-08-21 12:38:51 +02:00
|
|
|
|
|
|
|
plugin = Plugin()
|
|
|
|
|
|
|
|
|
2020-12-15 00:33:31 +01:00
|
|
|
EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1"
|
|
|
|
|
|
|
|
|
2020-08-21 12:38:51 +02:00
|
|
|
@plugin.hook('openchannel')
|
|
|
|
def on_openchannel(openchannel, plugin, **kwargs):
|
|
|
|
msg = "accept on principle"
|
|
|
|
plugin.log(msg)
|
|
|
|
return {'result': 'continue'}
|
|
|
|
|
|
|
|
|
2020-12-15 00:33:31 +01:00
|
|
|
if EXPERIMENTAL_FEATURES:
|
|
|
|
@plugin.hook('openchannel2')
|
|
|
|
def on_openchannel2(openchannel2, plugin, **kwargs):
|
|
|
|
msg = "accept on principle"
|
|
|
|
plugin.log(msg)
|
|
|
|
return {'result': 'continue'}
|
|
|
|
|
|
|
|
|
2020-08-21 12:38:51 +02:00
|
|
|
plugin.run()
|