Bitcoin Core  27.99.0
P2P Digital Currency
init.h
Go to the documentation of this file.
1 // Copyright (c) 2023 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_COMMON_INIT_H
6 #define BITCOIN_COMMON_INIT_H
7 
8 #include <util/translation.h>
9 
10 #include <functional>
11 #include <optional>
12 #include <string>
13 #include <vector>
14 
15 class ArgsManager;
16 
17 namespace common {
18 enum class ConfigStatus {
19  FAILED,
20  FAILED_WRITE,
21  ABORTED,
22 };
23 
24 struct ConfigError {
27  std::vector<std::string> details{};
28 };
29 
33 using SettingsAbortFn = std::function<bool(const bilingual_str& message, const std::vector<std::string>& details)>;
34 
35 /* Read config files, and create datadir and settings.json if they don't exist. */
36 std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn settings_abort_fn = nullptr);
37 } // namespace common
38 
39 #endif // BITCOIN_COMMON_INIT_H
ArgsManager & args
Definition: bitcoind.cpp:268
Definition: args.cpp:833
ConfigStatus
Definition: init.h:18
@ ABORTED
Aborted by user.
@ FAILED_WRITE
Failed to write settings.json.
@ FAILED
Failed generically.
std::function< bool(const bilingual_str &message, const std::vector< std::string > &details)> SettingsAbortFn
Callback function to let the user decide whether to abort loading if settings.json file exists and ca...
Definition: init.h:33
std::optional< ConfigError > InitConfig(ArgsManager &args, SettingsAbortFn settings_abort_fn)
Definition: init.cpp:18
Bilingual messages:
Definition: translation.h:18
bilingual_str message
Definition: init.h:26
std::vector< std::string > details
Definition: init.h:27
ConfigStatus status
Definition: init.h:25