Skip to content

Commit 456e34c

Browse files
committed
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.
1 parent 3f4b42c commit 456e34c

File tree

8 files changed

+3
-61
lines changed

8 files changed

+3
-61
lines changed

ci/test/00_setup_env_native_cxx20.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8
99
export CONTAINER_NAME=ci_native_cxx20
1010
export PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libdbus-1-dev libharfbuzz-dev"
1111
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
12-
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
12+
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
1313
export PYZMQ=true
1414
export RUN_FUNCTIONAL_TESTS=false
1515
export GOAL="install"

ci/test/00_setup_env_native_fuzz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8
99
export CONTAINER_NAME=ci_native_fuzz
1010
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev"
1111
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
12-
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
12+
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
1313
export CXXFLAGS="-Werror -Wno-unused-command-line-argument -Wno-unused-value -Wno-deprecated-builtins"
1414
export PYZMQ=true
1515
export RUN_UNIT_TESTS=false

ci/test/00_setup_env_native_tsan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export TEST_RUNNER_EXTRA="--extended --exclude feature_pruning,feature_dbcrash,w
1313
export TEST_RUNNER_EXTRA="${TEST_RUNNER_EXTRA} --timeout-factor=4" # Increase timeout because sanitizers slow down
1414
export GOAL="install"
1515
export BITCOIN_CONFIG="--enable-zmq --with-gui=no --with-sanitizers=thread CC=clang-16 CXX=clang++-16 CXXFLAGS='-g' --with-boost-process"
16-
export CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG -DARENA_DEBUG"
16+
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
1717
export PYZMQ=true

src/util/system.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@
3434
#include <utility>
3535
#include <vector>
3636

37-
// Debugging macros
38-
39-
// Uncomment the following line to enable debugging messages
40-
// or enable on a per file basis prior to inclusion of util.h
41-
//#define ENABLE_DASH_DEBUG
42-
#ifdef ENABLE_DASH_DEBUG
43-
#define DBG( x ) x
44-
#else
45-
#define DBG( x )
46-
#endif
47-
4837
//Dash only features
4938

5039
extern bool fMasternodeMode;

src/wallet/hdchain.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <key_io.h>
99
#include <tinyformat.h>
1010
#include <util/system.h>
11-
#include <util/strencodings.h>
1211

1312
bool CHDChain::SetNull()
1413
{
@@ -41,33 +40,6 @@ bool CHDChain::IsCrypted() const
4140
return fCrypted;
4241
}
4342

