Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Typedefs | Enumerations | Functions
common Namespace Reference

Classes

struct  ConfigError
 
struct  Settings
 Stored settings. More...
 
struct  SettingsSpan
 Accessor for list of settings that skips negated values when iterated over. More...
 

Typedefs

using SettingsAbortFn = std::function< bool(const bilingual_str &message, const std::vector< std::string > &details)>
 Callback function to let the user decide whether to abort loading if settings.json file exists and can't be parsed, or to ignore the error and overwrite the file. More...
 
using SettingsValue = UniValue
 Settings value type (string/integer/boolean/null variant). More...
 

Enumerations

enum class  ConfigStatus { FAILED , FAILED_WRITE , ABORTED }
 
enum class  PSBTError {
  MISSING_INPUTS , SIGHASH_MISMATCH , EXTERNAL_SIGNER_NOT_FOUND , EXTERNAL_SIGNER_FAILED ,
  UNSUPPORTED
}
 

Functions

std::optional< ConfigErrorInitConfig (ArgsManager &args, SettingsAbortFn settings_abort_fn)
 
std::string StringForFeeReason (FeeReason reason)
 
const std::vector< std::pair< std::string, FeeEstimateMode > > & FeeModeMap ()
 
std::string FeeModes (const std::string &delimiter)
 
std::string InvalidEstimateModeErrorMessage ()
 
