From 21fd3b22d472f89bec60048b8ab5f6fabf610155 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Sat, 26 Mar 2022 14:31:26 +0100 Subject: [PATCH] config: adds htlc_minimum_msat htlc_maximum_msat announce_discovered_ip This adds config and commandline options for htlc_min_msat, htlc_max_msat and announce_discovered_ip. The default is 0msat for htlc_min_msat, unlimited for htlc_max_msat and enabled for announce_discovered_ip. The announce_discovered_ip gets the disable commandline switch --disable-ip-discovery Changelog-added: Config options for htlc_min_msat, htlc_max_msat and announce_discovered_ip. --- lightningd/lightningd.h | 7 +++++++ lightningd/opening_common.c | 2 +- lightningd/opening_control.c | 4 ++-- lightningd/options.c | 23 +++++++++++++++++++++++ lightningd/peer_control.c | 2 +- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lightningd/lightningd.h b/lightningd/lightningd.h index a90f13309..ae74a635f 100644 --- a/lightningd/lightningd.h +++ b/lightningd/lightningd.h @@ -33,6 +33,10 @@ struct config { /* htlcs per channel */ u32 max_concurrent_htlcs; + /* htlc min/max values */ + struct amount_msat htlc_minimum_msat; + struct amount_msat htlc_maximum_msat; + /* Max amount of dust allowed per channel */ struct amount_msat max_dust_htlc_exposure_msat; @@ -52,6 +56,9 @@ struct config { /* Are we allowed to use DNS lookup for peers. */ bool use_dns; + /* Turn off IP address announcement discovered via peer `remote_addr` */ + bool disable_ip_discovery; + /* Minimal amount of effective funding_satoshis for accepting channels */ u64 min_capacity_sat; diff --git a/lightningd/opening_common.c b/lightningd/opening_common.c index 7442cea19..f866a91f5 100644 --- a/lightningd/opening_common.c +++ b/lightningd/opening_common.c @@ -147,7 +147,7 @@ void channel_config(struct lightningd *ld, = ld->config.max_dust_htlc_exposure_msat; /* Don't care */ - ours->htlc_minimum = AMOUNT_MSAT(0); + ours->htlc_minimum = ld->config.htlc_minimum_msat; /* BOLT #2: * diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 87ffc1984..9499a76e3 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -211,8 +211,8 @@ wallet_commit_channel(struct lightningd *ld, take(new_height_states(NULL, uc->fc ? LOCAL : REMOTE, &lease_start_blockheight)), 0, NULL, 0, 0, /* No leases on v1s */ - AMOUNT_MSAT(0), /* No htlc_minimum_msat */ - AMOUNT_MSAT(-1ULL)); /* No htlc_maximum_msat */ + ld->config.htlc_minimum_msat, + ld->config.htlc_maximum_msat); /* Now we finally put it in the database. */ wallet_channel_insert(ld->wallet, channel); diff --git a/lightningd/options.c b/lightningd/options.c index 635feb40e..826b87b64 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -760,6 +760,10 @@ static const struct config testnet_config = { /* Testnet blockspace is free. */ .max_concurrent_htlcs = 483, + /* channel defaults for htlc min/max values */ + .htlc_minimum_msat = AMOUNT_MSAT(0), + .htlc_maximum_msat = AMOUNT_MSAT(-1ULL), /* no limit */ + /* Max amount of dust allowed per channel (50ksat) */ .max_dust_htlc_exposure_msat = AMOUNT_MSAT(50000000), @@ -783,6 +787,9 @@ static const struct config testnet_config = { .use_dns = true, + /* Turn off IP address announcement discovered via peer `remote_addr` */ + .disable_ip_discovery = false, + /* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */ .min_capacity_sat = 10000, @@ -809,6 +816,10 @@ static const struct config mainnet_config = { /* While up to 483 htlcs are possible we do 30 by default (as eclair does) to save blockspace */ .max_concurrent_htlcs = 30, + /* defaults for htlc min/max values */ + .htlc_minimum_msat = AMOUNT_MSAT(0), + .htlc_maximum_msat = AMOUNT_MSAT(-1ULL), /* no limit */ + /* Max amount of dust allowed per channel (50ksat) */ .max_dust_htlc_exposure_msat = AMOUNT_MSAT(50000000), @@ -842,6 +853,9 @@ static const struct config mainnet_config = { .use_dns = true, + /* Turn off IP address announcement discovered via peer `remote_addr` */ + .disable_ip_discovery = false, + /* Sets min_effective_htlc_capacity - at 1000$/BTC this is 10ct */ .min_capacity_sat = 10000, @@ -1105,6 +1119,12 @@ static void register_opts(struct lightningd *ld) opt_register_arg("--fee-per-satoshi", opt_set_u32, opt_show_u32, &ld->config.fee_per_satoshi, "Microsatoshi fee for every satoshi in HTLC"); + opt_register_arg("--htlc-minimum-msat", opt_set_msat, NULL, + &ld->config.htlc_minimum_msat, + "The default minimal value an HTLC must carry in order to be forwardable for new channels"); + opt_register_arg("--htlc-maximum-msat", opt_set_msat, NULL, + &ld->config.htlc_maximum_msat, + "The default maximal value an HTLC must carry in order to be forwardable for new channel"); opt_register_arg("--max-concurrent-htlcs", opt_set_u32, opt_show_u32, &ld->config.max_concurrent_htlcs, "Number of HTLCs one channel can handle concurrently. Should be between 1 and 483"); @@ -1123,6 +1143,9 @@ static void register_opts(struct lightningd *ld) opt_register_arg("--announce-addr", opt_add_announce_addr, NULL, ld, "Set an IP address (v4 or v6) or .onion v3 to announce, but not listen on"); + opt_register_noarg("--disable-ip-discovery", opt_set_bool, + &ld->config.disable_ip_discovery, + "Turn off announcement of discovered public IPs"); opt_register_noarg("--offline", opt_set_offline, ld, "Start in offline-mode (do not automatically reconnect and do not accept incoming connections)"); diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 197ea9e41..8565a73a3 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1076,7 +1076,7 @@ static void update_remote_addr(struct lightningd *ld, const struct node_id peer_id) { /* failsafe to prevent privacy leakage. */ - if (ld->always_use_proxy) + if (ld->always_use_proxy || ld->config.disable_ip_discovery) return; switch (remote_addr->type) {