From: alex Date: Sun, 28 Jul 2013 16:29:39 +0000 (+0400) Subject: Allow user to select wallet file (-waller=walletfilename.dat) X-Git-Tag: v0.4.4-pre~5 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=9877a9452c925ea8b134907500829fd3376fd60f Allow user to select wallet file (-waller=walletfilename.dat) --- diff --git a/src/init.cpp b/src/init.cpp index f22dbc2..199e3fa 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -26,6 +26,7 @@ using namespace boost; CWallet* pwalletMain; CClientUIInterface uiInterface; +std::string strWalletFileName; ////////////////////////////////////////////////////////////////////////////// // @@ -224,6 +225,7 @@ std::string HelpMessage() " -gen " + _("Generate coins") + "\n" + " -gen=0 " + _("Don't generate coins") + "\n" + " -datadir= " + _("Specify data directory") + "\n" + + " -wallet= " + _("Specify wallet file (within data directory)") + "\n" + " -dbcache= " + _("Set database cache size in megabytes (default: 25)") + "\n" + " -dblogsize= " + _("Set database disk log size in megabytes (default: 100)") + "\n" + " -timeout= " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" + @@ -443,6 +445,11 @@ bool AppInit2() // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log std::string strDataDir = GetDataDir().string(); + std::string strWalletFileName = GetArg("-wallet", "wallet.dat"); + + // strWalletFileName must be a plain filename without a directory + if (strWalletFileName != boost::filesystem::basename(strWalletFileName) + boost::filesystem::extension(strWalletFileName)) + return InitError(strprintf(_("Wallet %s resides outside data directory %s."), strWalletFileName.c_str(), strDataDir.c_str())); // Make sure only a single Bitcoin process is using the data directory. boost::filesystem::path pathLockFile = GetDataDir() / ".lock"; @@ -505,13 +512,13 @@ bool AppInit2() if (GetBoolArg("-salvagewallet")) { // Recover readable keypairs: - if (!CWalletDB::Recover(bitdb, "wallet.dat", true)) + if (!CWalletDB::Recover(bitdb, strWalletFileName, true)) return false; } - if (filesystem::exists(GetDataDir() / "wallet.dat")) + if (filesystem::exists(GetDataDir() / strWalletFileName)) { - CDBEnv::VerifyResult r = bitdb.Verify("wallet.dat", CWalletDB::Recover); + CDBEnv::VerifyResult r = bitdb.Verify(strWalletFileName, CWalletDB::Recover); if (r == CDBEnv::RECOVER_OK) { string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!" @@ -715,7 +722,7 @@ bool AppInit2() printf("Loading wallet...\n"); nStart = GetTimeMillis(); bool fFirstRun = true; - pwalletMain = new CWallet("wallet.dat"); + pwalletMain = new CWallet(strWalletFileName); DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun); if (nLoadWalletRet != DB_LOAD_OK) { @@ -778,7 +785,7 @@ bool AppInit2() pindexRescan = pindexGenesisBlock; else { - CWalletDB walletdb("wallet.dat"); + CWalletDB walletdb(strWalletFileName); CBlockLocator locator; if (walletdb.ReadBestBlock(locator)) pindexRescan = locator.GetBlockIndex(); diff --git a/src/init.h b/src/init.h index 8308ee6..84f2712 100644 --- a/src/init.h +++ b/src/init.h @@ -8,7 +8,7 @@ #include "wallet.h" extern CWallet* pwalletMain; - +extern std::string strWalletFileName; void StartShutdown(); void Shutdown(void* parg); bool AppInit2(); diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index 66d6ecf..dcc5c8d 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -2164,6 +2164,11 @@ Address: %4 Don't generate coins + + Specify wallet file (within data directory) + Specify wallet file (within data directory) + + Specify data directory Specify data directory @@ -2539,6 +2544,11 @@ Address: %4 This help message + + Wallet %s resides outside data directory %s. + Wallet %s resides outside data directory %s. + + Cannot obtain a lock on data directory %s. NovaCoin is probably already running. Cannot obtain a lock on data directory %s. NovaCoin is probably already running. diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 651664e..ff84d5e 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -2166,6 +2166,11 @@ Address: %4 Указать pid-файл (по умолчанию: novacoin.pid) + + Specify wallet file (within data directory) + Указать файл кошелька (в пределах DATA директории) + + Generate coins Генерировать монеты @@ -2243,7 +2248,7 @@ Address: %4 Error initializing database environment %s! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat. - + Ошибка инициализации окружения БД %s! Для восстановления СДЕЛАЙТЕ РЕЗЕРВНУЮ КОПИЮ этой директории, затем удалите из нее все, кроме wallet.dat. @@ -2459,7 +2464,7 @@ Address: %4 Verifying database integrity... - + Проверка целостности базы данных... @@ -2474,7 +2479,7 @@ Address: %4 wallet.dat corrupt, salvage failed - + wallet.dat поврежден, восстановление не удалось @@ -2552,6 +2557,11 @@ Address: %4 Эта справка + + Wallet %s resides outside data directory %s. + Кошелек %s находится вне рабочей директории %s. + + Cannot obtain a lock on data directory %s. NovaCoin is probably already running. Невозможно установить блокировку на рабочую директорию %s. Возможно, бумажник уже запущен. diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 756fe61..68d09cb 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -72,7 +72,7 @@ bool OptionsModel::Upgrade() settings.setValue("bImportFinished", true); // Move settings from old wallet.dat (if any): - CWalletDB walletdb("wallet.dat"); + CWalletDB walletdb(strWalletFileName); QList intOptions; intOptions << "nDisplayUnit" << "nTransactionFee";