bool FeeModeFromString (const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
 
bilingual_str PSBTErrorString (PSBTError err)
 
bilingual_str TransactionErrorString (const TransactionError err)
 
bilingual_str ResolveErrMsg (const std::string &optname, const std::string &strBind)
 
bilingual_str InvalidPortErrMsg (const std::string &optname, const std::string &invalid_value)
 
bilingual_str AmountHighWarn (const std::string &optname)
 
bilingual_str AmountErrMsg (const std::string &optname, const std::string &strValue)
 
bilingual_str TransactionErrorString (const node::TransactionError error)
 
bool ReadSettings (const fs::path &path, std::map< std::string, SettingsValue > &values, std::vector< std::string > &errors)
 Read settings file. More...
 
bool WriteSettings (const fs::path &path, const std::map< std::string, SettingsValue > &values, std::vector< std::string > &errors)
 Write settings file. More...
 
SettingsValue GetSetting (const Settings &settings, const std::string &section, const std::string &name, bool ignore_default_section_config, bool ignore_nonpersistent, bool get_chain_type)
 Get settings value from combined sources: forced settings, command line arguments, runtime read-write settings, and the read-only config file. More...
 
std::vector< SettingsValueGetSettingsList (const Settings &settings, const std::string &section, const std::string &name, bool ignore_default_section_config)
 Get combined setting value similar to GetSetting(), except if setting was specified multiple times, return a list of all the values specified. More...
 
bool OnlyHasDefaultSectionSetting (const Settings &settings, const std::string &section, const std::string &name)
 Return true if a setting is set in the default config file section, and not overridden by a higher priority command-line or network section value. More...
 
template<typename Map , typename Key >
auto FindKey (Map &&map, Key &&key) -> decltype(&map.at(key))
 Map lookup helper. More...
 

Typedef Documentation

◆ SettingsAbortFn

using common::SettingsAbortFn = typedef std::function<bool(const bilingual_str& message, const std::vector<std::string>& details)>

Callback function to let the user decide whether to abort loading if settings.json file exists and can't be parsed, or to ignore the error and overwrite the file.

Definition at line 33 of file init.h.

◆ SettingsValue

Settings value type (string/integer/boolean/null variant).

Note
UniValue is used here for convenience and because it can be easily serialized in a readable format. But any other variant type that can be assigned strings, int64_t, and bool values and has get_str(), getInt<int64_t>(), get_bool(), isNum(), isBool(), isFalse(), isTrue() and isNull() methods can be substituted if there's a need to move away from UniValue. (An implementation with boost::variant was posted at https://github.com/bitcoin/bitcoin/pull/15934/files#r337691812)

Definition at line 28 of file settings.h.

Enumeration Type Documentation

◆ ConfigStatus

enum common::ConfigStatus
strong
Enumerator
FAILED 

Failed generically.

FAILED_WRITE 

Failed to write settings.json.

ABORTED 

Aborted by user.

Definition at line 18 of file init.h.

◆ PSBTError

enum common::PSBTError
strong
Enumerator
MISSING_INPUTS 
SIGHASH_MISMATCH 
EXTERNAL_SIGNER_NOT_FOUND 
EXTERNAL_SIGNER_FAILED 
UNSUPPORTED 

Definition at line 17 of file types.h.

Function Documentation

◆ AmountErrMsg()

bilingual_str common::AmountErrMsg ( const std::string &  optname,
const std::string &  strValue 
)

Definition at line 135 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AmountHighWarn()

bilingual_str common::AmountHighWarn ( const std::string &  optname)

Definition at line 130 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FeeModeFromString()

bool common::FeeModeFromString ( const std::string &  mode_string,
FeeEstimateMode fee_estimate_mode 
)

Definition at line 66 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FeeModeMap()

const std::vector<std::pair<std::string, FeeEstimateMode> >& common::FeeModeMap ( )

Definition at line 46 of file messages.cpp.

Here is the caller graph for this function:

◆ FeeModes()

std::string common::FeeModes ( const std::string &  delimiter)

Definition at line 56 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindKey()

template<typename Map , typename Key >
auto common::FindKey ( Map &&  map,
Key &&  key 
) -> decltype(&map.at(key))

Map lookup helper.

Definition at line 107 of file settings.h.

Here is the caller graph for this function:

◆ GetSetting()

SettingsValue common::GetSetting ( const Settings settings,
const std::string &  section,
const std::string &  name,
bool  ignore_default_section_config,
bool  ignore_nonpersistent,
bool  get_chain_type 
)

Get settings value from combined sources: forced settings, command line arguments, runtime read-write settings, and the read-only config file.

Parameters
ignore_default_section_config- ignore values in the default section of the config file (part before any [section] keywords)
ignore_nonpersistent- ignore non-persistent settings values (forced settings values and values specified on the command line). Only return settings in the read-only config and read-write settings files.
get_chain_type- enable special backwards compatible behavior for GetChainType

Definition at line 146 of file settings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSettingsList()

std::vector< SettingsValue > common::GetSettingsList ( const Settings settings,
const std::string &  section,
const std::string &  name,
bool  ignore_default_section_config 
)

Get combined setting value similar to GetSetting(), except if setting was specified multiple times, return a list of all the values specified.

Definition at line 203 of file settings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitConfig()

std::optional< ConfigError > common::InitConfig ( ArgsManager args,
SettingsAbortFn  settings_abort_fn 
)

Definition at line 18 of file init.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidEstimateModeErrorMessage()

std::string common::InvalidEstimateModeErrorMessage ( )

Definition at line 61 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InvalidPortErrMsg()

bilingual_str common::InvalidPortErrMsg ( const std::string &  optname,
const std::string &  invalid_value 
)

Definition at line 125 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnlyHasDefaultSectionSetting()

bool common::OnlyHasDefaultSectionSetting ( const Settings settings,
const std::string &  section,
const std::string &  name 
)

Return true if a setting is set in the default config file section, and not overridden by a higher priority command-line or network section value.

This is used to provide user warnings about values that might be getting ignored unintentionally.

Definition at line 248 of file settings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PSBTErrorString()

bilingual_str common::PSBTErrorString ( PSBTError  err)

Definition at line 78 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadSettings()

bool common::ReadSettings ( const fs::path path,
std::map< std::string, SettingsValue > &  values,
std::vector< std::string > &  errors 
)

Read settings file.

Definition at line 72 of file settings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResolveErrMsg()

bilingual_str common::ResolveErrMsg ( const std::string &  optname,
const std::string &  strBind 
)

Definition at line 120 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StringForFeeReason()

std::string common::StringForFeeReason ( FeeReason  reason)

Definition at line 26 of file messages.cpp.

Here is the caller graph for this function:

◆ TransactionErrorString() [1/2]

bilingual_str common::TransactionErrorString ( const node::TransactionError  error)

◆ TransactionErrorString() [2/2]

bilingual_str common::TransactionErrorString ( const TransactionError  err)

Definition at line 96 of file messages.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteSettings()

bool common::WriteSettings ( const fs::path path,
const std::map< std::string, SettingsValue > &  values,
std::vector< std::string > &  errors 
)

Write settings file.

Definition at line 123 of file settings.cpp.

Here is the call graph for this function:
Here is the caller graph for this function: