X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Finit.cpp;h=4078b7e0cb27a111afd2d6d9fe6c17c8004f2962;hp=603022e1e0fdbdbb273efa3fbb589d355313f52d;hb=439e1497e130914c2b78eff20c38046d6b1b6d49;hpb=4a17e3e6b947d6ede40e49f77244d880240240cd diff --git a/src/init.cpp b/src/init.cpp index 603022e..4078b7e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -222,6 +222,7 @@ bool AppInit2(int argc, char* argv[]) " -rpcallowip= \t\t " + _("Allow JSON-RPC connections from specified IP address") + "\n" + " -rpcconnect= \t " + _("Send commands to node running on (default: 127.0.0.1)") + "\n" + " -blocknotify= " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" + + " -upgradewallet \t " + _("Upgrade wallet to latest format") + "\n" + " -keypool= \t " + _("Set key pool size to (default: 100)") + "\n" + " -rescan \t " + _("Rescan the block chain for missing wallet transactions") + "\n" + " -checkblocks= \t\t " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" + @@ -380,6 +381,36 @@ bool AppInit2(int argc, char* argv[]) else strErrors << _("Error loading wallet.dat") << "\n"; } + + if (GetBoolArg("-upgradewallet", fFirstRun)) + { + int nMaxVersion = GetArg("-upgradewallet", 0); + if (nMaxVersion == 0) // the -walletupgrade without argument case + { + printf("Performing wallet upgrade to %i\n", FEATURE_LATEST); + nMaxVersion = CLIENT_VERSION; + pwalletMain->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately + } + else + printf("Allowing wallet upgrade up to %i\n", nMaxVersion); + if (nMaxVersion < pwalletMain->GetVersion()) + strErrors << _("Cannot downgrade wallet") << "\n"; + pwalletMain->SetMaxVersion(nMaxVersion); + } + + if (fFirstRun) + { + // Create new keyUser and set as default key + RandAddSeedPerfmon(); + + std::vector newDefaultKey; + if (!pwalletMain->GetKeyFromPool(newDefaultKey, false)) + strErrors << _("Cannot initialize keypool") << "\n"; + pwalletMain->SetDefaultKey(newDefaultKey); + if (!pwalletMain->SetAddressBookName(CBitcoinAddress(pwalletMain->vchDefaultKey), "")) + strErrors << _("Cannot write default address") << "\n"; + } + printf("%s", strErrors.str().c_str()); printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);