mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-17 00:52:43 +02:00
Merge bitcoin/bitcoin#32481: wallet, refactor: Remove Legacy wallet unused warnings and errors
ce90f0c99f
rpc, wallet, refactor: Remove non-descriptor errors (pablomartin4btc)573bcd75d7
wallet, refactor: Remove unused SetupGeneration (pablomartin4btc)5431f2dc21
wallet, refactor: Remove Legacy warnings and errors (pablomartin4btc) Pull request description: Remove dead code due to legacy wallet support removal. These changes have no impact on functionality. They are transparent to the end user, as legacy wallets can't be created or loaded anymore, so these checks are no longer reached. The legacy-to-descriptor wallet migration flow is not affected either, as these removals are not part of its process. ACKs for top commit: achow101: ACKce90f0c99f
rkrux: utACKce90f0c99f
Tree-SHA512: 9229ad9dda9ff1dece73b5b15a20d69c6ab1ff2c75b2ec430ddbbaeb3467f6a850f53df527bcb4a8114ccbf1aa9c794462d71a8d516aed6f9a9da74edae16feb
This commit is contained in:
@ -356,11 +356,6 @@ RPCHelpMan importdescriptors()
|
||||
// the user could have gotten from another RPC command prior to now
|
||||
wallet.BlockUntilSyncedToCurrentChain();
|
||||
|
||||
// Make sure wallet is a descriptor wallet
|
||||
if (!pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "importdescriptors is not available for non-descriptor wallets");
|
||||
}
|
||||
|
||||
WalletRescanReserver reserver(*pwallet);
|
||||
if (!reserver.reserve(/*with_passphrase=*/true)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Wallet is currently rescanning. Abort existing rescan or wait.");
|
||||
@ -493,10 +488,6 @@ RPCHelpMan listdescriptors()
|
||||
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
||||
if (!wallet) return UniValue::VNULL;
|
||||
|
||||
if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "listdescriptors is not available for non-descriptor wallets");
|
||||
}
|
||||
|
||||
const bool priv = !request.params[0].isNull() && request.params[0].get_bool();
|
||||
if (priv) {
|
||||
EnsureWalletIsUnlocked(*wallet);
|
||||
|
@ -763,10 +763,6 @@ RPCHelpMan gethdkeys()
|
||||
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
|
||||
if (!wallet) return UniValue::VNULL;
|
||||
|
||||
if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "gethdkeys is not available for non-descriptor wallets");
|
||||
}
|
||||
|
||||
LOCK(wallet->cs_wallet);
|
||||
|
||||
UniValue options{request.params[0].isNull() ? UniValue::VOBJ : request.params[0]};
|
||||
@ -865,11 +861,6 @@ static RPCHelpMan createwalletdescriptor()
|
||||
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
|
||||
if (!pwallet) return UniValue::VNULL;
|
||||
|
||||
// Make sure wallet is a descriptor wallet
|
||||
if (!pwallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "createwalletdescriptor is not available for non-descriptor wallets");
|
||||
}
|
||||
|
||||
std::optional<OutputType> output_type = ParseOutputType(request.params[0].get_str());
|
||||
if (!output_type) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address type '%s'", request.params[0].get_str()));
|
||||
|
@ -112,12 +112,6 @@ public:
|
||||
*/
|
||||
virtual std::vector<WalletDestination> MarkUnusedAddresses(const CScript& script) { return {}; }
|
||||
|
||||
/** Sets up the key generation stuff, i.e. generates new HD seeds and sets them as active.
|
||||
* Returns false if already setup or setup fails, true if setup is successful
|
||||
* Set force=true to make it re-setup if already setup, used for upgrades
|
||||
*/
|
||||
virtual bool SetupGeneration(bool force = false) { return false; }
|
||||
|
||||
/* Returns true if HD is enabled */
|
||||
virtual bool IsHDEnabled() const { return false; }
|
||||
|
||||
|
@ -288,11 +288,6 @@ std::shared_ptr<CWallet> 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<CWallet> 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<CWallet> 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<CWallet> 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<CWallet> 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,7 @@ std::shared_ptr<CWallet> 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();
|
||||
}
|
||||
|
||||
if (chain) {
|
||||
|
Reference in New Issue
Block a user