Skip to content

Commit 5431f2d

Browse files
wallet, refactor: Remove Legacy warnings and errors
Remove dead code due to legacy wallet removal.
1 parent dff208b commit 5431f2d

File tree

1 file changed

+11
-48
lines changed

1 file changed

+11
-48
lines changed

src/wallet/wallet.cpp

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,6 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
288288
return nullptr;
289289
}
290290

291-
// Legacy wallets are being deprecated, warn if the loaded wallet is legacy
292-
if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
293-
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."));
294-
}
295-
296291
NotifyWalletLoaded(context, wallet);
297292
AddWallet(context, wallet);
298293
wallet->postInitProcess();
@@ -382,12 +377,9 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
382377
uint64_t wallet_creation_flags = options.create_flags;
383378
const SecureString& passphrase = options.create_passphrase;
384379

385-
if (wallet_creation_flags & WALLET_FLAG_DESCRIPTORS) options.require_format = DatabaseFormat::SQLITE;
386-
else {
387-
error = Untranslated("Legacy wallets can no longer be created");
388-
status = DatabaseStatus::FAILED_CREATE;
389-
return nullptr;
390-
}
380+
// Only descriptor wallets can be created
381+
Assert(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS);
382+
options.require_format = DatabaseFormat::SQLITE;
391383

392384
// Indicate that the wallet is actually supposed to be blank and not just blank to make it encrypted
393385
bool create_blank = (wallet_creation_flags & WALLET_FLAG_BLANK_WALLET);
@@ -404,13 +396,6 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
404396
return nullptr;
405397
}
406398

407-
// Descriptor support must be enabled for an external signer wallet
408-
if ((wallet_creation_flags & WALLET_FLAG_EXTERNAL_SIGNER) && !(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) {
409-
error = Untranslated("Descriptor support must be enabled when using an external signer");
410-
status = DatabaseStatus::FAILED_CREATE;
411-
return nullptr;
412-
}
413-
414399
// Do not allow a passphrase when private keys are disabled
415400
if (!passphrase.empty() && (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
416401
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<CWallet> CreateWallet(WalletContext& context, const std::string&
453438
// Set a seed for the wallet
454439
{
455440
LOCK(wallet->cs_wallet);
456-
if (wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
457-
wallet->SetupDescriptorScriptPubKeyMans();
458-
} else {
459-
for (auto spk_man : wallet->GetActiveScriptPubKeyMans()) {
460-
if (!spk_man->SetupGeneration()) {
461-
error = Untranslated("Unable to generate initial keys");
462-
status = DatabaseStatus::FAILED_CREATE;
463-
return nullptr;
464-
}
465-
}
466-
}
441+
wallet->SetupDescriptorScriptPubKeyMans();
467442
}
468443

469444
// Relock the wallet
@@ -478,11 +453,6 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
478453
// Write the wallet settings
479454
UpdateWalletSetting(*context.chain, name, load_on_start, warnings);
480455

481-
// Legacy wallets are being deprecated, warn if a newly created wallet is legacy
482-
if (!(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS)) {
483-
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."));
484-
}
485-
486456
status = DatabaseStatus::SUCCESS;
487457
return wallet;
488458
}
@@ -813,6 +783,9 @@ void CWallet::AddToSpends(const CWalletTx& wtx, WalletBatch* batch)
813783

814784
bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
815785
{
786+
// Only descriptor wallets can be encrypted
787+
Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
788+
816789
if (IsCrypted())
817790
return false;
818791

@@ -871,8 +844,8 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
871844
Lock();
872845
Unlock(strWalletPassphrase);
873846

874-
// If we are using descriptors, make new descriptors with a new seed
875-
if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) && !IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
847+
// Make new descriptors with a new seed
848+
if (!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
876849
SetupDescriptorScriptPubKeyMans();
877850
}
878851
Lock();
@@ -2896,18 +2869,8 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
28962869
assert(walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
28972870

28982871
if ((wallet_creation_flags & WALLET_FLAG_EXTERNAL_SIGNER) || !(wallet_creation_flags & (WALLET_FLAG_DISABLE_PRIVATE_KEYS | WALLET_FLAG_BLANK_WALLET))) {
2899-
if (walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
2900-
walletInstance->SetupDescriptorScriptPubKeyMans();
2901-
// SetupDescriptorScriptPubKeyMans already calls SetupGeneration for us so we don't need to call SetupGeneration separately
2902-
} else {
2903-
// Legacy wallets need SetupGeneration here.
2904-
for (auto spk_man : walletInstance->GetActiveScriptPubKeyMans()) {
2905-
if (!spk_man->SetupGeneration()) {
2906-
error = _("Unable to generate initial keys");
2907-
return nullptr;
2908-
}
2909-
}
2910-
}
2872+
walletInstance->SetupDescriptorScriptPubKeyMans();
2873+
// SetupDescriptorScriptPubKeyMans already calls SetupGeneration for us so we don't need to call SetupGeneration separately
29112874
}
29122875

29132876
if (chain) {

0 commit comments

Comments
 (0)