@@ -3831,7 +3831,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
38313831 }
38323832
38333833 if (gArgs .GetBoolArg (" -upgradewallet" , false )) {
3834- if (!UpgradeWallet (walletInstance, gArgs .GetBoolArg (" -upgradewallet" , 0 ), error, warnings)) {
3834+ if (!UpgradeWallet (gArgs .GetBoolArg (" -upgradewallet" , 0 ), error, warnings)) {
38353835 return nullptr ;
38363836 }
38373837 }
@@ -4097,38 +4097,37 @@ const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest
40974097 return &address_book_it->second ;
40984098}
40994099
4100- bool CWallet::UpgradeWallet (std::shared_ptr<CWallet> walletInstance, int version, std::string& error, std::vector<std::string>& warnings)
4100+ bool CWallet::UpgradeWallet (int version, std::string& error, std::vector<std::string>& warnings)
41014101{
4102- int prev_version = walletInstance-> GetVersion ();
4102+ int prev_version = GetVersion ();
41034103 int nMaxVersion = version;
41044104 if (nMaxVersion == 0 ) // the -upgradewallet without argument case
41054105 {
4106- walletInstance-> WalletLogPrintf (" Performing wallet upgrade to %i\n " , FEATURE_LATEST);
4106+ WalletLogPrintf (" Performing wallet upgrade to %i\n " , FEATURE_LATEST);
41074107 nMaxVersion = FEATURE_LATEST;
4108- walletInstance-> SetMinVersion (FEATURE_LATEST); // permanently upgrade the wallet immediately
4108+ SetMinVersion (FEATURE_LATEST); // permanently upgrade the wallet immediately
41094109 }
41104110 else
4111- walletInstance-> WalletLogPrintf (" Allowing wallet upgrade up to %i\n " , nMaxVersion);
4112- if (nMaxVersion < walletInstance-> GetVersion ())
4111+ WalletLogPrintf (" Allowing wallet upgrade up to %i\n " , nMaxVersion);
4112+ if (nMaxVersion < GetVersion ())
41134113 {
41144114 error = _ (" Cannot downgrade wallet" ).translated ;
41154115 return false ;
41164116 }
4117- walletInstance-> SetMaxVersion (nMaxVersion);
4117+ SetMaxVersion (nMaxVersion);
41184118
4119- LOCK (walletInstance-> cs_wallet );
4119+ LOCK (cs_wallet);
41204120
41214121 // Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
4122- int max_version = walletInstance-> GetVersion ();
4123- if (!walletInstance-> CanSupportFeature (FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
4122+ int max_version = GetVersion ();
4123+ if (!CanSupportFeature (FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
41244124 error = _ (" Cannot upgrade a non HD split wallet without upgrading to support pre split keypool. Please use -upgradewallet=169900 or -upgradewallet with no version specified." ).translated ;
41254125 return false ;
41264126 }
41274127
4128- for (auto spk_man : walletInstance->GetActiveScriptPubKeyMans ()) {
4129- if (!spk_man->Upgrade (prev_version, error)) {
4130- return false ;
4131- }
4128+ for (auto spk_man : GetActiveScriptPubKeyMans ()) {
4129+ if (!spk_man->Upgrade (prev_version, error)) {
4130+ return false ;
41324131 }
41334132 }
41344133 return true ;
0 commit comments