Skip to content

Commit

Permalink
config: adds htlc_minimum_msat htlc_maximum_msat announce_discovered_ip
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
m-schmoock authored and rustyrussell committed Apr 4, 2022
1 parent c1e7c14 commit 21fd3b2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
7 changes: 7 additions & 0 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lightningd/opening_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down
4 changes: 2 additions & 2 deletions lightningd/opening_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 23 additions & 0 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand All @@ -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,

Expand All @@ -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),

Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -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");
Expand All @@ -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)");
Expand Down
2 changes: 1 addition & 1 deletion lightningd/peer_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 21fd3b2

Please sign in to comment.