Merge pull request #1889 from tcatm/multi-wallet
let user select wallet file with -wallet=foo.dat
This commit is contained in:
commit
5e67e124cf
3 changed files with 15 additions and 6 deletions
18
src/init.cpp
18
src/init.cpp
|
@ -29,6 +29,7 @@
|
|||
using namespace std;
|
||||
using namespace boost;
|
||||
|
||||
std::string strWalletFile;
|
||||
CWallet* pwalletMain;
|
||||
CClientUIInterface uiInterface;
|
||||
|
||||
|
@ -169,6 +170,7 @@ std::string HelpMessage()
|
|||
strUsage += " -pid=<file> " + _("Specify pid file (default: bitcoind.pid)") + "\n";
|
||||
strUsage += " -gen " + _("Generate coins (default: 0)") + "\n";
|
||||
strUsage += " -datadir=<dir> " + _("Specify data directory") + "\n";
|
||||
strUsage += " -wallet=<file> " + _("Specify wallet file (within data directory)") + "\n";
|
||||
strUsage += " -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n";
|
||||
strUsage += " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n";
|
||||
strUsage += " -proxy=<ip:port> " + _("Connect through socks proxy") + "\n";
|
||||
|
@ -493,10 +495,16 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
|
||||
}
|
||||
|
||||
strWalletFile = GetArg("-wallet", "wallet.dat");
|
||||
|
||||
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
||||
|
||||
std::string strDataDir = GetDataDir().string();
|
||||
|
||||
// Wallet file must be a plain filename without a directory
|
||||
if (strWalletFile != boost::filesystem::basename(strWalletFile) + boost::filesystem::extension(strWalletFile))
|
||||
return InitError(strprintf(_("Wallet %s resides outside data directory %s\n"), strWalletFile.c_str(), strDataDir.c_str()));
|
||||
|
||||
// Make sure only a single Bitcoin process is using the data directory.
|
||||
boost::filesystem::path pathLockFile = GetDataDir() / ".lock";
|
||||
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
|
||||
|
@ -555,13 +563,13 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
if (GetBoolArg("-salvagewallet", false))
|
||||
{
|
||||
// Recover readable keypairs:
|
||||
if (!CWalletDB::Recover(bitdb, "wallet.dat", true))
|
||||
if (!CWalletDB::Recover(bitdb, strWalletFile, true))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (filesystem::exists(GetDataDir() / "wallet.dat"))
|
||||
if (filesystem::exists(GetDataDir() / strWalletFile))
|
||||
{
|
||||
CDBEnv::VerifyResult r = bitdb.Verify("wallet.dat", CWalletDB::Recover);
|
||||
CDBEnv::VerifyResult r = bitdb.Verify(strWalletFile, CWalletDB::Recover);
|
||||
if (r == CDBEnv::RECOVER_OK)
|
||||
{
|
||||
string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!"
|
||||
|
@ -839,7 +847,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
|
||||
nStart = GetTimeMillis();
|
||||
bool fFirstRun = true;
|
||||
pwalletMain = new CWallet("wallet.dat");
|
||||
pwalletMain = new CWallet(strWalletFile);
|
||||
DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun);
|
||||
if (nLoadWalletRet != DB_LOAD_OK)
|
||||
{
|
||||
|
@ -904,7 +912,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
pindexRescan = pindexGenesisBlock;
|
||||
else
|
||||
{
|
||||
CWalletDB walletdb("wallet.dat");
|
||||
CWalletDB walletdb(strWalletFile);
|
||||
CBlockLocator locator;
|
||||
if (walletdb.ReadBestBlock(locator))
|
||||
pindexRescan = locator.GetBlockIndex();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "wallet.h"
|
||||
|
||||
extern std::string strWalletFile;
|
||||
extern CWallet* pwalletMain;
|
||||
|
||||
void StartShutdown();
|
||||
|
|
|
@ -89,7 +89,7 @@ bool OptionsModel::Upgrade()
|
|||
settings.setValue("bImportFinished", true);
|
||||
|
||||
// Move settings from old wallet.dat (if any):
|
||||
CWalletDB walletdb("wallet.dat");
|
||||
CWalletDB walletdb(strWalletFile);
|
||||
|
||||
QList<QString> intOptions;
|
||||
intOptions << "nDisplayUnit" << "nTransactionFee";
|
||||
|
|
Loading…
Reference in a new issue