From 6993d112f3b4ae2905bce58a66bdebf771a620ca Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Tue, 30 Jan 2024 23:42:33 +0700 Subject: [PATCH 01/15] feat: extra check failure case CWallet::GenerateNewHDChainEncrypted To unify code with GenerateNewHDChain --- src/wallet/wallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ebbcd47e765c..a7bebbcba362 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5597,6 +5597,9 @@ bool CWallet::GenerateNewHDChainEncrypted(const SecureString& secureMnemonic, co } Lock(); return true; + } else { + // this should never happen + throw std::runtime_error(std::string(__func__) + ": SetCryptedHDChainSingle failed"); } } From 7b72726b3ecd812fed20f82a73bf53cac4e4186f Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Tue, 30 Jan 2024 23:18:07 +0700 Subject: [PATCH 02/15] refactor: SetCryptedHDChain moved to scriptpubkeyman --- src/wallet/scriptpubkeyman.cpp | 41 +++++++++++++++++++++++ src/wallet/scriptpubkeyman.h | 1 + src/wallet/wallet.cpp | 61 ++++++++-------------------------- 3 files changed, 55 insertions(+), 48 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 6d3853fae412..824871627d8d 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -355,6 +355,47 @@ void LegacyScriptPubKeyMan::UpgradeKeyMetadata() } } +void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secureMnemonic, const SecureString& secureMnemonicPassphrase, CKeyingMaterial vMasterKey) +{ + assert(!m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); + + + CHDChain hdChainTmp; + + // NOTE: an empty mnemonic means "generate a new one for me" + // NOTE: default mnemonic passphrase is an empty string + if (!hdChainTmp.SetMnemonic(secureMnemonic, secureMnemonicPassphrase, true)) { + throw std::runtime_error(std::string(__func__) + ": SetMnemonic failed"); + } + + // add default account + hdChainTmp.AddAccount(); + hdChainTmp.Debug(__func__); + + bool res = EncryptHDChain(vMasterKey, hdChainTmp); + assert(res); + + CHDChain hdChainCrypted; + 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(hdChainTmp.GetID() == hdChainCrypted.GetID()); + assert(hdChainTmp.GetSeedHash() != hdChainCrypted.GetSeedHash()); + + hdChainCrypted.Debug(__func__); + + if (!SetCryptedHDChainSingle(hdChainCrypted, false)) { + throw std::runtime_error(std::string(__func__) + ": SetCryptedHDChainSingle failed"); + } +} + void LegacyScriptPubKeyMan::GenerateNewHDChain(const SecureString& secureMnemonic, const SecureString& secureMnemonicPassphrase) { assert(!m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index edbbef903f2f..8a60e9af421e 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -460,6 +460,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv bool GetDecryptedHDChain(CHDChain& hdChainRet); /* Generates a new HD chain */ + void GenerateNewCryptedHDChain(const SecureString& secureMnemonic, const SecureString& secureMnemonicPassphrase, CKeyingMaterial vMasterKey); void GenerateNewHDChain(const SecureString& secureMnemonic, const SecureString& secureMnemonicPassphrase); /** diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a7bebbcba362..a6b02093a546 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5538,25 +5538,12 @@ bool CWallet::GenerateNewHDChainEncrypted(const SecureString& secureMnemonic, co throw std::runtime_error(strprintf("%s: spk_man is not available", __func__)); } - assert(!IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); - if (!HasEncryptionKeys()) { return false; } CCrypter crypter; CKeyingMaterial vMasterKey; - CHDChain hdChainTmp; - - // NOTE: an empty mnemonic means "generate a new one for me" - // NOTE: default mnemonic passphrase is an empty string - if (!hdChainTmp.SetMnemonic(secureMnemonic, secureMnemonicPassphrase, true)) { - throw std::runtime_error(std::string(__func__) + ": SetMnemonic failed"); - } - - // add default account - hdChainTmp.AddAccount(); - hdChainTmp.Debug(__func__); LOCK(cs_wallet); for (const CWallet::MasterKeyMap::value_type& pMasterKey : mapMasterKeys) { @@ -5564,46 +5551,24 @@ bool CWallet::GenerateNewHDChainEncrypted(const SecureString& secureMnemonic, co return false; } // get vMasterKey to encrypt new hdChain - if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) { - continue; // try another master key + if (crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) { + break; } - bool res = spk_man->EncryptHDChain(vMasterKey, hdChainTmp); - assert(res); - - CHDChain hdChainCrypted; - res = spk_man->GetHDChain(hdChainCrypted); - assert(res); - - DBG( - tfm::format(std::cout, "GenerateNewHDChainEncrypted -- current seed: '%s'\n", HexStr(hdChainTmp.GetSeed())); - tfm::format(std::cout, "GenerateNewHDChainEncrypted -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed())); - ); - - // ids should match, seed hashes should not - assert(hdChainTmp.GetID() == hdChainCrypted.GetID()); - assert(hdChainTmp.GetSeedHash() != hdChainCrypted.GetSeedHash()); + } - hdChainCrypted.Debug(__func__); + spk_man->GenerateNewCryptedHDChain(secureMnemonic, secureMnemonicPassphrase, vMasterKey); - if (spk_man->SetCryptedHDChainSingle(hdChainCrypted, false)) { - Lock(); - if (!Unlock(secureWalletPassphrase)) { - // this should never happen - throw std::runtime_error(std::string(__func__) + ": Unlock failed"); - } - if (!spk_man->NewKeyPool()) { - throw std::runtime_error(std::string(__func__) + ": NewKeyPool failed"); - } - Lock(); - return true; - } else { - // this should never happen - throw std::runtime_error(std::string(__func__) + ": SetCryptedHDChainSingle failed"); - } + Lock(); + if (!Unlock(secureWalletPassphrase)) { + // this should never happen + throw std::runtime_error(std::string(__func__) + ": Unlock failed"); } - - return false; + if (!spk_man->NewKeyPool()) { + throw std::runtime_error(std::string(__func__) + ": NewKeyPool failed"); + } + Lock(); + return true; } void CWallet::UpdateProgress(const std::string& title, int nProgress) From 9c8e4584ae2d83543412bb2e3e5cc15e6665083b Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 00:48:07 +0700 Subject: [PATCH 03/15] refactor: unify SetHDChain and SetCryptedHDChain helpers --- src/wallet/scriptpubkeyman.cpp | 26 +++++++------------------- src/wallet/scriptpubkeyman.h | 3 ++- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 824871627d8d..511c56e46655 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -442,7 +442,7 @@ bool LegacyScriptPubKeyMan::SetCryptedHDChain(WalletBatch &batch, const CHDChain { LOCK(cs_KeyStore); - if (!SetCryptedHDChain(chain)) + if (!SetHDChain(chain)) return false; if (!memonly) { @@ -1118,26 +1118,14 @@ bool LegacyScriptPubKeyMan::AddWatchOnly(const CScript& dest, int64_t nCreateTim bool LegacyScriptPubKeyMan::SetHDChain(const CHDChain& chain) { LOCK(cs_KeyStore); - if (m_storage.HasEncryptionKeys()) - return false; - - if (chain.IsCrypted()) - return false; - - hdChain = chain; - return true; -} - -bool LegacyScriptPubKeyMan::SetCryptedHDChain(const CHDChain& chain) -{ - LOCK(cs_KeyStore); - if (!m_storage.HasEncryptionKeys()) - return false; - if (!chain.IsCrypted()) - return false; + if (m_storage.HasEncryptionKeys() != chain.IsCrypted()) return false; - cryptedHDChain = chain; + if (chain.IsCrypted()) { + cryptedHDChain = chain; + } else { + hdChain = chain; + } return true; } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 8a60e9af421e..bc10f9bb82b6 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -454,9 +454,10 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; +private: bool SetHDChain(const CHDChain& chain); +public: bool GetHDChain(CHDChain& hdChainRet) const; - bool SetCryptedHDChain(const CHDChain& chain); bool GetDecryptedHDChain(CHDChain& hdChainRet); /* Generates a new HD chain */ From a180d73e5c626e26aaa1e05c0d91f6a71c2223b4 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 01:06:39 +0700 Subject: [PATCH 04/15] refactor: unify WalletBatch's WriteHDChain and WriteCryptedHDChain --- src/wallet/scriptpubkeyman.cpp | 8 ++++---- src/wallet/walletdb.cpp | 16 +++++++--------- src/wallet/walletdb.h | 1 - 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 511c56e46655..0e343f39ab5c 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -447,11 +447,11 @@ bool LegacyScriptPubKeyMan::SetCryptedHDChain(WalletBatch &batch, const CHDChain if (!memonly) { if (encrypted_batch) { - if (!encrypted_batch->WriteCryptedHDChain(chain)) - throw std::runtime_error(std::string(__func__) + ": WriteCryptedHDChain failed"); + if (!encrypted_batch->WriteHDChain(chain)) + throw std::runtime_error(std::string(__func__) + ": WriteHDChain failed"); } else { - if (!batch.WriteCryptedHDChain(chain)) - throw std::runtime_error(std::string(__func__) + ": WriteCryptedHDChain failed"); + if (!batch.WriteHDChain(chain)) + throw std::runtime_error(std::string(__func__) + ": WriteHDChain failed"); } m_storage.UnsetBlankWalletFlag(batch); } diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 90ae0c6564d9..a81943bfc7fb 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -800,17 +800,15 @@ bool WalletBatch::EraseDestData(const std::string &address, const std::string &k bool WalletBatch::WriteHDChain(const CHDChain& chain) { - return WriteIC(DBKeys::HDCHAIN, chain); -} - -bool WalletBatch::WriteCryptedHDChain(const CHDChain& chain) -{ - if (!WriteIC(DBKeys::CRYPTED_HDCHAIN, chain)) - return false; + if (chain.IsCrypted()) { + if (!WriteIC(DBKeys::CRYPTED_HDCHAIN, chain)) + return false; - EraseIC(DBKeys::HDCHAIN); + EraseIC(DBKeys::HDCHAIN); - return true; + return true; + } + return WriteIC(DBKeys::HDCHAIN, chain); } bool WalletBatch::WriteHDPubKey(const CHDPubKey& hdPubKey, const CKeyMetadata& keyMeta) diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 7026b131a687..4847ac737579 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -219,7 +219,6 @@ class WalletBatch //! write the hdchain model (external chain child index counter) bool WriteHDChain(const CHDChain& chain); - bool WriteCryptedHDChain(const CHDChain& chain); bool WriteHDPubKey(const CHDPubKey& hdPubKey, const CKeyMetadata& keyMeta); bool WriteWalletFlags(const uint64_t flags); From 59a998843b22c45434b5dbc6778ac425d4409e14 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 01:10:12 +0700 Subject: [PATCH 05/15] refactor: unify ScriptPubKeyMan's SetHDChain nad SetHDCryptedChain --- src/wallet/scriptpubkeyman.cpp | 35 +++++++--------------------------- src/wallet/scriptpubkeyman.h | 1 - src/wallet/wallet.cpp | 2 +- 3 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 0e343f39ab5c..b9b4113bc2d4 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -428,31 +428,15 @@ bool LegacyScriptPubKeyMan::SetHDChain(WalletBatch &batch, const CHDChain& chain return false; if (!memonly) { - if (!batch.WriteHDChain(chain)) { - throw std::runtime_error(std::string(__func__) + ": WriteHDChain failed"); - } - - m_storage.UnsetBlankWalletFlag(batch); - } - - return true; -} - -bool LegacyScriptPubKeyMan::SetCryptedHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly) -{ - LOCK(cs_KeyStore); - - if (!SetHDChain(chain)) - return false; - - if (!memonly) { - if (encrypted_batch) { + if (chain.IsCrypted() && encrypted_batch) { if (!encrypted_batch->WriteHDChain(chain)) throw std::runtime_error(std::string(__func__) + ": WriteHDChain failed"); } else { - if (!batch.WriteHDChain(chain)) + if (!batch.WriteHDChain(chain)) { throw std::runtime_error(std::string(__func__) + ": WriteHDChain failed"); + } } + m_storage.UnsetBlankWalletFlag(batch); } @@ -468,7 +452,7 @@ bool LegacyScriptPubKeyMan::SetHDChainSingle(const CHDChain& chain, bool memonly bool LegacyScriptPubKeyMan::SetCryptedHDChainSingle(const CHDChain& chain, bool memonly) { WalletBatch batch(m_storage.GetDatabase()); - return SetCryptedHDChain(batch, chain, memonly); + return SetHDChain(batch, chain, memonly); } bool LegacyScriptPubKeyMan::GetDecryptedHDChain(CHDChain& hdChainRet) @@ -1351,13 +1335,8 @@ void LegacyScriptPubKeyMan::DeriveNewChildKey(WalletBatch &batch, CKeyMetadata& if (!hdChainCurrent.SetAccount(nAccountIndex, acc)) throw std::runtime_error(std::string(__func__) + ": SetAccount failed"); - if (m_storage.HasEncryptionKeys()) { - if (!SetCryptedHDChain(batch, hdChainCurrent, false)) - throw std::runtime_error(std::string(__func__) + ": SetCryptedHDChain failed"); - } - else { - if (!SetHDChain(batch, hdChainCurrent, false)) - throw std::runtime_error(std::string(__func__) + ": SetHDChain failed"); + if (!SetHDChain(batch, hdChainCurrent, false)) { + throw std::runtime_error(std::string(__func__) + ": SetHDChain failed"); } if (!AddHDPubKey(batch, childKey.Neuter(), fInternal)) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index bc10f9bb82b6..1ce5e6054ab9 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -389,7 +389,6 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv /* Set the HD chain model (chain child index counters) */ bool SetHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); - bool SetCryptedHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); /** * Set the HD chain model (chain child index counters) using temporary wallet db object * which causes db flush every time these methods are used diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a6b02093a546..8b707245fb7a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -675,7 +675,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) assert(hdChainCurrent.GetID() == hdChainCrypted.GetID()); assert(hdChainCurrent.GetSeedHash() != hdChainCrypted.GetSeedHash()); - assert(spk_man_legacy->SetCryptedHDChain(*encrypted_batch, hdChainCrypted, false)); + assert(spk_man_legacy->SetHDChain(*encrypted_batch, hdChainCrypted, false)); } } From e08b64a1bbdb5aeb0b7dd5502654a229e7033902 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 01:29:55 +0700 Subject: [PATCH 06/15] refactor: unify SetHDChainSingle and SetCryptedHDChainSingle --- src/wallet/scriptpubkeyman.cpp | 10 ++-------- src/wallet/scriptpubkeyman.h | 1 - src/wallet/walletdb.cpp | 11 ++--------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index b9b4113bc2d4..0b0ae18682be 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -391,8 +391,8 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure hdChainCrypted.Debug(__func__); - if (!SetCryptedHDChainSingle(hdChainCrypted, false)) { - throw std::runtime_error(std::string(__func__) + ": SetCryptedHDChainSingle failed"); + if (!SetHDChainSingle(hdChainCrypted, false)) { + throw std::runtime_error(std::string(__func__) + ": SetHDChainSingle failed"); } } @@ -449,12 +449,6 @@ bool LegacyScriptPubKeyMan::SetHDChainSingle(const CHDChain& chain, bool memonly return SetHDChain(batch, chain, memonly); } -bool LegacyScriptPubKeyMan::SetCryptedHDChainSingle(const CHDChain& chain, bool memonly) -{ - WalletBatch batch(m_storage.GetDatabase()); - return SetHDChain(batch, chain, memonly); -} - bool LegacyScriptPubKeyMan::GetDecryptedHDChain(CHDChain& hdChainRet) { LOCK(cs_KeyStore); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 1ce5e6054ab9..103bb28a5223 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -394,7 +394,6 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv * which causes db flush every time these methods are used */ bool SetHDChainSingle(const CHDChain& chain, bool memonly); - bool SetCryptedHDChainSingle(const CHDChain& chain, bool memonly); //! Adds a watch-only address to the store, without saving it to disk (used by LoadWallet) bool LoadWatchOnly(const CScript &dest); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index a81943bfc7fb..4d12417b25fc 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -457,22 +457,15 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssKey >> strKey; ssValue >> strValue; pwallet->LoadDestData(DecodeDestination(strAddress), strKey, strValue); - } else if (strType == DBKeys::HDCHAIN) { + } else if (strType == DBKeys::HDCHAIN || strType == DBKeys::CRYPTED_HDCHAIN) { CHDChain chain; ssValue >> chain; + assert ((strType == DBKeys::CRYPTED_HDCHAIN) == chain.IsCrypted()); if (!pwallet->GetOrCreateLegacyScriptPubKeyMan()->SetHDChainSingle(chain, true)) { strErr = "Error reading wallet database: SetHDChain failed"; return false; } - } else if (strType == DBKeys::CRYPTED_HDCHAIN) { - CHDChain chain; - ssValue >> chain; - if (!pwallet->GetOrCreateLegacyScriptPubKeyMan()->SetCryptedHDChainSingle(chain, true)) - { - strErr = "Error reading wallet database: SetHDCryptedChain failed"; - return false; - } } else if (strType == DBKeys::HDPUBKEY) { wss.nHDPubKeys++; CPubKey vchPubKey; From c3754d5183a09bb27fc05dedf73879cd48c08e4e Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 01:51:09 +0700 Subject: [PATCH 07/15] refactor: move DecryptHDChain from public to private --- src/wallet/scriptpubkeyman.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 103bb28a5223..3fca376924cb 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -451,8 +451,8 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv */ bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); - bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; private: + bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; bool SetHDChain(const CHDChain& chain); public: bool GetHDChain(CHDChain& hdChainRet) const; From f418b9ac628a35a3bf8b9323e11ee2229578707b Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 02:09:40 +0700 Subject: [PATCH 08/15] refactor: move Encrypt chain call inside ScriptPubKeyMan::Encrypt --- src/wallet/scriptpubkeyman.cpp | 24 ++++++++++++++++++++++++ src/wallet/scriptpubkeyman.h | 2 +- src/wallet/wallet.cpp | 22 ---------------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 0b0ae18682be..5c1d6cffc367 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -237,12 +237,17 @@ bool LegacyScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBatch* batch) { LOCK(cs_KeyStore); + encrypted_batch = batch; if (!mapCryptedKeys.empty()) { encrypted_batch = nullptr; return false; } + // must get current HD chain before EncryptKeys + CHDChain hdChainCurrent; + GetHDChain(hdChainCurrent); + KeyMap keys_to_encrypt; keys_to_encrypt.swap(mapKeys); // Clear mapKeys so AddCryptedKeyInner will succeed. for (const KeyMap::value_type& mKey : keys_to_encrypt) @@ -260,6 +265,25 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat return false; } } + + if (!hdChainCurrent.IsNull()) { + assert(EncryptHDChain(master_key)); + + 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()); + + assert(SetHDChain(*encrypted_batch, hdChainCrypted, false)); + } + encrypted_batch = nullptr; return true; } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 3fca376924cb..7ccd5ecd8609 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -450,8 +450,8 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv * HD Wallet Functions */ - bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); private: + bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; bool SetHDChain(const CHDChain& chain); public: diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8b707245fb7a..0557f0b43fce 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -644,13 +644,8 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) } encrypted_batch->WriteMasterKey(nMasterKeyMaxID, kMasterKey); - // must get current HD chain before EncryptKeys - CHDChain hdChainCurrent; - for (const auto& spk_man_pair : m_spk_managers) { auto spk_man = spk_man_pair.second.get(); - LegacyScriptPubKeyMan *spk_man_legacy = dynamic_cast(spk_man); - if (spk_man_legacy != nullptr) spk_man_legacy->GetHDChain(hdChainCurrent); if (!spk_man->Encrypt(_vMasterKey, encrypted_batch)) { encrypted_batch->TxnAbort(); @@ -660,23 +655,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) // die and let the user reload the unencrypted wallet. assert(false); } - if (!hdChainCurrent.IsNull()) { - assert(spk_man_legacy->EncryptHDChain(_vMasterKey)); - - CHDChain hdChainCrypted; - assert(spk_man_legacy->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()); - - assert(spk_man_legacy->SetHDChain(*encrypted_batch, hdChainCrypted, false)); - } } From a219748f5ef970c6b1537df7a737d5654bb81379 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 01:19:43 +0700 Subject: [PATCH 09/15] refactor: make SetHDChain private in ScriptPubKeyManager --- src/wallet/scriptpubkeyman.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 7ccd5ecd8609..7efef9f16c53 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -388,7 +388,9 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv CPubKey GenerateNewKey(WalletBatch& batch, uint32_t nAccountIndex, bool fInternal /*= false*/) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore); /* Set the HD chain model (chain child index counters) */ +private: bool SetHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); +public: /** * Set the HD chain model (chain child index counters) using temporary wallet db object * which causes db flush every time these methods are used From b2143f9346fe8800d554d206b7279aa86d1e22c1 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 02:26:59 +0700 Subject: [PATCH 10/15] refactor: re-order public and private methods in scriptpubkeyman --- src/wallet/scriptpubkeyman.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 7efef9f16c53..1c7ae6fcfa70 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -274,6 +274,13 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv /** Add a KeyOriginInfo to the wallet */ bool AddKeyOriginWithDB(WalletBatch& batch, const CPubKey& pubkey, const KeyOriginInfo& info); + /* Set the HD chain model (chain child index counters) */ + bool SetHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); + + bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); + bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; + bool SetHDChain(const CHDChain& chain); + /* the HD chain data model (external chain counters) */ CHDChain hdChain GUARDED_BY(cs_KeyStore); CHDChain cryptedHDChain GUARDED_BY(cs_KeyStore); @@ -387,10 +394,6 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv //! Generate a new key CPubKey GenerateNewKey(WalletBatch& batch, uint32_t nAccountIndex, bool fInternal /*= false*/) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore); - /* Set the HD chain model (chain child index counters) */ -private: - bool SetHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); -public: /** * Set the HD chain model (chain child index counters) using temporary wallet db object * which causes db flush every time these methods are used @@ -452,11 +455,6 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv * HD Wallet Functions */ -private: - bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); - bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; - bool SetHDChain(const CHDChain& chain); -public: bool GetHDChain(CHDChain& hdChainRet) const; bool GetDecryptedHDChain(CHDChain& hdChainRet); From a0389e181fdd76f7216f89f1b8a062be2fce003d Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 04:42:04 +0700 Subject: [PATCH 11/15] refactor: rename EncryptHDChain to EncryptAndSetHDChain --- src/wallet/scriptpubkeyman.cpp | 6 +++--- src/wallet/scriptpubkeyman.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 5c1d6cffc367..0e2586db843f 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -267,7 +267,7 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat } if (!hdChainCurrent.IsNull()) { - assert(EncryptHDChain(master_key)); + assert(EncryptAndSetHDChain(master_key)); CHDChain hdChainCrypted; assert(GetHDChain(hdChainCrypted)); @@ -396,7 +396,7 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure hdChainTmp.AddAccount(); hdChainTmp.Debug(__func__); - bool res = EncryptHDChain(vMasterKey, hdChainTmp); + bool res = EncryptAndSetHDChain(vMasterKey, hdChainTmp); assert(res); CHDChain hdChainCrypted; @@ -494,7 +494,7 @@ bool LegacyScriptPubKeyMan::GetDecryptedHDChain(CHDChain& hdChainRet) return true; } -bool LegacyScriptPubKeyMan::EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain) +bool LegacyScriptPubKeyMan::EncryptAndSetHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain) { LOCK(cs_KeyStore); // should call EncryptKeys first diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 1c7ae6fcfa70..6deb254d7b77 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -277,7 +277,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv /* Set the HD chain model (chain child index counters) */ bool SetHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); - bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); + bool EncryptAndSetHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; bool SetHDChain(const CHDChain& chain); From 392b51b19791701ba061acd74930fca207c5c2e5 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Wed, 31 Jan 2024 22:01:25 +0700 Subject: [PATCH 12/15] refactor: obsolete hdCryptedChain from ScriptPubKeyMan --- src/wallet/scriptpubkeyman.cpp | 85 ++++++++++++++-------------------- src/wallet/scriptpubkeyman.h | 3 +- 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 0e2586db843f..28093cca9331 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -218,14 +218,14 @@ bool LegacyScriptPubKeyMan::CheckDecryptionKey(const CKeyingMaterial& master_key if (keyFail) { return false; } - if (!keyPass && !accept_no_keys && cryptedHDChain.IsNull()) { + if (!keyPass && !accept_no_keys && (hdChain.IsNull() || !hdChain.IsNull() && !hdChain.IsCrypted())) { return false; } - if(!cryptedHDChain.IsNull()) { + if(!hdChain.IsNull() && !hdChain.IsCrypted()) { // try to decrypt seed and make sure it matches CHDChain hdChainTmp; - if (!DecryptHDChain(master_key, hdChainTmp) || (cryptedHDChain.GetID() != hdChainTmp.GetSeedHash())) { + if (!DecryptHDChain(master_key, hdChainTmp) || (hdChain.GetID() != hdChainTmp.GetSeedHash())) { return false; } } @@ -267,7 +267,8 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat } if (!hdChainCurrent.IsNull()) { - assert(EncryptAndSetHDChain(master_key)); + assert(EncryptHDChain(master_key, hdChain)); + assert(SetHDChain(hdChain)); CHDChain hdChainCrypted; assert(GetHDChain(hdChainCrypted)); @@ -396,7 +397,11 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure hdChainTmp.AddAccount(); hdChainTmp.Debug(__func__); - bool res = EncryptAndSetHDChain(vMasterKey, hdChainTmp); + // We need to safe chain for validation further + CHDChain hdChainPrev = hdChainTmp; + bool res = EncryptHDChain(vMasterKey, hdChainTmp); + assert(res); + res = SetHDChain(hdChainTmp); assert(res); CHDChain hdChainCrypted; @@ -408,10 +413,9 @@ void LegacyScriptPubKeyMan::GenerateNewCryptedHDChain(const SecureString& secure tfm::format(std::cout, "GenerateNewCryptedHDChain -- crypted seed: '%s'\n", HexStr(hdChainCrypted.GetSeed())); ); - // ids should match, seed hashes should not - assert(hdChainTmp.GetID() == hdChainCrypted.GetID()); - assert(hdChainTmp.GetSeedHash() != hdChainCrypted.GetSeedHash()); + assert(hdChainPrev.GetID() == hdChainCrypted.GetID()); + assert(hdChainPrev.GetSeedHash() != hdChainCrypted.GetSeedHash()); hdChainCrypted.Debug(__func__); @@ -494,62 +498,52 @@ bool LegacyScriptPubKeyMan::GetDecryptedHDChain(CHDChain& hdChainRet) return true; } -bool LegacyScriptPubKeyMan::EncryptAndSetHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain) +bool LegacyScriptPubKeyMan::EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& chain) { LOCK(cs_KeyStore); // should call EncryptKeys first if (!m_storage.HasEncryptionKeys()) return false; - if (!cryptedHDChain.IsNull()) - return true; - - if (cryptedHDChain.IsCrypted()) + if (chain.IsCrypted()) return true; - if (hdChain.IsNull() && !chain.IsNull()) { - // Encrypting a new HDChain for an already encrypted non-HD wallet - hdChain = chain; - } - // make sure seed matches this chain - if (hdChain.GetID() != hdChain.GetSeedHash()) + if (chain.GetID() != chain.GetSeedHash()) return false; std::vector vchCryptedSeed; - if (!EncryptSecret(vMasterKeyIn, hdChain.GetSeed(), hdChain.GetID(), vchCryptedSeed)) + if (!EncryptSecret(vMasterKeyIn, chain.GetSeed(), chain.GetID(), vchCryptedSeed)) return false; - hdChain.Debug(__func__); - cryptedHDChain = hdChain; - cryptedHDChain.SetCrypted(true); + CHDChain cryptedChain = chain; + cryptedChain.Debug(__func__); + cryptedChain.SetCrypted(true); SecureVector vchSecureCryptedSeed(vchCryptedSeed.begin(), vchCryptedSeed.end()); - if (!cryptedHDChain.SetSeed(vchSecureCryptedSeed, false)) + if (!cryptedChain.SetSeed(vchSecureCryptedSeed, false)) return false; SecureVector vchMnemonic; SecureVector vchMnemonicPassphrase; // it's ok to have no mnemonic if wallet was initialized via hdseed - if (hdChain.GetMnemonic(vchMnemonic, vchMnemonicPassphrase)) { + if (chain.GetMnemonic(vchMnemonic, vchMnemonicPassphrase)) { std::vector vchCryptedMnemonic; std::vector vchCryptedMnemonicPassphrase; - if (!vchMnemonic.empty() && !EncryptSecret(vMasterKeyIn, vchMnemonic, hdChain.GetID(), vchCryptedMnemonic)) + if (!vchMnemonic.empty() && !EncryptSecret(vMasterKeyIn, vchMnemonic, chain.GetID(), vchCryptedMnemonic)) return false; - if (!vchMnemonicPassphrase.empty() && !EncryptSecret(vMasterKeyIn, vchMnemonicPassphrase, hdChain.GetID(), vchCryptedMnemonicPassphrase)) + if (!vchMnemonicPassphrase.empty() && !EncryptSecret(vMasterKeyIn, vchMnemonicPassphrase, chain.GetID(), vchCryptedMnemonicPassphrase)) return false; SecureVector vchSecureCryptedMnemonic(vchCryptedMnemonic.begin(), vchCryptedMnemonic.end()); SecureVector vchSecureCryptedMnemonicPassphrase(vchCryptedMnemonicPassphrase.begin(), vchCryptedMnemonicPassphrase.end()); - if (!cryptedHDChain.SetMnemonic(vchSecureCryptedMnemonic, vchSecureCryptedMnemonicPassphrase, false)) + if (!cryptedChain.SetMnemonic(vchSecureCryptedMnemonic, vchSecureCryptedMnemonicPassphrase, false)) return false; } - if (!hdChain.SetNull()) - return false; - + chain = cryptedChain; return true; } @@ -559,40 +553,40 @@ bool LegacyScriptPubKeyMan::DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, if (!m_storage.HasEncryptionKeys()) return true; - if (cryptedHDChain.IsNull()) + if (hdChain.IsNull()) return false; - if (!cryptedHDChain.IsCrypted()) + if (!hdChain.IsCrypted()) return false; SecureVector vchSecureSeed; - SecureVector vchSecureCryptedSeed = cryptedHDChain.GetSeed(); + SecureVector vchSecureCryptedSeed = hdChain.GetSeed(); std::vector vchCryptedSeed(vchSecureCryptedSeed.begin(), vchSecureCryptedSeed.end()); - if (!DecryptSecret(vMasterKeyIn, vchCryptedSeed, cryptedHDChain.GetID(), vchSecureSeed)) + if (!DecryptSecret(vMasterKeyIn, vchCryptedSeed, hdChain.GetID(), vchSecureSeed)) return false; - hdChainRet = cryptedHDChain; + hdChainRet = hdChain; if (!hdChainRet.SetSeed(vchSecureSeed, false)) return false; // hash of decrypted seed must match chain id - if (hdChainRet.GetSeedHash() != cryptedHDChain.GetID()) + if (hdChainRet.GetSeedHash() != hdChain.GetID()) return false; SecureVector vchSecureCryptedMnemonic; SecureVector vchSecureCryptedMnemonicPassphrase; // it's ok to have no mnemonic if wallet was initialized via hdseed - if (cryptedHDChain.GetMnemonic(vchSecureCryptedMnemonic, vchSecureCryptedMnemonicPassphrase)) { + if (hdChain.GetMnemonic(vchSecureCryptedMnemonic, vchSecureCryptedMnemonicPassphrase)) { SecureVector vchSecureMnemonic; SecureVector vchSecureMnemonicPassphrase; std::vector vchCryptedMnemonic(vchSecureCryptedMnemonic.begin(), vchSecureCryptedMnemonic.end()); std::vector vchCryptedMnemonicPassphrase(vchSecureCryptedMnemonicPassphrase.begin(), vchSecureCryptedMnemonicPassphrase.end()); - if (!vchCryptedMnemonic.empty() && !DecryptSecret(vMasterKeyIn, vchCryptedMnemonic, cryptedHDChain.GetID(), vchSecureMnemonic)) + if (!vchCryptedMnemonic.empty() && !DecryptSecret(vMasterKeyIn, vchCryptedMnemonic, hdChain.GetID(), vchSecureMnemonic)) return false; - if (!vchCryptedMnemonicPassphrase.empty() && !DecryptSecret(vMasterKeyIn, vchCryptedMnemonicPassphrase, cryptedHDChain.GetID(), vchSecureMnemonicPassphrase)) + if (!vchCryptedMnemonicPassphrase.empty() && !DecryptSecret(vMasterKeyIn, vchCryptedMnemonicPassphrase, hdChain.GetID(), vchSecureMnemonicPassphrase)) return false; if (!hdChainRet.SetMnemonic(vchSecureMnemonic, vchSecureMnemonicPassphrase, false)) @@ -1123,11 +1117,7 @@ bool LegacyScriptPubKeyMan::SetHDChain(const CHDChain& chain) if (m_storage.HasEncryptionKeys() != chain.IsCrypted()) return false; - if (chain.IsCrypted()) { - cryptedHDChain = chain; - } else { - hdChain = chain; - } + hdChain = chain; return true; } @@ -1786,11 +1776,6 @@ std::set LegacyScriptPubKeyMan::GetKeys() const bool LegacyScriptPubKeyMan::GetHDChain(CHDChain& hdChainRet) const { LOCK(cs_KeyStore); - if (m_storage.HasEncryptionKeys() && !cryptedHDChain.IsNull()) { - hdChainRet = cryptedHDChain; - return true; - } - hdChainRet = hdChain; return !hdChain.IsNull(); } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 6deb254d7b77..e2d6784fc9b6 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -277,13 +277,12 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv /* Set the HD chain model (chain child index counters) */ bool SetHDChain(WalletBatch &batch, const CHDChain& chain, bool memonly); - bool EncryptAndSetHDChain(const CKeyingMaterial& vMasterKeyIn, const CHDChain& chain = CHDChain()); + bool EncryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& chain); bool DecryptHDChain(const CKeyingMaterial& vMasterKeyIn, CHDChain& hdChainRet) const; bool SetHDChain(const CHDChain& chain); /* the HD chain data model (external chain counters) */ CHDChain hdChain GUARDED_BY(cs_KeyStore); - CHDChain cryptedHDChain GUARDED_BY(cs_KeyStore); /* HD derive new child key (on internal or external chain) */ void DeriveNewChildKey(WalletBatch& batch, CKeyMetadata& metadata, CKey& secretRet, uint32_t nAccountIndex, bool fInternal /*= false*/) EXCLUSIVE_LOCKS_REQUIRED(cs_KeyStore); From fa6519f320ef6de42ae75e3e24b0170e310ec64f Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 1 Feb 2024 00:17:05 +0700 Subject: [PATCH 13/15] refactor: move hdchain to wallet/ because it belongs there --- src/Makefile.am | 4 ++-- src/script/signingprovider.h | 1 - src/{ => wallet}/hdchain.cpp | 3 ++- src/{ => wallet}/hdchain.h | 6 +++--- src/wallet/init.cpp | 2 +- src/wallet/scriptpubkeyman.h | 1 + src/wallet/walletdb.cpp | 2 +- test/lint/lint-cppcheck-dash.sh | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) rename src/{ => wallet}/hdchain.cpp (99%) rename src/{ => wallet}/hdchain.h (97%) diff --git a/src/Makefile.am b/src/Makefile.am index 28aa3bad7186..cbaf065b37f6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -203,7 +203,6 @@ BITCOIN_CORE_H = \ gsl/assert.h \ gsl/pointers.h \ flat-database.h \ - hdchain.h \ flatfile.h \ fs.h \ httprpc.h \ @@ -371,6 +370,7 @@ BITCOIN_CORE_H = \ wallet/crypter.h \ wallet/db.h \ wallet/fees.h \ + wallet/hdchain.h \ wallet/ismine.h \ wallet/load.h \ wallet/rpcwallet.h \ @@ -540,12 +540,12 @@ libbitcoin_wallet_a_SOURCES = \ coinjoin/client.cpp \ coinjoin/interfaces.cpp \ coinjoin/util.cpp \ - hdchain.cpp \ wallet/coincontrol.cpp \ wallet/context.cpp \ wallet/crypter.cpp \ wallet/db.cpp \ wallet/fees.cpp \ + wallet/hdchain.cpp \ wallet/interfaces.cpp \ wallet/load.cpp \ wallet/rpcdump.cpp \ diff --git a/src/script/signingprovider.h b/src/script/signingprovider.h index 8ab2793a5b5d..1514a3a3f56e 100644 --- a/src/script/signingprovider.h +++ b/src/script/signingprovider.h @@ -6,7 +6,6 @@ #ifndef BITCOIN_SCRIPT_SIGNINGPROVIDER_H #define BITCOIN_SCRIPT_SIGNINGPROVIDER_H -#include #include #include #include