diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -359,6 +359,7 @@ clientversion.cpp compat/glibcxx_sanity.cpp compat/strnlen.cpp + currencyunit.cpp fs.cpp interfaces/handler.cpp logging.cpp diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,7 @@ const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST); + SetupCurrencyUnitOptions(argsman); argsman.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg( diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ static void SetupBitcoinTxArgs(ArgsManager &argsman) { SetupHelpOptions(argsman); + SetupCurrencyUnitOptions(argsman); argsman.AddArg("-create", "Create new, empty TX.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-json", "Select JSON output", ArgsManager::ALLOW_ANY, diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp --- a/src/bitcoin-wallet.cpp +++ b/src/bitcoin-wallet.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -20,6 +21,7 @@ static void SetupWalletToolArgs(ArgsManager &argsman) { SetupHelpOptions(argsman); SetupChainParamsBaseOptions(argsman); + SetupCurrencyUnitOptions(argsman); argsman.AddArg("-datadir=", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); diff --git a/src/chainparams.cpp b/src/chainparams.cpp --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -204,7 +205,7 @@ base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4}; cashaddrPrefix = - gArgs.GetBoolArg("-ecash", false) ? "ecash" : "bitcoincash"; + gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? "ecash" : "bitcoincash"; vFixedSeeds = std::vector( pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); @@ -352,7 +353,7 @@ base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; cashaddrPrefix = - gArgs.GetBoolArg("-ecash", false) ? "ectest" : "bchtest"; + gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? "ectest" : "bchtest"; vFixedSeeds = std::vector( pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); @@ -485,7 +486,7 @@ base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; cashaddrPrefix = - gArgs.GetBoolArg("-ecash", false) ? "ecregtest" : "bchreg"; + gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? "ecregtest" : "bchreg"; } }; diff --git a/src/currencyunit.h b/src/currencyunit.h new file mode 100644 --- /dev/null +++ b/src/currencyunit.h @@ -0,0 +1,14 @@ +// Copyright (c) 2021 The Bitcoin Developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_CURRENCYUNIT_H +#define BITCOIN_CURRENCYUNIT_H + +class ArgsManager; + +constexpr bool DEFAULT_ECASH = false; + +void SetupCurrencyUnitOptions(ArgsManager &argsman); + +#endif // BITCOIN_CURRENCYUNIT_H diff --git a/src/currencyunit.cpp b/src/currencyunit.cpp new file mode 100644 --- /dev/null +++ b/src/currencyunit.cpp @@ -0,0 +1,15 @@ +// Copyright (c) 2021 The Bitcoin Developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include + +void SetupCurrencyUnitOptions(ArgsManager &argsman) { + // whether to use eCash default unit and address prefix + argsman.AddArg("-ecash", + strprintf("Use ecash as default unit (default: %s)", + DEFAULT_ECASH ? "true" : "false"), + ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS); +} diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -381,13 +382,11 @@ ArgsManager &argsman = *node.args; SetupHelpOptions(argsman); + SetupCurrencyUnitOptions(argsman); // server-only for now argsman.AddArg("-help-debug", "Print help message with debugging options and exit", false, OptionsCategory::DEBUG_TEST); - // whether to use eCash default unit and address prefix - argsman.AddArg("-ecash", "Use ecash as default unit (Default: false)", - ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS); const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); diff --git a/src/minerfund.cpp b/src/minerfund.cpp --- a/src/minerfund.cpp +++ b/src/minerfund.cpp @@ -6,6 +6,7 @@ #include #include +#include #include // For DecodeDestination #include #include // For VersionBitsBlockState @@ -30,8 +31,8 @@ static const std::string bitcoinCashMinerFund = "bitcoincash:pqnqv9lt7e5vjyp0w88zf2af0l92l8rxdgnlxww9j9"; static CTxDestination dest = BuildDestination( - gArgs.GetBoolArg("-ecash", false) ? ecashMinerFund - : bitcoinCashMinerFund); + gArgs.GetBoolArg("-ecash", DEFAULT_ECASH) ? ecashMinerFund + : bitcoinCashMinerFund); return dest; }