diff --git a/bitcoin/chainparams.c b/bitcoin/chainparams.c index c0b58c07b..b817af066 100644 --- a/bitcoin/chainparams.c +++ b/bitcoin/chainparams.c @@ -1,9 +1,9 @@ #include "chainparams.h" +#include +#include #include -#define CHAINPARAMS_NETWORK_COUNT 4 - -const struct chainparams networks[CHAINPARAMS_NETWORK_COUNT] = { +const struct chainparams networks[] = { {.index = 0, .network_name = "bitcoin", .genesis_blockhash = {{.u.u8 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xd6, @@ -55,8 +55,8 @@ const struct chainparams networks[CHAINPARAMS_NETWORK_COUNT] = { const struct chainparams *chainparams_for_network(const char *network_name) { - for (int i = 0; i < CHAINPARAMS_NETWORK_COUNT; i++) { - if (strcmp(network_name, networks[i].network_name) == 0) { + for (size_t i = 0; i < ARRAY_SIZE(networks); i++) { + if (streq(network_name, networks[i].network_name)) { return &networks[i]; } } @@ -65,7 +65,7 @@ const struct chainparams *chainparams_for_network(const char *network_name) const struct chainparams *chainparams_by_index(const int index) { - if (index >= CHAINPARAMS_NETWORK_COUNT || index < 0) { + if (index >= ARRAY_SIZE(networks) || index < 0) { return NULL; } else { return &networks[index]; diff --git a/daemon/options.c b/daemon/options.c index f9a2446e6..99bd8b4c6 100644 --- a/daemon/options.c +++ b/daemon/options.c @@ -163,6 +163,15 @@ static char *opt_set_network(const char *arg, struct lightningd *ld) return NULL; } +/* FIXME: Uncomment once legacy daemon has been removed */ +/* +static void opt_show_network(char buf[OPT_SHOW_LEN], + const struct lightningd *ld) +{ + snprintf(buf, OPT_SHOW_LEN, "%s", ld->chainparams->network_name); +} +*/ + static void config_register_opts(struct lightningd_state *dstate) { opt_register_arg("--locktime-blocks", opt_set_u32, opt_show_u32, @@ -235,9 +244,11 @@ static void config_register_opts(struct lightningd_state *dstate) &dstate->config.ipaddr, "Set the IP address (v4 or v6) to announce to the network for incoming connections"); - opt_register_arg( - "--network", opt_set_network, NULL, ld_from_dstate(dstate), - "Select the network parameters (bitcoin, testnet, regtest, or litecoin, default: testnet)"); + /* FIXME: Register opt_show_network with the option */ + opt_register_arg("--network", opt_set_network, NULL, + ld_from_dstate(dstate), + "Select the network parameters (bitcoin, testnet, " + "regtest, or litecoin)"); } static void dev_register_opts(struct lightningd_state *dstate)