Skip to content

Commit 2e97541

Browse files
committed
Merge bitcoin/bitcoin#32944: wallet: Remove upgradewallet RPC
d89c6fa wallet: Remove `upgradewallet` RPC (w0xlt) Pull request description: Based on discussions in bitcoin/bitcoin#32803, this PR proposes removing the ` upgradewallet` RPC. ACKs for top commit: maflcko: review ACK d89c6fa 🤙 achow101: ACK d89c6fa pablomartin4btc: ACK d89c6fa brunoerg: Concept & light cr ACK d89c6fa Tree-SHA512: 9ab89c9137ff83d7826da6b9d00d3617149a5d144129086a2685ee525087534c5ed06259075c0689ded52d33e075acb5067d185be04ecc638e27469f958f9a56
2 parents b08041c + d89c6fa commit 2e97541

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
@@ -490,69 +490,6 @@ static RPCHelpMan unloadwallet()
490490
};
491491
}
492492

493-
static RPCHelpMan upgradewallet()
494-
{
495-
return RPCHelpMan{
496-
"upgradewallet",
497-
"Upgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
498-
"New keys may be generated and a new wallet backup will need to be made.",
499-
{
500-
{"version", RPCArg::Type::NUM, RPCArg::Default{int{FEATURE_LATEST}}, "The version number to upgrade to. Default is the latest wallet version."}
501-
},
502-
RPCResult{
503-
RPCResult::Type::OBJ, "", "",
504-
{
505-
{RPCResult::Type::STR, "wallet_name", "Name of wallet this operation was performed on"},
506-
{RPCResult::Type::NUM, "previous_version", "Version of wallet before this operation"},
507-
{RPCResult::Type::NUM, "current_version", "Version of wallet after this operation"},
508-
{RPCResult::Type::STR, "result", /*optional=*/true, "Description of result, if no error"},
509-
{RPCResult::Type::STR, "error", /*optional=*/true, "Error message (if there is one)"}
510-
},
511-
},
512-
RPCExamples{
513-
HelpExampleCli("upgradewallet", "169900")
514-
+ HelpExampleRpc("upgradewallet", "169900")
515-
},
516-
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
517-
{
518-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
519-
if (!pwallet) return UniValue::VNULL;
520-
521-
EnsureWalletIsUnlocked(*pwallet);
522-
523-
int version = 0;
524-
if (!request.params[0].isNull()) {
525-
version = request.params[0].getInt<int>();
526-
}
527-
bilingual_str error;
528-
const int previous_version{pwallet->GetVersion()};
529-
const bool wallet_upgraded{pwallet->UpgradeWallet(version, error)};
530-
const int current_version{pwallet->GetVersion()};
531-
std::string result;
532-
533-
if (wallet_upgraded) {
534-
if (previous_version == current_version) {
535-
result = "Already at latest version. Wallet version unchanged.";
536-
} else {
537-
result = strprintf("Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
538-
}
539-
}
540-
541-
UniValue obj(UniValue::VOBJ);
542-
obj.pushKV("wallet_name", pwallet->GetName());
543-
obj.pushKV("previous_version", previous_version);
544-
obj.pushKV("current_version", current_version);
545-
if (!result.empty()) {
546-
obj.pushKV("result", result);
547-
} else {
548-
CHECK_NONFATAL(!error.empty());
549-
obj.pushKV("error", error.original);
550-
}
551-
return obj;
552-
},
553-
};
554-
}
555-
556493
RPCHelpMan simulaterawtransaction()
557494
{
558495
return RPCHelpMan{
@@ -1025,7 +962,6 @@ std::span<const CRPCCommand> GetWalletRPCCommands()
1025962
{"wallet", &simulaterawtransaction},
1026963
{"wallet", &sendall},
1027964
{"wallet", &unloadwallet},
1028-
{"wallet", &upgradewallet},
1029965
{"wallet", &walletcreatefundedpsbt},
1030966
#ifdef ENABLE_EXTERNAL_SIGNER
1031967
{"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
@@ -3194,39 +3194,6 @@ const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest
31943194
return &address_book_it->second;
31953195
}
31963196

3197-
bool CWallet::UpgradeWallet(int version, bilingual_str& error)
3198-
{
3199-
int prev_version = GetVersion();
3200-
if (version == 0) {
3201-
WalletLogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
3202-
version = FEATURE_LATEST;
3203-
} else {
3204-
WalletLogPrintf("Allowing wallet upgrade up to %i\n", version);
3205-
}
3206-
if (version < prev_version) {
3207-
error = strprintf(_("Cannot downgrade wallet from version %i to version %i. Wallet version unchanged."), prev_version, version);
3208-
return false;
3209-
}
3210-
3211-
LOCK(cs_wallet);
3212-
3213-
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
3214-
if (!CanSupportFeature(FEATURE_HD_SPLIT) && version >= FEATURE_HD_SPLIT && version < FEATURE_PRE_SPLIT_KEYPOOL) {
3215-
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);
3216-
return false;
3217-
}
3218-
3219-
// Permanently upgrade to the version
3220-
SetMinVersion(GetClosestWalletFeature(version));
3221-
3222-
for (auto spk_man : GetActiveScriptPubKeyMans()) {
3223-
if (!spk_man->Upgrade(prev_version, version, error)) {
3224-
return false;
3225-
}
3226-
}
3227-
return true;
3228-
}
3229-
32303197
void CWallet::postInitProcess()
32313198
{
32323199
// 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
@@ -945,9 +945,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
945945
LogInfo("%s %s", GetDisplayName(), tfm::format(wallet_fmt, params...));
946946
};
947947

948-
/** Upgrade the wallet */
949-
bool UpgradeWallet(int version, bilingual_str& error);
950-
951948
//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers
952949
std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
953950
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)