diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 904154c91da..e535a080f28 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2172,6 +2172,10 @@ bool CWallet::GetNewChangeDestination(const OutputType type, CTxDestination& des std::optional CWallet::GetOldestKeyPoolTime() const { LOCK(cs_wallet); + if (m_spk_managers.empty()) { + return std::nullopt; + } + std::optional oldest_key{std::numeric_limits::max()}; for (const auto& spk_man_pair : m_spk_managers) { oldest_key = std::min(oldest_key, spk_man_pair.second->GetOldestKeyPoolTime());