6#if defined(HAVE_CONFIG_H)
7#include <config/bitcoin-config.h>
92 if (
chdir(
"/") != 0) {
100 int fd = open(
"/dev/null",
O_RDWR);
139 std::any context{&
node};
165 strUsage +=
"\nUsage: bitcoind [options] "
187 strprintf(
"Specified data directory \"%s\" does not exist.\n",
188 args.
GetArg(
"-datadir",
""))));
198 }
catch (
const std::exception &
e) {
213 for (
int i = 1; i <
argc; i++) {
216 strprintf(
"Command line contains unexpected token '%s', "
217 "see bitcoind -h for a list of options.\n",
277 tfm::format(std::cerr,
"Error during initialization - "
278 "check debug.log for details\n");
285 "-daemon is not supported on this operating system\n"));
296 }
catch (
const std::exception &
e) {
320 common::WinCmdLineArgs
winArgs;
bool HelpRequested(const ArgsManager &args)
bool CheckDataDirOption(const ArgsManager &args)
bool IsSwitchChar(char c)
static bool AppInit(int argc, char *argv[])
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate string to current locale using Qt.
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
#define Assert(val)
Identity function.
bool InitSettings(std::string &error)
Read and update settings file with saved settings.
bool ParseParameters(int argc, const char *const argv[], std::string &error)
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
std::string GetHelpMessage() const
Get the help string.
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool SoftSetBoolArg(const std::string &strArg, bool fValue)
Set a boolean argument if it doesn't already have a value.
bool ReadConfigFiles(std::string &error, bool ignore_invalid_keys=false)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
Class for registering and managing all RPC calls.
static std::optional< TokenPipe > Make()
Create a new pipe.
std::string FormatFullVersion()
std::string LicenseInfo()
Returns licensing information (for -version)
const Config & GetConfig()
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
void Interrupt(NodeContext &node)
Interrupt threads.
void InitLogging(const ArgsManager &args)
Initialize global loggers.
bool AppInitLockDataDirectory()
Lock bitcoin data directory.
void SetupServerArgs(NodeContext &node)
Register all arguments with the ArgsManager.
void Shutdown(NodeContext &node)
bool AppInitMain(Config &config, RPCServer &rpcServer, HTTPRPCRequestProcessor &httpRPCRequestProcessor, NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin main initialization.
bool AppInitBasicSetup(const ArgsManager &args)
Initialize bitcoin: Basic context setup.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
bool AppInitParameterInteraction(Config &config, const ArgsManager &args)
Initialization: parameter interaction.
static constexpr bool DEFAULT_DAEMON
Default value for -daemon option.
static constexpr bool DEFAULT_DAEMONWAIT
Default value for -daemonwait option.
bool error(const char *fmt, const Args &...args)
void ThreadSetInternalName(std::string &&)
Set the internal (in-memory) name of the current thread only.
void noui_connect()
Connect all bitcoind signal handlers.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
void WaitForShutdown()
Wait for StartShutdown to be called in any thread.
NodeContext struct containing references to chain state and connection state.
std::string SysErrorString(int err)
Return system error string from errno value.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
bool InitError(const bilingual_str &str)
Show error message.
std::string FormatParagraph(std::string_view in, size_t width, size_t indent)
Format a paragraph of text to a fixed width, adding spaces for indentation to any added line.