the result of CWallet::IsHDEnabled() was initialized with true.

But in case of no keys or a blank hd wallet the iterator would be skipped
and not set to false but true, since the loop would be not entered.

That had resulted in a wrong return and subsequent false HD and watch-only
icon display in gui when reloading a wallet after closing.

Update src/wallet/wallet.cpp

Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>

Github-Pull: #22781
Rebased-From: 8733a8e84c
This commit is contained in:
Saibato 2021-08-23 12:49:10 -04:00 committed by fanquake
parent a5a1538826
commit c671c6f470
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -1360,9 +1360,10 @@ CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) co
bool CWallet::IsHDEnabled() const
{
// All Active ScriptPubKeyMans must be HD for this to be true
bool result = true;
bool result = false;
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
result &= spk_man->IsHDEnabled();
if (!spk_man->IsHDEnabled()) return false;
result = true;
}
return result;
}