From 456e34c9912fd042a9ca1322dfb95a3b48e1322a Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 3 Apr 2024 17:23:20 +0700 Subject: [PATCH] chore: drop debug printing of private keys to console stdout Debug logs should not be printed to stdout, stderr exists for it. Private keys should not be printed to console by activation very general macros name "ENABLE_DASH_DEBUG". This macros is used only for hdchain private keys, the location util/system.h is too general for it. Functional test "tool_wallet.py" is failed due to unexpected output for tsan. It seems as easier to remove this logs due to too many issues with it rather than address all of them. --- ci/test/00_setup_env_native_cxx20.sh | 2 +- ci/test/00_setup_env_native_fuzz.sh | 2 +- ci/test/00_setup_env_native_tsan.sh | 2 +- src/util/system.h | 11 ----------- src/wallet/hdchain.cpp | 28 ---------------------------- src/wallet/hdchain.h | 2 -- src/wallet/scriptpubkeyman.cpp | 16 ---------------- src/wallet/wallet.cpp | 1 - 8 files changed, 3 insertions(+), 61 deletions(-) diff --git a/ci/test/00_setup_env_native_cxx20.sh b/ci/test/00_setup_env_native_cxx20.sh index 24a1195d6b..422da6b4ca 100755 --- a/ci/test/00_setup_env_native_cxx20.sh +++ b/ci/test/00_setup_env_native_cxx20.sh @@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8 export CONTAINER_NAME=ci_native_cxx20 export PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libdbus-1-dev libharfbuzz-dev" export DEP_OPTS="NO_UPNP=1 DEBUG=1" -export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG" +export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG" export PYZMQ=true export RUN_FUNCTIONAL_TESTS=false export GOAL="install" diff --git a/ci/test/00_setup_env_native_fuzz.sh b/ci/test/00_setup_env_native_fuzz.sh index d7cad6126e..a6f7f629a8 100755 --- a/ci/test/00_setup_env_native_fuzz.sh +++ b/ci/test/00_setup_env_native_fuzz.sh @@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8 export CONTAINER_NAME=ci_native_fuzz export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev" export DEP_OPTS="NO_UPNP=1 DEBUG=1" -export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG" +export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG" export CXXFLAGS="-Werror -Wno-unused-command-line-argument -Wno-unused-value -Wno-deprecated-builtins" export PYZMQ=true export RUN_UNIT_TESTS=false diff --git a/ci/test/00_setup_env_native_tsan.sh b/ci/test/00_setup_env_native_tsan.sh index bcdc05103c..633304580f 100755 --- a/ci/test/00_setup_env_native_tsan.sh +++ b/ci/test/00_setup_env_native_tsan.sh @@ -13,5 +13,5 @@ export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,w export TEST_RUNNER_EXTRA="${TEST_RUNNER_EXTRA} --timeout-factor=4" # Increase timeout because sanitizers slow down export GOAL="install" export BITCOIN_CONFIG="--enable-zmq --with-gui=no --with-sanitizers=thread CC=clang-16 CXX=clang++-16 CXXFLAGS='-g' --with-boost-process" -export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG" +export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG" export PYZMQ=true diff --git a/src/util/system.h b/src/util/system.h index f00ff20031..3aa787d766 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -34,17 +34,6 @@ #include #include -// Debugging macros - -// Uncomment the following line to enable debugging messages -// or enable on a per file basis prior to inclusion of util.h -//#define ENABLE_DASH_DEBUG -#ifdef ENABLE_DASH_DEBUG -#define DBG( x ) x -#else -#define DBG( x ) -#endif - //Dash only features extern bool fMasternodeMode; diff --git a/src/wallet/hdchain.cpp b/src/wallet/hdchain.cpp index b4fca803a3..516b8c38ba 100644 --- a/src/wallet/hdchain.cpp +++ b/src/wallet/hdchain.cpp @@ -8,7 +8,6 @@ #include #include #include -#include bool CHDChain::SetNull() { @@ -41,33 +40,6 @@ bool CHDChain::IsCrypted() const return fCrypted; } -void CHDChain::Debug(const std::string& strName) const -{ - DBG( - LOCK(cs); - std::cout << __func__ << ": ---" << strName << "---" << std::endl; - if (fCrypted) { - std::cout << "mnemonic: ***CRYPTED***" << std::endl; - std::cout << "mnemonicpassphrase: ***CRYPTED***" << std::endl; - std::cout << "seed: ***CRYPTED***" << std::endl; - } else { - std::cout << "mnemonic: " << std::string(vchMnemonic.begin(), vchMnemonic.end()).c_str() << std::endl; - std::cout << "mnemonicpassphrase: " << std::string(vchMnemonicPassphrase.begin(), vchMnemonicPassphrase.end()).c_str() << std::endl; - std::cout << "seed: " << HexStr(vchSeed).c_str() << std::endl; - - CExtKey extkey; - extkey.SetSeed(vchSeed); - - std::cout << "extended private masterkey: " << EncodeExtKey(extkey).c_str() << std::endl; - - CExtPubKey extpubkey; - extpubkey = extkey.Neuter(); - - std::cout << "extended public masterkey: " << EncodeExtPubKey(extpubkey).c_str() << std::endl; - } - ); -} - bool CHDChain::SetMnemonic(const SecureVector& vchMnemonic, const SecureVector& vchMnemonicPassphrase, bool fUpdateID) { return SetMnemonic(SecureString(vchMnemonic.begin(), vchMnemonic.end()), SecureString(vchMnemonicPassphrase.begin(), vchMnemonicPassphrase.end()), fUpdateID); diff --git a/src/wallet/hdchain.h b/src/wallet/hdchain.h index bacb834ddc..6d2b6cccfe 100644 --- a/src/wallet/hdchain.h +++ b/src/wallet/hdchain.h @@ -98,8 +98,6 @@ public: void SetCrypted(bool fCryptedIn); bool IsCrypted() const; - void Debug(const std::string& strName) const; - bool SetMnemonic(const SecureVector& vchMnemonic, const SecureVector& vchMnemonicPassphrase, bool fUpdateID); bool SetMnemonic(const SecureString& ssMnemonic, const SecureString& ssMnemonicPassphrase, bool fUpdateID); bool GetMnemonic(SecureVector& vchMnemonicRet, SecureVector& vchMnemonicPassphraseRet) const; diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 2c9a3c0034..7021967601 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -273,11 +273,6 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat CHDChain hdChainCrypted; assert(GetHDChain(hdChainCrypted)); - DBG( - tfm::format(std::cout, "EncryptWallet -- current seed: '%s'\n", HexStr(hdChainCurrent.GetSeed())); - tfm::format(std::cout, "EncryptWallet -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed())); - ); - // ids should match, seed hashes should not assert(hdChainCurrent.GetID() == hdChainCrypted.GetID()); assert(hdChainCurrent.GetSeedHash() != hdChainCrypted.GetSeedHash()); @@ -396,7 +391,6 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure // add default account hdChainTmp.AddAccount(); - hdChainTmp.Debug(__func__); // We need to safe chain for validation further CHDChain hdChainPrev = hdChainTmp; @@ -409,17 +403,10 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure res = GetHDChain(hdChainCrypted); assert(res); - DBG( - tfm::format(std::cout, "GenerateNewCryptedHDChain -- current seed: '%s'\n", HexStr(hdChainTmp.GetSeed())); - tfm::format(std::cout, "GenerateNewCryptedHDChain -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed())); - ); - // ids should match, seed hashes should not assert(hdChainPrev.GetID() == hdChainCrypted.GetID()); assert(hdChainPrev.GetSeedHash() != hdChainCrypted.GetSeedHash()); - hdChainCrypted.Debug(__func__); - if (!SetHDChainSingle(hdChainCrypted, false)) { throw std::runtime_error(std::string(__func__) + ": SetHDChainSingle failed"); } @@ -438,7 +425,6 @@ void LegacyScriptPubKeyMan::GenerateNewHDChain(const SecureString& secureMnemoni // add default account newHdChain.AddAccount(); - newHdChain.Debug(__func__); if (!SetHDChainSingle(newHdChain, false)) { throw std::runtime_error(std::string(__func__) + ": SetHDChainSingle failed"); @@ -518,7 +504,6 @@ bool LegacyScriptPubKeyMan::EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, return false; CHDChain cryptedChain = chain; - cryptedChain.Debug(__func__); cryptedChain.SetCrypted(true); SecureVector vchSecureCryptedSeed(vchCryptedSeed.begin(), vchCryptedSeed.end()); @@ -595,7 +580,6 @@ bool LegacyScriptPubKeyMan::DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, } hdChainRet.SetCrypted(false); - hdChainRet.Debug(__func__); return true; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index cb541942bd..757c663df8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4607,7 +4607,6 @@ std::shared_ptr CWallet::Create(interfaces::Chain& chain, interfaces::C } // add default account newHdChain.AddAccount(); - newHdChain.Debug(__func__); } else { if (gArgs.IsArgSet("-hdseed") && !IsHex(strSeed)) { walletInstance->WalletLogPrintf("%s -- Incorrect seed, generating a random mnemonic instead\n", __func__);