mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00
Make UpgradeWallet a member function of CWallet
This commit is contained in:
parent
c988f27937
commit
1e48796c99
@ -3831,7 +3831,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gArgs.GetBoolArg("-upgradewallet", false)) {
|
if (gArgs.GetBoolArg("-upgradewallet", false)) {
|
||||||
if (!UpgradeWallet(walletInstance, gArgs.GetBoolArg("-upgradewallet", 0), error, warnings)) {
|
if (!UpgradeWallet(gArgs.GetBoolArg("-upgradewallet", 0), error, warnings)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4097,38 +4097,37 @@ const CAddressBookData* CWallet::FindAddressBookEntry(const CTxDestination& dest
|
|||||||
return &address_book_it->second;
|
return &address_book_it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWallet::UpgradeWallet(std::shared_ptr<CWallet> walletInstance, int version, std::string& error, std::vector<std::string>& warnings)
|
bool CWallet::UpgradeWallet(int version, std::string& error, std::vector<std::string>& warnings)
|
||||||
{
|
{
|
||||||
int prev_version = walletInstance->GetVersion();
|
int prev_version = GetVersion();
|
||||||
int nMaxVersion = version;
|
int nMaxVersion = version;
|
||||||
if (nMaxVersion == 0) // the -upgradewallet without argument case
|
if (nMaxVersion == 0) // the -upgradewallet without argument case
|
||||||
{
|
{
|
||||||
walletInstance->WalletLogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
|
WalletLogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
|
||||||
nMaxVersion = FEATURE_LATEST;
|
nMaxVersion = FEATURE_LATEST;
|
||||||
walletInstance->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately
|
SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
walletInstance->WalletLogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion);
|
WalletLogPrintf("Allowing wallet upgrade up to %i\n", nMaxVersion);
|
||||||
if (nMaxVersion < walletInstance->GetVersion())
|
if (nMaxVersion < GetVersion())
|
||||||
{
|
{
|
||||||
error = _("Cannot downgrade wallet").translated;
|
error = _("Cannot downgrade wallet").translated;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
walletInstance->SetMaxVersion(nMaxVersion);
|
SetMaxVersion(nMaxVersion);
|
||||||
|
|
||||||
LOCK(walletInstance->cs_wallet);
|
LOCK(cs_wallet);
|
||||||
|
|
||||||
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
|
// Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
|
||||||
int max_version = walletInstance->GetVersion();
|
int max_version = GetVersion();
|
||||||
if (!walletInstance->CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
|
if (!CanSupportFeature(FEATURE_HD_SPLIT) && max_version >= FEATURE_HD_SPLIT && max_version < FEATURE_PRE_SPLIT_KEYPOOL) {
|
||||||
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;
|
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;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto spk_man : walletInstance->GetActiveScriptPubKeyMans()) {
|
for (auto spk_man : GetActiveScriptPubKeyMans()) {
|
||||||
if (!spk_man->Upgrade(prev_version, error)) {
|
if (!spk_man->Upgrade(prev_version, error)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1176,7 +1176,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Upgrade the wallet */
|
/** Upgrade the wallet */
|
||||||
static bool UpgradeWallet(std::shared_ptr<CWallet> wallet, int version, std::string& error, std::vector<std::string>& warnings);
|
bool UpgradeWallet(int version, std::string& error, std::vector<std::string>& warnings);
|
||||||
|
|
||||||
//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers
|
//! Returns all unique ScriptPubKeyMans in m_internal_spk_managers and m_external_spk_managers
|
||||||
std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
|
std::set<ScriptPubKeyMan*> GetActiveScriptPubKeyMans() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user