diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 47c28cf28..7f1d50993 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -373,6 +373,9 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS) tal_del_destructor2(dualopend, openchannel2_remove_dualopend, payload); if (payload->err_msg) { + log_debug(dualopend->ld->log, + "openchannel2_hook rejects and says '%s'", + payload->err_msg); msg = towire_dualopend_fail(NULL, payload->err_msg); return subd_send_msg(dualopend, take(msg)); } diff --git a/tests/plugins/openchannel_hook_accept.py b/tests/plugins/openchannel_hook_accept.py index afc922dc7..0022179eb 100755 --- a/tests/plugins/openchannel_hook_accept.py +++ b/tests/plugins/openchannel_hook_accept.py @@ -5,10 +5,14 @@ Will simply accept any channel. Useful fot testing chained hook. """ from pyln.client import Plugin +from pyln.testing.utils import env plugin = Plugin() +EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1" + + @plugin.hook('openchannel') def on_openchannel(openchannel, plugin, **kwargs): msg = "accept on principle" @@ -16,4 +20,12 @@ def on_openchannel(openchannel, plugin, **kwargs): return {'result': 'continue'} +if EXPERIMENTAL_FEATURES: + @plugin.hook('openchannel2') + def on_openchannel2(openchannel2, plugin, **kwargs): + msg = "accept on principle" + plugin.log(msg) + return {'result': 'continue'} + + plugin.run() diff --git a/tests/plugins/openchannel_hook_reject.py b/tests/plugins/openchannel_hook_reject.py index c89655dde..93fe15e40 100755 --- a/tests/plugins/openchannel_hook_reject.py +++ b/tests/plugins/openchannel_hook_reject.py @@ -6,6 +6,10 @@ Useful fot testing chained hook. """ from pyln.client import Plugin +from pyln.testing.utils import env + +EXPERIMENTAL_FEATURES = env("EXPERIMENTAL_FEATURES", "0") == "1" + plugin = Plugin() @@ -17,4 +21,12 @@ def on_openchannel(openchannel, plugin, **kwargs): return {'result': 'reject', 'error_message': msg} +if EXPERIMENTAL_FEATURES: + @plugin.hook('openchannel2') + def on_openchannel2(openchannel2, plugin, **kwargs): + msg = "reject on principle" + plugin.log(msg) + return {'result': 'reject', 'error_message': msg} + + plugin.run() diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 1b3109eee..7af79f40e 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -646,7 +646,7 @@ def test_openchannel_hook_chaining(node_factory, bitcoind): l1, l2 = node_factory.line_graph(2, fundchannel=False, opts=opts) l1.fundwallet(10**6) - hook_msg = "openchannel_hook rejects and says '" + hook_msg = "openchannel2?_hook rejects and says '" # 100005sat fundchannel should fail fatal() for l2 # because hook_accepter.py rejects on that amount 'for a reason' with pytest.raises(RpcError, match=r'They sent error channel'):