MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_early_opts

Function handle_early_opts

lightningd/options.c:1797–1883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1795}
1796
1797void handle_early_opts(struct lightningd *ld, int argc, char *argv[])
1798{
1799 /* Make ccan/opt use tal for allocations */
1800 setup_option_allocators();
1801
1802 /*~ List features immediately, before doing anything interesting */
1803 clnopt_noarg("--list-features-only", OPT_EARLY|OPT_EXITS,
1804 list_features_and_exit,
1805 ld, "List the features configured, and exit immediately");
1806
1807 /*~ We need to know this super-early, as it controls other options */
1808 clnopt_noarg("--developer", OPT_EARLY|OPT_SHOWBOOL,
1809 opt_set_bool, &ld->developer,
1810 "Enable developer commands/options, disable legacy APIs");
1811
1812 /*~ This does enough parsing to get us the base configuration options */
1813 ld->configvars = initial_config_opts(ld, &argc, argv, true,
1814 &ld->config_filename,
1815 &ld->config_basedir,
1816 &ld->config_netdir,
1817 &ld->rpc_filename,
1818 &ld->setconfig_file);
1819
1820 if (argc != 1)
1821 errx(1, "no arguments accepted");
1822
1823 /* Copy in default config, to be modified by further options */
1824 if (chainparams->testnet)
1825 ld->config = testnet_config;
1826 else
1827 ld->config = mainnet_config;
1828
1829 /* No anchors if we're elements */
1830 if (chainparams->is_elements) {
1831 feature_set_sub(ld->our_features,
1832 feature_set_for_feature(tmpctx,
1833 OPTIONAL_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX)));
1834 }
1835
1836 /* Set the ln_port given from chainparams */
1837 ld->config.ip_discovery_port = chainparams->ln_port;
1838
1839 /* Now we can initialize wallet_dsn */
1840 ld->wallet_dsn = tal_fmt(ld, "sqlite3://%s/lightningd.sqlite3",
1841 ld->config_netdir);
1842
1843 /* Set default PID file name to be per-network (in base dir) */
1844 ld->pidfile = path_join(ld, ld->config_basedir,
1845 tal_fmt(tmpctx, "lightningd-%s.pid",
1846 chainparams->network_name));
1847
1848 /*~ Move into config dir: this eases path manipulation and also
1849 * gives plugins a good place to store their stuff. */
1850 if (chdir(ld->config_netdir) != 0) {
1851 log_info(ld->log, "Creating configuration directory %s",
1852 ld->config_netdir);
1853 /* We assume home dir exists, so only create two. */
1854 if (mkdir(ld->config_basedir, 0700) != 0 && errno != EEXIST)

Callers 1

mainFunction · 0.70

Calls 12

setup_option_allocatorsFunction · 0.85
initial_config_optsFunction · 0.85
errxFunction · 0.85
feature_set_subFunction · 0.85
feature_set_for_featureFunction · 0.85
path_joinFunction · 0.85
log_infoClass · 0.85
promote_missing_filesFunction · 0.85
register_optsFunction · 0.85
parse_configvars_earlyFunction · 0.85
logging_options_parsedFunction · 0.85
fatalFunction · 0.70

Tested by

no test coverage detected