Browse Source

feat: add min_capacity_sat config value and switch

- add config value min_capacity_sat that will replaces the magic value
  min_effective_htlc_capacity = AMOUNT_MSAT(1000000)
- add config switch min_capacity_sat
pr-2587
Michael Schmoock 6 years ago
committed by Christian Decker
parent
commit
c7af0c93c9
  1. 3
      lightningd/lightningd.h
  2. 6
      lightningd/opening_control.c
  3. 9
      lightningd/options.c
  4. 1
      wallet/test/test_utils.c

3
lightningd/lightningd.h

@ -67,6 +67,9 @@ struct config {
/* Are we allowed to use DNS lookup for peers. */ /* Are we allowed to use DNS lookup for peers. */
bool use_dns; bool use_dns;
/* Minimal amount of effective funding_satoshis for accepting channels */
u64 min_capacity_sat;
}; };
struct lightningd { struct lightningd {

6
lightningd/opening_control.c

@ -662,8 +662,10 @@ static void channel_config(struct lightningd *ld,
{ {
/* FIXME: depend on feerate. */ /* FIXME: depend on feerate. */
*max_to_self_delay = ld->config.locktime_max; *max_to_self_delay = ld->config.locktime_max;
/* This is 1c at $1000/BTC */
*min_effective_htlc_capacity = AMOUNT_MSAT(1000000); /* Take minimal effective capacity from config min_capacity_sat */
amount_msat_from_sat_u64(min_effective_htlc_capacity,
ld->config.min_capacity_sat);
/* BOLT #2: /* BOLT #2:
* *

9
lightningd/options.c

@ -376,6 +376,9 @@ static void config_register_opts(struct lightningd *ld)
opt_register_arg("--fee-per-satoshi", opt_set_u32, opt_show_u32, opt_register_arg("--fee-per-satoshi", opt_set_u32, opt_show_u32,
&ld->config.fee_per_satoshi, &ld->config.fee_per_satoshi,
"Microsatoshi fee for every satoshi in HTLC"); "Microsatoshi fee for every satoshi in HTLC");
opt_register_arg("--min-capacity-sat", opt_set_u64, opt_show_u64,
&ld->config.min_capacity_sat,
"Minimum capacity in satoshis for accepting channels");
opt_register_arg("--addr", opt_add_addr, NULL, opt_register_arg("--addr", opt_add_addr, NULL,
ld, ld,
"Set an IP address (v4 or v6) to listen on and announce to the network for incoming connections"); "Set an IP address (v4 or v6) to listen on and announce to the network for incoming connections");
@ -544,6 +547,9 @@ static const struct config testnet_config = {
.max_fee_multiplier = 10, .max_fee_multiplier = 10,
.use_dns = true, .use_dns = true,
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 1ct */
.min_capacity_sat = 1000,
}; };
/* aka. "Dude, where's my coins?" */ /* aka. "Dude, where's my coins?" */
@ -607,6 +613,9 @@ static const struct config mainnet_config = {
.max_fee_multiplier = 10, .max_fee_multiplier = 10,
.use_dns = true, .use_dns = true,
/* Sets min_effective_htlc_capacity - at 1000$/BTC this is 1ct */
.min_capacity_sat = 1000,
}; };
static void check_config(struct lightningd *ld) static void check_config(struct lightningd *ld)

1
wallet/test/test_utils.c

@ -22,4 +22,5 @@ const struct config test_config = {
.rescan = 30, .rescan = 30,
.max_fee_multiplier = 10, .max_fee_multiplier = 10,
.use_dns = true, .use_dns = true,
.min_capacity_sat = 1000,
}; };

Loading…
Cancel
Save