mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 01:43:36 +01:00
fix: Addressing feedback from PR #192
This commit is contained in:
parent
83c8c3fc52
commit
5fdb8a58aa
@ -1,9 +1,9 @@
|
||||
#include "chainparams.h"
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/str/str.h>
|
||||
#include <string.h>
|
||||
|
||||
#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];
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user