From 147787319084382e4a7141163d52aa632bc99faa Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 20 May 2022 15:43:56 +0200 Subject: [PATCH] plugin: Allow plugins to customize the mindepth in accept_channel This is the counterpart of the `mindepth` parameter in `fundchannel` and friends. Allows dynamic lookups of `node_id` and selectively opting into `option_zeroconf` being used. Changelog-Added: plugin: The `openchannel` hook may return a `mindepth` indicating how many confirmations are required. --- lightningd/opening_control.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 8754ba647..8449edf9d 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -701,6 +701,7 @@ openchannel_hook_deserialize(struct openchannel_hook_payload *payload, const jsmntok_t *t_result = json_get_member(buffer, toks, "result"); const jsmntok_t *t_errmsg = json_get_member(buffer, toks, "error_message"); const jsmntok_t *t_closeto = json_get_member(buffer, toks, "close_to"); + const jsmntok_t *t_mindepth = json_get_member(buffer, toks, "mindepth"); if (!t_result) fatal("Plugin returned an invalid response to the" @@ -752,6 +753,16 @@ openchannel_hook_deserialize(struct openchannel_hook_payload *payload, break; } } + + if (t_mindepth != NULL) { + json_to_u32(buffer, t_mindepth, &payload->uc->minimum_depth); + log_debug( + openingd->ld->log, + "Setting mindepth=%d for this channel as requested by " + "the openchannel hook", + payload->uc->minimum_depth); + } + return true; }