rkrux
commented at 10:42 am on February 4, 2026:
contributor
Reasons:
Few of the wallet methods are descriptors specific as suggested
by their names, these assertions seems redundant within them.
Since the legacy wallet can’t be loaded anymore, few of these
assertions are outdated now.
Seeing too many of these assertions in the CWallet class while
reading the code is cognitively loaded, and after a while becomes
annoying for the reader.
Note: Such assertions in the migration specific functions have been
left untouched because they seem necessary there.
DrahtBot added the label
Wallet
on Feb 4, 2026
DrahtBot
commented at 10:42 am on February 4, 2026:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviews
See the guideline for information on the review process.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
#30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() by ryanofsky)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
rkrux
commented at 11:49 am on February 4, 2026:
contributor
I had incorrectly run the functional tests in a different directory in local that led to all the functional tests pass. I can reproduce the test failure locally now, putting the PR in draft for now.
rkrux marked this as a draft
on Feb 4, 2026
DrahtBot added the label
CI failed
on Feb 4, 2026
wallet: remove few asserts of `WALLET_FLAG_DESCRIPTORS` flag
Reasons:
1. Few of the wallet methods are descriptors specific as suggested
by their names, these assertions seems redundant within them.
2. Since the legacy wallet can't be loaded anymore, few of these
assertions are outdated now.
3. Seeing too many of these assertions in the `CWallet` class while
reading the code is cognitively loaded, and after a while becomes
annoying for the reader.
Note: Such assertions in the migration specific functions have been
left untouched because they seem necessary there.
a3ff41a5a8
wallet: move out `UpgradeDescriptorCache()` wallet flag check to the callers
The `UpgradeDescriptorCache` method ends up being called via the
`CWallet::Unlock` and `WalletBatch::LoadWallet` methods, both of
which can be called for the legacy wallets within the context of
wallet migration. For the former caller, it is evident in the
`test_encrypted` test of `wallet_migration` suite.
The previous code where there is no explicit check in the callers
makes the reader believe that the callers end up being called only
for descriptor wallets, which is misleading. This move out of the
check makes it explicit for the reader that this is not the only
flow for these callers.
77778e2559
rkrux force-pushed
on Feb 4, 2026
rkrux renamed this:
wallet: remove few asserts of `WALLET_FLAG_DESCRIPTORS` flag
wallet: remove most asserts of `WALLET_FLAG_DESCRIPTORS` flag
on Feb 4, 2026
DrahtBot removed the label
CI failed
on Feb 4, 2026
rkrux marked this as ready for review
on Feb 5, 2026
frankomosh
commented at 11:29 am on February 9, 2026:
contributor
Few questions from my code review;
Why remove the assertion from EncryptWallet()? I think it also does descriptor-specific work (iterates m_spk_managers, calls SetupDescriptorScriptPubKeyMans()).
You said in the other commit that Unlock() and LoadWallet() can be called during migration for legacy wallets. I wonder if EncryptWallet() can face a similar situation.
b-l-u-e
commented at 12:38 pm on February 18, 2026:
contributor
Why remove the assertion from EncryptWallet()? I think it also does descriptor-specific work (iterates m_spk_managers, calls SetupDescriptorScriptPubKeyMans()).
i tried testing with and without assertion seems with removing assertion leds to errors failing later
added some tests in src/wallet/test/wallet_tests.cpp to see
0--- a/src/wallet/test/wallet_tests.cpp
1+++ b/src/wallet/test/wallet_tests.cpp
2@@ -722,5 +722,32 @@ BOOST_FIXTURE_TEST_CASE(RemoveTxs, TestChain100Setup)
3 TestUnloadWallet(std::move(wallet));
4 }
5 6+BOOST_FIXTURE_TEST_CASE(encryptwallet_requires_descriptor_wallet, BasicTestingSetup)
7+{
8+ WalletContext context;
9+ context.args = &m_args;
10+ auto wallet = TestLoadWallet(context);
11+ BOOST_REQUIRE(wallet);
12+ BOOST_CHECK(wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
13+ bool ok = wallet->EncryptWallet("test");
14+ (void)ok;
15+ WaitForDeleteWallet(std::move(wallet));
16+}
17+
18+BOOST_FIXTURE_TEST_CASE(encryptwallet_on_non_descriptor_wrong_behavior, WalletTestingSetup)
19+{
20+ BOOST_REQUIRE(!m_wallet.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
21+ BOOST_REQUIRE(m_wallet.GetAllScriptPubKeyMans().empty());
22+
23+ bool ok = m_wallet.EncryptWallet("test");
24+
25+ if (ok) {
26+ BOOST_CHECK_MESSAGE(!m_wallet.GetAllScriptPubKeyMans().empty(),
27+ "EncryptWallet added descriptor SPKMs via SetupDescriptorScriptPubKeyMans()");
28+ BOOST_CHECK_MESSAGE(!m_wallet.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS),
29+ "Wrong behavior: wallet has descriptor SPKMs but WALLET_FLAG_DESCRIPTORS was never set inconsistent state");
30+ }
31+}
so tests fails inside descriptor code scriptpubkeyman this is without assert
0wallet/test/wallet_tests.cpp(737): Entering test case"encryptwallet_on_non_descriptor_wrong_behavior" 1wallet/test/wallet_tests.cpp(739): info: check !m_wallet.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) has passed
2wallet/test/wallet_tests.cpp(740): info: check m_wallet.GetAllScriptPubKeyMans().empty() has passed
3test_bitcoin: wallet/scriptpubkeyman.cpp:1138: bool wallet::DescriptorScriptPubKeyMan::SetupDescriptorGeneration(WalletBatch &, const CExtKey &, OutputType, bool): Assertion `m_storage.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)' failed. 4unknown location(0): fatal error: in"wallet_tests/encryptwallet_on_non_descriptor_wrong_behavior": signal: SIGABRT (application abort requested)
5wallet/test/wallet_tests.cpp(740): last checkpoint
6wallet/test/wallet_tests.cpp(737): Leaving test case"encryptwallet_on_non_descriptor_wrong_behavior"; testing time: 340947us
7wallet/test/wallet_tests.cpp(45): Leaving test suite "wallet_tests"; testing time: 340982us
8wallet/test/wallet_transaction_tests.cpp(12): Test suite "wallet_transaction_tests" is skipped because disabled
9wallet/test/walletdb_tests.cpp(15): Test suite "walletdb_tests" is skipped because disabled
10wallet/test/walletload_tests.cpp(14): Test suite "walletload_tests" is skipped because disabled
11ipc/test/ipc_tests.cpp(11): Test suite "ipc_tests" is skipped because disabled
12Leaving test module "Bitcoin Core Test Suite"; testing time: 341332us
1314***1 failure is detected in the test module "Bitcoin Core Test Suite"
and then with assert it fails at the boundary Encryptwallet
0wallet/test/wallet_tests.cpp(739): info: check !m_wallet.IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) has passed
1wallet/test/wallet_tests.cpp(740): info: check m_wallet.GetAllScriptPubKeyMans().empty() has passed
2wallet/wallet.cpp:812bool wallet::CWallet::EncryptWallet(const SecureString &): Assertion `IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)' failed. 3unknown location(0): fatal error: in"wallet_tests/encryptwallet_on_non_descriptor_wrong_behavior": signal: SIGABRT (application abort requested)
4wallet/test/wallet_tests.cpp(740): last checkpoint
5wallet/test/wallet_tests.cpp(737): Leaving test case"encryptwallet_on_non_descriptor_wrong_behavior"; testing time: 13719us
6wallet/test/wallet_tests.cpp(45): Leaving test suite "wallet_tests"; testing time: 13750us
7wallet/test/wallet_transaction_tests.cpp(12): Test suite "wallet_transaction_tests" is skipped because disabled
8wallet/test/walletdb_tests.cpp(15): Test suite "walletdb_tests" is skipped because disabled
9wallet/test/walletload_tests.cpp(14): Test suite "walletload_tests" is skipped because disabled
10ipc/test/ipc_tests.cpp(11): Test suite "ipc_tests" is skipped because disabled
11Leaving test module "Bitcoin Core Test Suite"; testing time: 14055us
1213***1 failure is detected in the test module "Bitcoin Core Test Suite"
b-l-u-e
commented at 1:50 pm on February 18, 2026:
contributor
i think here states that its descriptor-specific
0git show a3ff41a5a8:src/wallet/wallet.cpp | sed -n '865,868p'
1 if (!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
2 SetupDescriptorScriptPubKeyMans();
3 }
4 Lock();
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-03-03 21:13 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me