From e95143af9aa0d0c3e0dbb39d1726770e99f417b3 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj Date: Sun, 6 May 2018 23:01:49 +0000 Subject: [PATCH] options: Add --dev-max-funding-unconfirmed-blocks. Maximum number of blocks where funding tx is unconfirmed, after which if we are the fundee, we forget the channel. --- lightningd/channel_control.c | 9 ++------- lightningd/lightningd.c | 2 ++ lightningd/lightningd.h | 4 ++++ lightningd/options.c | 9 +++++++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lightningd/channel_control.c b/lightningd/channel_control.c index 7c5a79efe..1fe6347eb 100644 --- a/lightningd/channel_control.c +++ b/lightningd/channel_control.c @@ -341,12 +341,7 @@ is_fundee_should_forget(struct lightningd *ld, struct channel *channel, u32 block_height) { - u32 max_no_funding_tx = 2016; - - /* FIXME: we should be getting max_no_funding_tx - * from an lightningd option, which is why we get - * it as an argument. */ - (void) ld; + u32 max_funding_unconfirmed = ld->max_funding_unconfirmed; /* BOLT #2: * @@ -369,7 +364,7 @@ is_fundee_should_forget(struct lightningd *ld, return false; /* Timeout in blocks not yet reached. */ - if (block_height - channel->first_blocknum < max_no_funding_tx) + if (block_height - channel->first_blocknum < max_funding_unconfirmed) return false; /* Ah forget it! */ diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index bef71131e..1c9af6556 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -87,6 +87,8 @@ static struct lightningd *new_lightningd(const tal_t *ctx) ld->use_proxy_always = false; ld->pure_tor_setup = false; ld->tor_service_password = NULL; + ld->max_funding_unconfirmed = 2016; + return ld; } diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index 812cb6945..4db2e5c29 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -160,6 +160,10 @@ struct lightningd { u64 ini_autocleaninvoice_cycle; u64 ini_autocleaninvoice_expiredby; + /* Number of blocks we wait for a channel to get funded + * if we are the fundee. */ + u32 max_funding_unconfirmed; + #if DEVELOPER /* If we want to debug a subdaemon. */ const char *dev_debug_subdaemon; diff --git a/lightningd/options.c b/lightningd/options.c index 524fc2153..bff71ac2a 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -406,6 +406,15 @@ static void config_register_opts(struct lightningd *ld) opt_register_early_arg("--always-use-proxy", opt_set_bool_arg, opt_show_bool, &ld->use_proxy_always, "Use the proxy always"); + +#if DEVELOPER + opt_register_arg("--dev-max-funding-unconfirmed-blocks", + opt_set_u32, opt_show_u32, + &ld->max_funding_unconfirmed, + "Maximum number of blocks we wait for a channel " + "funding transaction to confirm, if we are the " + "fundee."); +#endif } #if DEVELOPER