Allow user to select wallet file (-waller=walletfilename.dat)
authoralex <alex@alex-VirtualBox.(none)>
Sun, 28 Jul 2013 16:29:39 +0000 (20:29 +0400)
committeralex <alex@alex-VirtualBox.(none)>
Sun, 28 Jul 2013 16:29:39 +0000 (20:29 +0400)
src/init.cpp
src/init.h
src/qt/locale/bitcoin_en.ts
src/qt/locale/bitcoin_ru.ts
src/qt/optionsmodel.cpp

index f22dbc2..199e3fa 100644 (file)
@@ -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=<dir>         " + _("Specify data directory") + "\n" +
+        "  -wallet=<dir>          " + _("Specify wallet file (within data directory)") + "\n" +
         "  -dbcache=<n>           " + _("Set database cache size in megabytes (default: 25)") + "\n" +
         "  -dblogsize=<n>         " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
         "  -timeout=<n>           " + _("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();
index 8308ee6..84f2712 100644 (file)
@@ -8,7 +8,7 @@
 #include "wallet.h"
 
 extern CWallet* pwalletMain;
-
+extern std::string strWalletFileName;
 void StartShutdown();
 void Shutdown(void* parg);
 bool AppInit2();
index 66d6ecf..dcc5c8d 100644 (file)
@@ -2164,6 +2164,11 @@ Address: %4
         <translation>Don&apos;t generate coins</translation>
     </message>
     <message>
+        <location line="-17"/>
+        <source>Specify wallet file (within data directory)</source>
+        <translation>Specify wallet file (within data directory)</translation>
+    </message>
+    <message>
         <location line="+60"/>
         <source>Specify data directory</source>
         <translation>Specify data directory</translation>
@@ -2539,6 +2544,11 @@ Address: %4
         <translation>This help message</translation>
     </message>
     <message>
+        <location line="-122"/>
+        <source>Wallet %s resides outside data directory %s.</source>
+        <translation>Wallet %s resides outside data directory %s.</translation>
+    </message>
+    <message>
         <location line="-131"/>
         <source>Cannot obtain a lock on data directory %s.  NovaCoin is probably already running.</source>
         <translation>Cannot obtain a lock on data directory %s.  NovaCoin is probably already running.</translation>
index 651664e..ff84d5e 100644 (file)
@@ -2166,6 +2166,11 @@ Address: %4
         <translation>Указать pid-файл (по умолчанию: novacoin.pid)</translation>
     </message>
     <message>
+        <location line="-17"/>
+        <source>Specify wallet file (within data directory)</source>
+        <translation>Указать файл кошелька (в пределах DATA директории)</translation>
+    </message>
+    <message>
         <location line="-47"/>
         <source>Generate coins</source>
         <translation>Генерировать монеты</translation>
@@ -2243,7 +2248,7 @@ Address: %4
     <message>
         <location line="+2"/>
         <source>Error initializing database environment %s! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat.</source>
-        <translation type="unfinished"></translation>
+        <translation>Ошибка инициализации окружения БД %s! Для восстановления СДЕЛАЙТЕ РЕЗЕРВНУЮ КОПИЮ этой директории, затем удалите из нее все, кроме wallet.dat.</translation>
     </message>
     <message>
         <location line="+13"/>
@@ -2459,7 +2464,7 @@ Address: %4
     <message>
         <location line="+1"/>
         <source>Verifying database integrity...</source>
-        <translation type="unfinished"></translation>
+        <translation>Проверка целостности базы данных...</translation>
     </message>
     <message>
         <location line="+2"/>
@@ -2474,7 +2479,7 @@ Address: %4
     <message>
         <location line="+1"/>
         <source>wallet.dat corrupt, salvage failed</source>
-        <translation type="unfinished"></translation>
+        <translation>wallet.dat поврежден, восстановление не удалось</translation>
     </message>
     <message>
         <location line="-43"/>
@@ -2552,6 +2557,11 @@ Address: %4
         <translation>Эта справка</translation>
     </message>
     <message>
+        <location line="-122"/>
+        <source>Wallet %s resides outside data directory %s.</source>
+        <translation>Кошелек %s находится вне рабочей директории %s.</translation>
+    </message>
+    <message>
         <location line="-131"/>
         <source>Cannot obtain a lock on data directory %s.  NovaCoin is probably already running.</source>
         <translation>Невозможно установить блокировку на рабочую директорию %s.  Возможно, бумажник уже запущен.</translation>
index 756fe61..68d09cb 100644 (file)
@@ -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<QString> intOptions;
     intOptions << "nDisplayUnit" << "nTransactionFee";