@ -11,6 +11,7 @@
@@ -11,6 +11,7 @@
# include <protocol.h>
# include <util.h>
# include <utilstrencodings.h>
# include <wallet/walletutil.h>
# include <stdint.h>
@ -257,7 +258,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco
@@ -257,7 +258,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco
return fSuccess ;
}
bool CDB : : VerifyEnvironment ( const std : : string & walletFile , const fs : : path & data Dir, std : : string & errorStr )
bool CDB : : VerifyEnvironment ( const std : : string & walletFile , const fs : : path & wallet Dir, std : : string & errorStr )
{
LogPrintf ( " Using BerkeleyDB version %s \n " , DbEnv : : version ( 0 , 0 , 0 ) ) ;
LogPrintf ( " Using wallet %s \n " , walletFile ) ;
@ -265,15 +266,15 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataD
@@ -265,15 +266,15 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataD
// Wallet file must be a plain filename without a directory
if ( walletFile ! = fs : : basename ( walletFile ) + fs : : extension ( walletFile ) )
{
errorStr = strprintf ( _ ( " Wallet %s resides outside data directory %s " ) , walletFile , data Dir. string ( ) ) ;
errorStr = strprintf ( _ ( " Wallet %s resides outside wallet directory %s " ) , walletFile , wallet Dir. string ( ) ) ;
return false ;
}
if ( ! bitdb . Open ( data Dir) )
if ( ! bitdb . Open ( wallet Dir) )
{
// try moving the database env out of the way
fs : : path pathDatabase = data Dir / " database " ;
fs : : path pathDatabaseBak = data Dir / strprintf ( " database.%d.bak " , GetTime ( ) ) ;
fs : : path pathDatabase = wallet Dir / " database " ;
fs : : path pathDatabaseBak = wallet Dir / strprintf ( " database.%d.bak " , GetTime ( ) ) ;
try {
fs : : rename ( pathDatabase , pathDatabaseBak ) ;
LogPrintf ( " Moved old %s to %s. Retrying. \n " , pathDatabase . string ( ) , pathDatabaseBak . string ( ) ) ;
@ -282,18 +283,18 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataD
@@ -282,18 +283,18 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataD
}
// try again
if ( ! bitdb . Open ( data Dir) ) {
if ( ! bitdb . Open ( wallet Dir) ) {
// if it still fails, it probably means we can't even create the database env
errorStr = strprintf ( _ ( " Error initializing wallet database environment %s! " ) , GetDataDir ( ) ) ;
errorStr = strprintf ( _ ( " Error initializing wallet database environment %s! " ) , walletDir ) ;
return false ;
}
}
return true ;
}
bool CDB : : VerifyDatabaseFile ( const std : : string & walletFile , const fs : : path & data Dir, std : : string & warningStr , std : : string & errorStr , CDBEnv : : recoverFunc_type recoverFunc )
bool CDB : : VerifyDatabaseFile ( const std : : string & walletFile , const fs : : path & wallet Dir, std : : string & warningStr , std : : string & errorStr , CDBEnv : : recoverFunc_type recoverFunc )
{
if ( fs : : exists ( data Dir / walletFile ) )
if ( fs : : exists ( wallet Dir / walletFile ) )
{
std : : string backup_filename ;
CDBEnv : : VerifyResult r = bitdb . Verify ( walletFile , recoverFunc , backup_filename ) ;
@ -303,7 +304,7 @@ bool CDB::VerifyDatabaseFile(const std::string& walletFile, const fs::path& data
@@ -303,7 +304,7 @@ bool CDB::VerifyDatabaseFile(const std::string& walletFile, const fs::path& data
" Original %s saved as %s in %s; if "
" your balance or transactions are incorrect you should "
" restore from a backup. " ) ,
walletFile , backup_filename , data Dir) ;
walletFile , backup_filename , wallet Dir) ;
}
if ( r = = CDBEnv : : RECOVER_FAIL )
{
@ -407,7 +408,7 @@ CDB::CDB(CWalletDBWrapper& dbw, const char* pszMode, bool fFlushOnCloseIn) : pdb
@@ -407,7 +408,7 @@ CDB::CDB(CWalletDBWrapper& dbw, const char* pszMode, bool fFlushOnCloseIn) : pdb
{
LOCK ( env - > cs_db ) ;
if ( ! env - > Open ( GetData Dir ( ) ) )
if ( ! env - > Open ( GetWallet Dir ( ) ) )
throw std : : runtime_error ( " CDB: Failed to open database environment. " ) ;
pdb = env - > mapDb [ strFilename ] ;
@ -695,7 +696,7 @@ bool CWalletDBWrapper::Backup(const std::string& strDest)
@@ -695,7 +696,7 @@ bool CWalletDBWrapper::Backup(const std::string& strDest)
env - > mapFileUseCount . erase ( strFile ) ;
// Copy wallet file
fs : : path pathSrc = GetData Dir ( ) / strFile ;
fs : : path pathSrc = GetWallet Dir ( ) / strFile ;
fs : : path pathDest ( strDest ) ;
if ( fs : : is_directory ( pathDest ) )
pathDest / = strFile ;