diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6542abc23df..af1a20dacb5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -288,11 +288,6 @@ std::shared_ptr LoadWalletInternal(WalletContext& context, const std::s return nullptr; } - // Legacy wallets are being deprecated, warn if the loaded wallet is legacy - if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { - warnings.emplace_back(_("Wallet loaded successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future. Legacy wallets can be migrated to a descriptor wallet with migratewallet.")); - } - NotifyWalletLoaded(context, wallet); AddWallet(context, wallet); wallet->postInitProcess(); @@ -382,12 +377,9 @@ std::shared_ptr CreateWallet(WalletContext& context, const std::string& uint64_t wallet_creation_flags = options.create_flags; const SecureString& passphrase = options.create_passphrase; - if (wallet_creation_flags & WALLET_FLAG_DESCRIPTORS) options.require_format = DatabaseFormat::SQLITE; - else { - error = Untranslated("Legacy wallets can no longer be created"); - status = DatabaseStatus::FAILED_CREATE; - return nullptr; - } + // Only descriptor wallets can be created + Assert(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS); + options.require_format = DatabaseFormat::SQLITE; // Indicate that the wallet is actually supposed to be blank and not just blank to make it encrypted bool create_blank = (wallet_creation_flags & WALLET_FLAG_BLANK_WALLET); @@ -404,13 +396,6 @@ std::shared_ptr CreateWallet(WalletContext& context, const std::string& return nullptr; } - // Descriptor support must be enabled for an external signer wallet - if ((wallet_creation_flags & WALLET_FLAG_EXTERNAL_SIGNER) && !(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) { - error = Untranslated("Descriptor support must be enabled when using an external signer"); - status = DatabaseStatus::FAILED_CREATE; - return nullptr; - } - // Do not allow a passphrase when private keys are disabled if (!passphrase.empty() && (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { error = Untranslated("Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled."); @@ -453,17 +438,7 @@ std::shared_ptr CreateWallet(WalletContext& context, const std::string& // Set a seed for the wallet { LOCK(wallet->cs_wallet); - if (wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { - wallet->SetupDescriptorScriptPubKeyMans(); - } else { - for (auto spk_man : wallet->GetActiveScriptPubKeyMans()) { - if (!spk_man->SetupGeneration()) { - error = Untranslated("Unable to generate initial keys"); - status = DatabaseStatus::FAILED_CREATE; - return nullptr; - } - } - } + wallet->SetupDescriptorScriptPubKeyMans(); } // Relock the wallet @@ -478,11 +453,6 @@ std::shared_ptr CreateWallet(WalletContext& context, const std::string& // Write the wallet settings UpdateWalletSetting(*context.chain, name, load_on_start, warnings); - // Legacy wallets are being deprecated, warn if a newly created wallet is legacy - if (!(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) { - warnings.emplace_back(_("Wallet created successfully. The legacy wallet type is being deprecated and support for creating and opening legacy wallets will be removed in the future.")); - } - status = DatabaseStatus::SUCCESS; return wallet; } @@ -813,6 +783,9 @@ void CWallet::AddToSpends(const CWalletTx& wtx, WalletBatch* batch) bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) { + // Only descriptor wallets can be encrypted + Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)); + if (IsCrypted()) return false; @@ -871,8 +844,8 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase) Lock(); Unlock(strWalletPassphrase); - // If we are using descriptors, make new descriptors with a new seed - if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) && !IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) { + // Make new descriptors with a new seed + if (!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) { SetupDescriptorScriptPubKeyMans(); } Lock(); @@ -2896,18 +2869,8 @@ std::shared_ptr CWallet::Create(WalletContext& context, const std::stri assert(walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)); if ((wallet_creation_flags & WALLET_FLAG_EXTERNAL_SIGNER) || !(wallet_creation_flags & (WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET))) { - if (walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) { - walletInstance->SetupDescriptorScriptPubKeyMans(); - // SetupDescriptorScriptPubKeyMans already calls SetupGeneration for us so we don't need to call SetupGeneration separately - } else { - // Legacy wallets need SetupGeneration here. - for (auto spk_man : walletInstance->GetActiveScriptPubKeyMans()) { - if (!spk_man->SetupGeneration()) { - error = _("Unable to generate initial keys"); - return nullptr; - } - } - } + walletInstance->SetupDescriptorScriptPubKeyMans(); + // SetupDescriptorScriptPubKeyMans already calls SetupGeneration for us so we don't need to call SetupGeneration separately } if (chain) {