wallet, refactor: Remove Legacy warnings and errors
Remove dead code due to legacy wallet removal.
This commit is contained in:
1 parent
dff208bd5a
commit
5431f2dc21
1 file changed
+11
-48
+11
-48
@@ -288,11 +288,6 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
|
|||||||
return nullptr;
|
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);
|
NotifyWalletLoaded(context, wallet);
|
||||||
AddWallet(context, wallet);
|
AddWallet(context, wallet);
|
||||||
wallet->postInitProcess();
|
wallet->postInitProcess();
|
||||||
@@ -382,12 +377,9 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
|||||||
uint64_t wallet_creation_flags = options.create_flags;
|
uint64_t wallet_creation_flags = options.create_flags;
|
||||||
const SecureString& passphrase = options.create_passphrase;
|
const SecureString& passphrase = options.create_passphrase;
|
||||||
|
|
||||||
if (wallet_creation_flags & WALLET_FLAG_DESCRIPTORS) options.require_format = DatabaseFormat::SQLITE;
|
// Only descriptor wallets can be created
|
||||||
else {
|
Assert(wallet_creation_flags & WALLET_FLAG_DESCRIPTORS);
|
||||||
error = Untranslated("Legacy wallets can no longer be created");
|
options.require_format = DatabaseFormat::SQLITE;
|
||||||
status = DatabaseStatus::FAILED_CREATE;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indicate that the wallet is actually supposed to be blank and not just blank to make it encrypted
|
// 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);
|
bool create_blank = (wallet_creation_flags & WALLET_FLAG_BLANK_WALLET);
|
||||||
@@ -404,13 +396,6 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
|||||||
return nullptr;
|
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
|
// Do not allow a passphrase when private keys are disabled
|
||||||
if (!passphrase.empty() && (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
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.");
|
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&
|
|||||||
// Set a seed for the wallet
|
// Set a seed for the wallet
|
||||||
{
|
{
|
||||||
LOCK(wallet->cs_wallet);
|
LOCK(wallet->cs_wallet);
|
||||||
if (wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
wallet->SetupDescriptorScriptPubKeyMans();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Relock the wallet
|
// Relock the wallet
|
||||||
@@ -478,11 +453,6 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
|||||||
// Write the wallet settings
|
// Write the wallet settings
|
||||||
UpdateWalletSetting(*context.chain, name, load_on_start, warnings);
|
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;
|
status = DatabaseStatus::SUCCESS;
|
||||||
return wallet;
|
return wallet;
|
||||||
}
|
}
|
||||||
@@ -813,6 +783,9 @@ void CWallet::AddToSpends(const CWalletTx& wtx, WalletBatch* batch)
|
|||||||
|
|
||||||
bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
||||||
{
|
{
|
||||||
|
// Only descriptor wallets can be encrypted
|
||||||
|
Assert(IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
||||||
|
|
||||||
if (IsCrypted())
|
if (IsCrypted())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -871,8 +844,8 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
|
|||||||
Lock();
|
Lock();
|
||||||
Unlock(strWalletPassphrase);
|
Unlock(strWalletPassphrase);
|
||||||
|
|
||||||
// If we are using descriptors, make new descriptors with a new seed
|
// Make new descriptors with a new seed
|
||||||
if (IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS) && !IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
|
if (!IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET)) {
|
||||||
SetupDescriptorScriptPubKeyMans();
|
SetupDescriptorScriptPubKeyMans();
|
||||||
}
|
}
|
||||||
Lock();
|
Lock();
|
||||||
@@ -2896,18 +2869,8 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||||||
assert(walletInstance->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS));
|
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 ((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();
|
||||||
walletInstance->SetupDescriptorScriptPubKeyMans();
|
// SetupDescriptorScriptPubKeyMans already calls SetupGeneration for us so we don't need to call SetupGeneration separately
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chain) {
|
if (chain) {
|
||||||
|
|||||||
Reference in new issue
Block a user