zcashd/src/experimental_features.cpp

57 lines
2.4 KiB
C++
Raw Normal View History

// Copyright (c) 2020-2023 The Zcash developers
2020-01-27 06:59:24 -08:00
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#include "experimental_features.h"
scripted-diff: Move util files to separate directory. -BEGIN VERIFY SCRIPT- mkdir -p src/util git mv src/util.h src/util/system.h git mv src/util.cpp src/util/system.cpp git mv src/utilmoneystr.h src/util/moneystr.h git mv src/utilmoneystr.cpp src/util/moneystr.cpp git mv src/utilstrencodings.h src/util/strencodings.h git mv src/utilstrencodings.cpp src/util/strencodings.cpp git mv src/utiltime.h src/util/time.h git mv src/utiltime.cpp src/util/time.cpp sed -i -e 's/"util\.h"/"util\/system\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp') git checkout HEAD -- src/secp256k1 # exclude secp256k1, which has its own "util.h" sed -i -e 's/"utilmoneystr\.h"/"util\/moneystr\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i -e 's/"utilstrencodings\.h"/"util\/strencodings\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i -e 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i -e 's/"utiltime\.h"/"util\/time\.h"/g' $(git ls-files 'src/*.h' 'src/*.cpp') sed -i -e 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h sed -i -e 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h sed -i -e 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h sed -i -e 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h sed -i -e 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am sed -i -e 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am sed -i -e 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am sed -i -e 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am sed -i -e 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-locale-dependence.sh sed -i -e 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh sed -i -e 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh -END VERIFY SCRIPT-
2018-10-22 15:51:11 -07:00
#include "util/system.h"
2020-01-27 06:59:24 -08:00
bool fExperimentalDeveloperEncryptWallet = false;
bool fExperimentalDeveloperSetPoolSizeZero = false;
bool fExperimentalPaymentDisclosure = false;
bool fExperimentalInsightExplorer = false;
2020-03-13 04:13:33 -07:00
bool fExperimentalLightWalletd = false;
2020-01-27 06:59:24 -08:00
std::optional<std::string> InitExperimentalMode()
2020-01-27 06:59:24 -08:00
{
auto fExperimentalMode = GetBoolArg("-experimentalfeatures", false);
fExperimentalDeveloperEncryptWallet = GetBoolArg("-developerencryptwallet", false);
fExperimentalDeveloperSetPoolSizeZero = GetBoolArg("-developersetpoolsizezero", false);
fExperimentalPaymentDisclosure = GetBoolArg("-paymentdisclosure", false);
fExperimentalInsightExplorer = GetBoolArg("-insightexplorer", false);
2020-03-13 04:13:33 -07:00
fExperimentalLightWalletd = GetBoolArg("-lightwalletd", false);
2020-01-27 06:59:24 -08:00
// Fail if user has set experimental options without the global flag
if (!fExperimentalMode) {
if (fExperimentalDeveloperEncryptWallet) {
return _("Wallet encryption requires -experimentalfeatures.");
} else if (fExperimentalDeveloperSetPoolSizeZero) {
return _("Setting the size of shielded pools to zero requires -experimentalfeatures.");
} else if (fExperimentalPaymentDisclosure) {
return _("Payment disclosure requires -experimentalfeatures.");
} else if (fExperimentalInsightExplorer) {
return _("Insight explorer requires -experimentalfeatures.");
2020-03-13 04:13:33 -07:00
} else if (fExperimentalLightWalletd) {
return _("Light Walletd requires -experimentalfeatures.");
2020-01-27 06:59:24 -08:00
}
}
return std::nullopt;
2020-01-27 06:59:24 -08:00
}
std::vector<std::string> GetExperimentalFeatures()
{
std::vector<std::string> experimentalfeatures;
if (fExperimentalDeveloperEncryptWallet)
experimentalfeatures.push_back("developerencryptwallet");
if (fExperimentalDeveloperSetPoolSizeZero)
experimentalfeatures.push_back("developersetpoolsizezero");
if (fExperimentalPaymentDisclosure)
experimentalfeatures.push_back("paymentdisclosure");
if (fExperimentalInsightExplorer)
experimentalfeatures.push_back("insightexplorer");
2020-03-13 04:13:33 -07:00
if (fExperimentalLightWalletd)
experimentalfeatures.push_back("lightwalletd");
2020-01-27 06:59:24 -08:00
return experimentalfeatures;
}