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.
This commit is contained in:
Konstantin Akimov 2024-04-03 17:23:20 +07:00
parent 3f4b42caa4
commit 456e34c991
No known key found for this signature in database
GPG Key ID: 2176C4A5D01EA524
8 changed files with 3 additions and 61 deletions

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -34,17 +34,6 @@
#include <utility>
#include <vector>
// 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;

View File

@ -8,7 +8,6 @@
#include <key_io.h>
#include <tinyformat.h>
#include <util/system.h>
#include <util/strencodings.h>
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);

View File

@ -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;

View File

@ -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;
}

View File

@ -4607,7 +4607,6 @@ std::shared_ptr<CWallet> 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__);