fix: avoid calling functions that change wallet state inside of assert(...)

This commit is contained in:
UdjinM6 2024-03-06 04:39:13 +03:00
parent 09239a17c7
commit 121c032e41
No known key found for this signature in database
GPG Key ID: 83592BD1400D58D9

View File

@ -268,17 +268,21 @@ bool LegacyScriptPubKeyMan::Encrypt(const CKeyingMaterial& master_key, WalletBat
}
if (!hdChainCurrent.IsNull()) {
assert(EncryptHDChain(master_key, m_hd_chain));
assert(LoadHDChain(m_hd_chain));
bool res = EncryptHDChain(master_key, m_hd_chain);
assert(res);
res = LoadHDChain(m_hd_chain);
assert(res);
CHDChain hdChainCrypted;
assert(GetHDChain(hdChainCrypted));
res = GetHDChain(hdChainCrypted);
assert(res);
// ids should match, seed hashes should not
assert(hdChainCurrent.GetID() == hdChainCrypted.GetID());
assert(hdChainCurrent.GetSeedHash() != hdChainCrypted.GetSeedHash());
assert(AddHDChain(*encrypted_batch, hdChainCrypted));
res = AddHDChain(*encrypted_batch, hdChainCrypted);
assert(res);
}
encrypted_batch = nullptr;