From 121c032e411ddb5f36d1c0efe87fbf3687886cdb Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 6 Mar 2024 04:39:13 +0300 Subject: [PATCH] fix: avoid calling functions that change wallet state inside of `assert(...)` --- src/wallet/scriptpubkeyman.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 678022e1f22e..9cc86db524a8 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -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;