From ee03c782ba61993d9e95fa499546cd14cee35445 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 30 Oct 2021 22:19:22 +0300 Subject: [PATCH] wallet: Make GetOldestKeyPoolTime return nullopt for blank wallets This change suppress the "keypoololdest" field in the getwalletinfo RPC response for blank descriptor wallets. --- src/wallet/wallet.cpp | 4 ++++ 1 file changed, 4 insertions(+) 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());