mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-13 11:09:14 +01:00
common: change default network from testnet to mainnet for new installs.
Changelog-changed: Default network (new installs) is now bitcoin, not testnet. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
a56f2b25b0
commit
36c517bac5
1 changed files with 41 additions and 4 deletions
|
@ -10,6 +10,9 @@
|
||||||
#include <common/utils.h>
|
#include <common/utils.h>
|
||||||
#include <common/version.h>
|
#include <common/version.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
bool deprecated_apis = true;
|
bool deprecated_apis = true;
|
||||||
|
|
||||||
|
@ -241,6 +244,34 @@ void parse_config_files(const char *config_filename,
|
||||||
parse_implied_config_file(config_basedir, chainparams->network_name, early);
|
parse_implied_config_file(config_basedir, chainparams->network_name, early);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Could be a yet-to-be-upgraded dir (definitely testnet), or could be
|
||||||
|
* it's been upgraded to testnet. */
|
||||||
|
static bool smells_like_old_testnet(const char *config_basedir)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
/* Doubles as convenient top-level ctx for this function */
|
||||||
|
const char *base = default_base_configdir(NULL);
|
||||||
|
|
||||||
|
if (!config_basedir)
|
||||||
|
config_basedir = base;
|
||||||
|
|
||||||
|
/* If it doesn't exist, it's not testnet. */
|
||||||
|
if (stat(config_basedir, &st) != 0) {
|
||||||
|
tal_free(base);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Does it have a bitcoin/ subdir and no testnet/ subdir? */
|
||||||
|
if (stat(path_join(base, config_basedir, "bitcoin"), &st) == 0
|
||||||
|
&& stat(path_join(base, config_basedir, "testnet"), &st) != 0) {
|
||||||
|
tal_free(base);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tal_free(base);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void initial_config_opts(const tal_t *ctx,
|
void initial_config_opts(const tal_t *ctx,
|
||||||
int argc, char *argv[],
|
int argc, char *argv[],
|
||||||
char **config_filename,
|
char **config_filename,
|
||||||
|
@ -318,10 +349,16 @@ void initial_config_opts(const tal_t *ctx,
|
||||||
parse_implied_config_file(*config_basedir, NULL, true);
|
parse_implied_config_file(*config_basedir, NULL, true);
|
||||||
opt_early_parse_incomplete(argc, argv, opt_log_stderr_exit);
|
opt_early_parse_incomplete(argc, argv, opt_log_stderr_exit);
|
||||||
|
|
||||||
/* We use a global (in common/utils.h) for the chainparams.
|
/* We use a global (in common/utils.h) for the chainparams. */
|
||||||
* We default to testnet for now. */
|
if (!chainparams) {
|
||||||
if (!chainparams)
|
/* Use bitcoin default on new installations. */
|
||||||
|
if (deprecated_apis && smells_like_old_testnet(*config_basedir)) {
|
||||||
|
warnx("WARNING: default network changing in 2020:"
|
||||||
|
" please set network=testnet in config!");
|
||||||
chainparams = chainparams_for_network("testnet");
|
chainparams = chainparams_for_network("testnet");
|
||||||
|
} else
|
||||||
|
chainparams = chainparams_for_network("bitcoin");
|
||||||
|
}
|
||||||
|
|
||||||
if (!*config_basedir)
|
if (!*config_basedir)
|
||||||
*config_basedir = default_base_configdir(ctx);
|
*config_basedir = default_base_configdir(ctx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue