Skip to content

Commit d89c6fa

Browse files
committed
wallet: Remove upgradewallet RPC
1 parent 5ef0d48 commit d89c6fa

File tree

7 files changed

+3
-107
lines changed

7 files changed

+3
-107
lines changed

doc/release-notes-32944.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# RPC
2+
3+
`upgradewallet` has been removed. It was unused and only applied to unsupported legacy wallets.

src/rpc/client.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ static const CRPCConvertParam vRPCConvertParams[] =
275275
{ "logging", 0, "include" },
276276
{ "logging", 1, "exclude" },
277277
{ "disconnectnode", 1, "nodeid" },
278-
{ "upgradewallet", 0, "version" },
279278
{ "gethdkeys", 0, "active_only" },
280279
{ "gethdkeys", 0, "options" },
281280
{ "gethdkeys", 0, "private" },

src/wallet/rpc/wallet.cpp

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -497,69 +497,6 @@ static RPCHelpMan unloadwallet()
497497
};
498498
}
499499

500-
static RPCHelpMan upgradewallet()
501-
{
502-
return RPCHelpMan{
503-
"upgradewallet",
504-
"Upgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
505-
"New keys may be generated and a new wallet backup will need to be made.",
506-
{
507-
{"version", RPCArg::Type::NUM, RPCArg::Default{int{FEATURE_LATEST}}, "The version number to upgrade to. Default is the latest wallet version."}
508-
},
509-
RPCResult{
510-
RPCResult::Type::OBJ, "", "",
511-
{
512-
{RPCResult::Type::STR, "wallet_name", "Name of wallet this operation was performed on"},
513-
{RPCResult::Type::NUM, "previous_version", "Version of wallet before this operation"},
514-
{RPCResult::Type::NUM, "current_version", "Version of wallet after this operation"},
515-
{RPCResult::Type::STR, "result", /*optional=*/true, "Description of result, if no error"},
516-
{RPCResult::Type::STR, "error", /*optional=*/true, "Error message (if there is one)"}
517-
},
518-
},
519-
RPCExamples{
520-
HelpExampleCli("upgradewallet", "169900")
521-
+ HelpExampleRpc("upgradewallet", "169900")
522-
},
523-
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
524-
{
525-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
526-
if (!pwallet) return UniValue::VNULL;
527-
528-
EnsureWalletIsUnlocked(*pwallet);
529-
530-
int version = 0;
531-
if (!request.params[0].isNull()) {
532-
version = request.params[0].getInt<int>();
533-
}
534-
bilingual_str error;
535-
const int previous_version{pwallet->GetVersion()};
536-
const bool wallet_upgraded{pwallet->UpgradeWallet(version, error)};
537-
const int current_version{pwallet->GetVersion()};
538-
std::string result;
539-
540-
if (wallet_upgraded) {
541-
if (previous_version == current_version) {
542-
result = "Already at latest version. Wallet version unchanged.";
543-
} else {
544-
result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
545-
}
546-
}
547-
548-
UniValue obj(UniValue::VOBJ);
549-
obj.pushKV("wallet_name", pwallet->GetName());
550-
obj.pushKV("previous_version", previous_version);
551-
obj.pushKV("current_version", current_version);
552-
if (!result.empty()) {
553-
obj.pushKV("result", result);
554-
} else {
555-
CHECK_NONFATAL(!error.empty());
556-
obj.pushKV("error", error.original);
557-
}
558-
return obj;
559-
},
560-
};
561-
}
562-
563500
RPCHelpMan simulaterawtransaction()
564501
{
565502
return RPCHelpMan{
@@ -1042,7 +979,6 @@ std::span<const CRPCCommand> GetWalletRPCCommands()
1042979
{"wallet", &simulaterawtransaction},
1043980
{"wallet", &sendall},
1044981
{"wallet", &unloadwallet},
1045-
{"wallet", &upgradewallet},
1046982
{"wallet", &walletcreatefundedpsbt},
1047983
#ifdef ENABLE_EXTERNAL_SIGNER
1048984
{"wallet", &walletdisplayaddress},

src/wallet/scriptpubkeyman.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ class ScriptPubKeyMan
118118
/* Returns true if the wallet can give out new addresses. This means it has keys in the keypool or can generate new keys */
119119
virtual bool CanGetAddresses(bool internal = false) const { return false; }
120120

121-
/** Upgrades the wallet to the specified version */
122-
virtual bool Upgrade(int prev_version, int new_version, bilingual_str& error) { return true; }
123-
124121
virtual bool HavePrivateKeys() const { return false; }
125122
virtual bool HaveCryptedKeys() const { return false; }
126123

src/wallet/wallet.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,39 +3189,6 @@ const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest
31893189
return &address_book_it->second;
31903190
}
31913191

3192-
bool CWallet::UpgradeWallet(int version, bilingual_str& error)
3193-
{
3194-
int prev_version = GetVersion();
3195-
if (version == 0) {
3196-
WalletLogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
3197-
version = FEATURE_LATEST;
3198-
} else {
3199-
WalletLogPrintf("Allowing wallet upgrade up to %i\n", version);
3200-
}
3201-
if (version < prev_version) {
3202-
error = strprintf(_("Cannot downgrade wallet from version %i to version %i. Wallet version unchanged."), prev_version, version);
3203-
return false;
3204-
}
3205-
3206-
LOCK(cs_wallet);
3207-
3208-
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
3209-
if (!CanSupportFeature(FEATURE_HD_SPLIT) && version >= FEATURE_HD_SPLIT && version < FEATURE_PRE_SPLIT_KEYPOOL) {
3210-
error = strprintf(_("Cannot upgrade a non HD split wallet from version %i to version %i without upgrading to support pre-split keypool. Please use version %i or no version specified."), prev_version, version, FEATURE_PRE_SPLIT_KEYPOOL);
3211-
return false;
3212-
}
3213-
3214-
// Permanently upgrade to the version
3215-
SetMinVersion(GetClosestWalletFeature(version));
3216-
3217-
for (auto spk_man : GetActiveScriptPubKeyMans()) {
3218-
if (!spk_man->Upgrade(prev_version, version, error)) {
3219-
return false;
3220-
}
3221-
}
3222-
return true;
3223-
}
3224-
32253192
void CWallet::postInitProcess()
32263193
{
32273194
// Add wallet transactions that aren't already in a block to mempool

src/wallet/wallet.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
942942
LogInfo("%s %s", GetDisplayName(), tfm::format(wallet_fmt, params...));
943943
};
944944

945-
/** Upgrade the wallet */
946-
bool UpgradeWallet(int version, bilingual_str& error);
947-
948945
//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers
949946
std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
950947
bool IsActiveScriptPubKeyMan(const ScriptPubKeyMan& spkm) const;

test/functional/wallet_multiwallet.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,6 @@ def wallet_file(name):
183183
open(not_a_dir, 'a', encoding="utf8").close()
184184
self.nodes[0].assert_start_raises_init_error(['-walletdir=' + not_a_dir], 'Error: Specified -walletdir "' + not_a_dir + '" is not a directory')
185185

186-
self.log.info("Do not allow -upgradewallet with multiwallet")
187-
self.nodes[0].assert_start_raises_init_error(['-upgradewallet'], "Error: Error parsing command line arguments: Invalid parameter -upgradewallet")
188-
189186
# if wallets/ doesn't exist, datadir should be the default wallet dir
190187
wallet_dir2 = data_dir('walletdir')
191188
os.rename(wallet_dir(), wallet_dir2)

0 commit comments

Comments
 (0)