44-
void CHDChain::Debug(const std::string& strName) const
45-
{
46-
DBG(
47-
LOCK(cs);
48-
std::cout << __func__ << ": ---" << strName << "---" << std::endl;
49-
if (fCrypted) {
50-
std::cout << "mnemonic: ***CRYPTED***" << std::endl;
51-
std::cout << "mnemonicpassphrase: ***CRYPTED***" << std::endl;
52-
std::cout << "seed: ***CRYPTED***" << std::endl;
53-
} else {
54-
std::cout << "mnemonic: " << std::string(vchMnemonic.begin(), vchMnemonic.end()).c_str() << std::endl;
55-
std::cout << "mnemonicpassphrase: " << std::string(vchMnemonicPassphrase.begin(), vchMnemonicPassphrase.end()).c_str() << std::endl;
56-
std::cout << "seed: " << HexStr(vchSeed).c_str() << std::endl;
57-
58-
CExtKey extkey;
59-
extkey.SetSeed(vchSeed);
60-
61-
std::cout << "extended private masterkey: " << EncodeExtKey(extkey).c_str() << std::endl;
62-
63-
CExtPubKey extpubkey;
64-
extpubkey = extkey.Neuter();
65-
66-
std::cout << "extended public masterkey: " << EncodeExtPubKey(extpubkey).c_str() << std::endl;
67-
}
68-
);
69-
}
70-
7143
bool CHDChain::SetMnemonic(const SecureVector& vchMnemonic, const SecureVector& vchMnemonicPassphrase, bool fUpdateID)
7244
{
7345
return SetMnemonic(SecureString(vchMnemonic.begin(), vchMnemonic.end()), SecureString(vchMnemonicPassphrase.begin(), vchMnemonicPassphrase.end()), fUpdateID);

src/wallet/hdchain.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ class CHDChain
9898
void SetCrypted(bool fCryptedIn);
9999
bool IsCrypted() const;
100100

101-
void Debug(const std::string& strName) const;
102-
103101
bool SetMnemonic(const SecureVector& vchMnemonic, const SecureVector& vchMnemonicPassphrase, bool fUpdateID);
104102
bool SetMnemonic(const SecureString& ssMnemonic, const SecureString& ssMnemonicPassphrase, bool fUpdateID);
105103
bool GetMnemonic(SecureVector& vchMnemonicRet, SecureVector& vchMnemonicPassphraseRet) const;

src/wallet/scriptpubkeyman.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat
273273
CHDChain hdChainCrypted;
274274
assert(GetHDChain(hdChainCrypted));
275275

276-
DBG(
277-
tfm::format(std::cout, "EncryptWallet -- current seed: '%s'\n", HexStr(hdChainCurrent.GetSeed()));
278-
tfm::format(std::cout, "EncryptWallet -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed()));
279-
);
280-
281276
// ids should match, seed hashes should not
282277
assert(hdChainCurrent.GetID() == hdChainCrypted.GetID());
283278
assert(hdChainCurrent.GetSeedHash() != hdChainCrypted.GetSeedHash());
@@ -396,7 +391,6 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure
396391

397392
// add default account
398393
hdChainTmp.AddAccount();
399-
hdChainTmp.Debug(__func__);
400394

401395
// We need to safe chain for validation further
402396
CHDChain hdChainPrev = hdChainTmp;
@@ -409,17 +403,10 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure
409403
res = GetHDChain(hdChainCrypted);
410404
assert(res);
411405

412-
DBG(
413-
tfm::format(std::cout, "GenerateNewCryptedHDChain -- current seed: '%s'\n", HexStr(hdChainTmp.GetSeed()));
414-
tfm::format(std::cout, "GenerateNewCryptedHDChain -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed()));
415-
);
416-
417406
// ids should match, seed hashes should not
418407
assert(hdChainPrev.GetID() == hdChainCrypted.GetID());
419408
assert(hdChainPrev.GetSeedHash() != hdChainCrypted.GetSeedHash());
420409

421-
hdChainCrypted.Debug(__func__);
422-
423410
if (!SetHDChainSingle(hdChainCrypted, false)) {
424411
throw std::runtime_error(std::string(__func__) + ": SetHDChainSingle failed");
425412
}
@@ -438,7 +425,6 @@ void LegacyScriptPubKeyMan::GenerateNewHDChain(const SecureString& secureMnemoni
438425

439426
// add default account
440427
newHdChain.AddAccount();
441-
newHdChain.Debug(__func__);
442428

443429
if (!SetHDChainSingle(newHdChain, false)) {
444430
throw std::runtime_error(std::string(__func__) + ": SetHDChainSingle failed");
@@ -518,7 +504,6 @@ bool LegacyScriptPubKeyMan::EncryptHDChain(const CKeyingMaterial& vMasterKeyIn,
518504
return false;
519505

520506
CHDChain cryptedChain = chain;
521-
cryptedChain.Debug(__func__);
522507
cryptedChain.SetCrypted(true);
523508

524509
SecureVector vchSecureCryptedSeed(vchCryptedSeed.begin(), vchCryptedSeed.end());
@@ -595,7 +580,6 @@ bool LegacyScriptPubKeyMan::DecryptHDChain(const CKeyingMaterial& vMasterKeyIn,
595580
}
596581

597582
hdChainRet.SetCrypted(false);
598-
hdChainRet.Debug(__func__);
599583

600584
return true;
601585
}

src/wallet/wallet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4607,7 +4607,6 @@ std::shared_ptr<CWallet> CWallet::Create(interfaces::Chain& chain, interfaces::C
46074607
}
46084608
// add default account
46094609
newHdChain.AddAccount();
4610-
newHdChain.Debug(__func__);
46114610
} else {
46124611
if (gArgs.IsArgSet("-hdseed") && !IsHex(strSeed)) {
46134612
walletInstance->WalletLogPrintf("%s -- Incorrect seed, generating a random mnemonic instead\n", __func__);

0 commit comments

Comments
 (0)