Merge bitcoin/bitcoin#36127: wallet: remove unused code
What changed, and why it matters
This commit is a routine cleanup that removes six pieces of unused wallet code from Bitcoin Core. Nothing is added or changed in behavior; only dead code is deleted. There is no security issue here.
No action required. This is a benign refactoring/cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit removes six unused items in src/wallet: COutput::ToString, DescriptorScriptPubKeyMan::AddDescriptorKey, CHDChain keypool index members, WalletDatabase::m_refcount, the warnings parameter of CreateFromDump, and two BDB-only DatabaseOptions members. All removals are straightforward dead-code elimination with no functional changes. The PR description explicitly states each item was unused and references the prior PRs that made them obsolete.
Changed components
src/wallet/coinselection.cppsrc/wallet/coinselection.hsrc/wallet/db.hsrc/wallet/dump.cppsrc/wallet/dump.hsrc/wallet/scriptpubkeyman.cppsrc/wallet/scriptpubkeyman.hsrc/wallet/walletdb.hsrc/wallet/wallettool.cppInspect captured patch +3 / −33
### src/wallet/coinselection.cpp
@@ -1027,11 +1027,6 @@ bool SelectionResult::operator<(SelectionResult other) const
return *m_waste < *other.m_waste || (*m_waste == *other.m_waste && m_selected_inputs.size() > other.m_selected_inputs.size());
}
-std::string COutput::ToString() const
-{
- return strprintf("COutput(%s, %d, %d) [%s]", outpoint.hash.ToString(), outpoint.n, depth, FormatMoney(txout.nValue));
-}
-
std::string GetAlgorithmName(const SelectionAlgorithm algo)
{
switch (algo)
### src/wallet/coinselection.h
@@ -98,8 +98,6 @@ struct COutput {
effective_value = txout.nValue - fee.value();
}
- std::string ToString() const;
-
bool operator<(const COutput& rhs) const
{
return outpoint < rhs.outpoint;
### src/wallet/db.h
@@ -11,7 +11,6 @@
#include <support/allocators/secure.h>
#include <util/fs.h>
-#include <atomic>
#include <memory>
#include <optional>
#include <string>
@@ -136,9 +135,6 @@ class WalletDatabase
/** Open the database if it is not already opened. */
virtual void Open() = 0;
- //! Counts the number of active database users to be sure that the database is not closed while someone is using it
- std::atomic<int> m_refcount{0};
-
/** Rewrite the entire database on disk
*/
virtual bool Rewrite() = 0;
@@ -179,8 +175,6 @@ struct DatabaseOptions {
// Specialized options. Not every option is supported by every backend.
bool verify = true; //!< Check data integrity on load.
bool use_unsafe_sync = false; //!< Disable file sync for faster performance.
- bool use_shared_memory = false; //!< Let other processes access the database.
- int64_t max_log_mb = 100; //!< Max log size to allow before consolidating.
};
enum class DatabaseStatus {
### src/wallet/dump.cpp
@@ -119,7 +119,7 @@ static void WalletToolReleaseWallet(CWallet* wallet)
delete wallet;
}
-bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::path& wallet_path, bilingual_str& error, std::vector<bilingual_str>& warnings)
+bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::path& wallet_path, bilingual_str& error)
{
if (name.empty()) {
tfm::format(std::cerr, "Wallet name cannot be empty\n");
### src/wallet/dump.h
@@ -8,7 +8,6 @@
#include <util/fs.h>
#include <string>
-#include <vector>
struct bilingual_str;
class ArgsManager;
@@ -17,7 +16,7 @@ namespace wallet {
class WalletDatabase;
bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& error);
-bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::path& wallet_path, bilingual_str& error, std::vector<bilingual_str>& warnings);
+bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::path& wallet_path, bilingual_str& error);
} // namespace wallet
#endif // BITCOIN_WALLET_DUMP_H
### src/wallet/scriptpubkeyman.cpp
@@ -1173,15 +1173,6 @@ std::vector<WalletDestination> DescriptorScriptPubKeyMan::MarkUnusedAddresses(co
return result;
}
-void DescriptorScriptPubKeyMan::AddDescriptorKey(const CKey& key, const CPubKey &pubkey)
-{
- LOCK(cs_desc_man);
- WalletBatch batch(m_storage.GetDatabase());
- if (!AddDescriptorKeyWithDB(batch, key, pubkey)) {
- throw std::runtime_error(std::string(__func__) + ": writing descriptor private key failed");
- }
-}
-
bool DescriptorScriptPubKeyMan::AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey)
{
AssertLockHeld(cs_desc_man);
### src/wallet/scriptpubkeyman.h
@@ -321,7 +321,6 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
void Load();
- void AddDescriptorKey(const CKey& key, const CPubKey &pubkey);
void UpdateWithSigningProvider(WalletBatch& batch, const FlatSigningProvider& signing_provider) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
//! Setup descriptors based on the given CExtKey
### src/wallet/walletdb.h
@@ -99,8 +99,6 @@ class CHDChain
uint32_t nExternalChainCounter;
uint32_t nInternalChainCounter;
CKeyID seed_id; //!< seed hash160
- int64_t m_next_external_index{0}; // Next index in the keypool to be used. Memory only.
- int64_t m_next_internal_index{0}; // Next index in the keypool to be used. Memory only.
static constexpr int VERSION_HD_BASE{1};
static constexpr int VERSION_HD_CHAIN_SPLIT{2};
### src/wallet/wallettool.cpp
@@ -162,11 +162,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
return ret;
} else if (command == "createfromdump") {
bilingual_str error;
- std::vector<bilingual_str> warnings;
- bool ret = CreateFromDump(args, name, path, error, warnings);
- for (const auto& warning : warnings) {
- tfm::format(std::cout, "%s\n", warning.original);
- }
+ bool ret = CreateFromDump(args, name, path, error);
if (!ret && !error.empty()) {
tfm::format(std::cerr, "%s\n", error.original);
}Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.