MCPcopy Create free account
hub / github.com/ElementsProject/elements / UpgradeWallet

Method UpgradeWallet

src/wallet/wallet.cpp:3261–3292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3259}
3260
3261bool CWallet::UpgradeWallet(int version, bilingual_str& error)
3262{
3263 int prev_version = GetVersion();
3264 if (version == 0) {
3265 WalletLogPrintf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
3266 version = FEATURE_LATEST;
3267 } else {
3268 WalletLogPrintf("Allowing wallet upgrade up to %i\n", version);
3269 }
3270 if (version < prev_version) {
3271 error = strprintf(_("Cannot downgrade wallet from version %i to version %i. Wallet version unchanged."), prev_version, version);
3272 return false;
3273 }
3274
3275 LOCK(cs_wallet);
3276
3277 // Do not upgrade versions to any version between HD_SPLIT and FEATURE_PRE_SPLIT_KEYPOOL unless already supporting HD_SPLIT
3278 if (!CanSupportFeature(FEATURE_HD_SPLIT) && version >= FEATURE_HD_SPLIT && version < FEATURE_PRE_SPLIT_KEYPOOL) {
3279 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);
3280 return false;
3281 }
3282
3283 // Permanently upgrade to the version
3284 SetMinVersion(GetClosestWalletFeature(version));
3285
3286 for (auto spk_man : GetActiveScriptPubKeyMans()) {
3287 if (!spk_man->Upgrade(prev_version, version, error)) {
3288 return false;
3289 }
3290 }
3291 return true;
3292}
3293
3294void CWallet::postInitProcess()
3295{

Callers 1

upgradewalletFunction · 0.80

Calls 3

_Function · 0.85
GetClosestWalletFeatureFunction · 0.85
UpgradeMethod · 0.45

Tested by

no test coverage detected