|
10 | 10 | #include <common/features.h> |
11 | 11 | #include <common/hsm_encryption.h> |
12 | 12 | #include <common/json_command.h> |
| 13 | +#include <common/json_helpers.h> |
13 | 14 | #include <common/json_tok.h> |
14 | 15 | #include <common/param.h> |
15 | 16 | #include <common/type_to_string.h> |
@@ -671,6 +672,9 @@ static const struct config testnet_config = { |
671 | 672 | /* Testnet blockspace is free. */ |
672 | 673 | .max_concurrent_htlcs = 483, |
673 | 674 |
|
| 675 | + /* Max amount of dust allowed per channel (50ksat) */ |
| 676 | + .max_dust_htlc_exposure_msat = AMOUNT_MSAT(50000000), |
| 677 | + |
674 | 678 | /* Be aggressive on testnet. */ |
675 | 679 | .cltv_expiry_delta = 6, |
676 | 680 | .cltv_final = 10, |
@@ -717,6 +721,9 @@ static const struct config mainnet_config = { |
717 | 721 | /* While up to 483 htlcs are possible we do 30 by default (as eclair does) to save blockspace */ |
718 | 722 | .max_concurrent_htlcs = 30, |
719 | 723 |
|
| 724 | + /* Max amount of dust allowed per channel (50ksat) */ |
| 725 | + .max_dust_htlc_exposure_msat = AMOUNT_MSAT(50000000), |
| 726 | + |
720 | 727 | /* BOLT #2: |
721 | 728 | * |
722 | 729 | * 1. the `cltv_expiry_delta` for channels, `3R+2G+2S`: if in doubt, a |
@@ -842,6 +849,14 @@ static char *opt_start_daemon(struct lightningd *ld) |
842 | 849 | errx(1, "Died with signal %u", WTERMSIG(exitcode)); |
843 | 850 | } |
844 | 851 |
|
| 852 | +static char *opt_set_msat(const char *arg, struct amount_msat *amt) |
| 853 | +{ |
| 854 | + if (!parse_amount_msat(amt, arg, strlen(arg))) |
| 855 | + return tal_fmt(NULL, "Unable to parse millisatoshi '%s'", arg); |
| 856 | + |
| 857 | + return NULL; |
| 858 | +} |
| 859 | + |
845 | 860 | static char *opt_set_wumbo(struct lightningd *ld) |
846 | 861 | { |
847 | 862 | feature_set_or(ld->our_features, |
@@ -1005,6 +1020,9 @@ static void register_opts(struct lightningd *ld) |
1005 | 1020 | opt_register_arg("--max-concurrent-htlcs", opt_set_u32, opt_show_u32, |
1006 | 1021 | &ld->config.max_concurrent_htlcs, |
1007 | 1022 | "Number of HTLCs one channel can handle concurrently. Should be between 1 and 483"); |
| 1023 | + opt_register_arg("--max-dust-htlc-exposure-msat", opt_set_msat, |
| 1024 | + NULL, &ld->config.max_dust_htlc_exposure_msat, |
| 1025 | + "Max HTLC amount that can be trimmed"); |
1008 | 1026 | opt_register_arg("--min-capacity-sat", opt_set_u64, opt_show_u64, |
1009 | 1027 | &ld->config.min_capacity_sat, |
1010 | 1028 | "Minimum capacity in satoshis for accepting channels"); |
@@ -1496,6 +1514,8 @@ static void add_config(struct lightningd *ld, |
1496 | 1514 | || opt->cb_arg == (void *)plugin_opt_flag_set) { |
1497 | 1515 | /* FIXME: We actually treat it as if they specified |
1498 | 1516 | * --plugin for each one, so ignore these */ |
| 1517 | + } else if (opt->cb_arg == (void *)opt_set_msat) { |
| 1518 | + json_add_amount_msat_only(response, name0, ld->config.max_dust_htlc_exposure_msat); |
1499 | 1519 | #if EXPERIMENTAL_FEATURES |
1500 | 1520 | } else if (opt->cb_arg == (void *)opt_set_accept_extra_tlv_types) { |
1501 | 1521 | /* TODO Actually print the option */ |
|
0 commit comments