X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Finit.cpp;h=199e3fae9ab576ecf8880b9bfa5d73ff2000ddf3;hb=9877a9452c925ea8b134907500829fd3376fd60f;hp=f22dbc2dfef3a97329b6820986f977ec4ee58d58;hpb=474998b61ff01d5c0d4dcf03474ab6ec772fbe08;p=novacoin.git
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();