wallet, refactor: Remove Legacy check and error
What changed, and why it matters
This commit removes a now-impossible error path in Bitcoin Core's wallet code. Legacy (non-descriptor) wallets have already been removed from the codebase, so the check that rejected adding descriptors to a legacy wallet was unreachable 'dead code.' The change replaces that check with an internal assertion, which only affects debug builds and only crashes the program if an invariant that should never happen is violated. There is no security vulnerability here.
No action needed. This is a routine cleanup refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In CWallet::AddWalletDescriptor, the previous code returned a user-facing error if WALLET_FLAG_DESCRIPTORS was not set. Because legacy wallet support has been removed, all wallets are descriptor wallets and this flag is always set, making the branch unreachable. The patch replaces the conditional error with Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)), a debug-only assertion. This is a pure refactor with no functional change in release builds.
Changed components
src/wallet/wallet.cppCWallet::AddWalletDescriptorInspect captured patch +1 / −3
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index c7df8187..4973c8f2 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3656,9 +3656,7 @@ util::Result<std::reference_wrapper<DescriptorScriptPubKeyMan>> CWallet::AddWall
{
AssertLockHeld(cs_wallet);
- if (!IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
- return util::Error{_("Cannot add WalletDescriptor to a non-descriptor wallet")};
- }
+ Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
auto spk_man = GetDescriptorScriptPubKeyMan(desc);
if (spk_man) {
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.