Move AutoBackup initialization into CWallet::InitAutoBackup

This commit is contained in:
Alexander Block 2018-01-11 18:39:50 +01:00
parent 205ff3519e
commit 9b1d1c61b2
3 changed files with 28 additions and 14 deletions

View File

@ -1241,20 +1241,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 5: Backup wallet and verify wallet database integrity
#ifdef ENABLE_WALLET
std::string strWarning;
std::string strError;
nWalletBackups = GetArg("-createwalletbackups", 10);
nWalletBackups = std::max(0, std::min(10, nWalletBackups));
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) {
if (!strWarning.empty())
InitWarning(strWarning);
if (!strError.empty())
return InitError(strError);
}
if (!CWallet::InitAutoBackup())
return false;
if (!CWallet::Verify())
return false;

View File

@ -4840,6 +4840,29 @@ bool CWallet::ParameterInteraction()
return true;
}
bool CWallet::InitAutoBackup()
{
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true;
std::string strWarning;
std::string strError;
nWalletBackups = GetArg("-createwalletbackups", 10);
nWalletBackups = std::max(0, std::min(10, nWalletBackups));
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) {
if (!strWarning.empty())
InitWarning(strWarning);
if (!strError.empty())
return InitError(strError);
}
return true;
}
bool CWallet::BackupWallet(const std::string& strDest)
{
if (!fFileBacked)

View File

@ -1042,6 +1042,9 @@ public:
/* Wallets parameter interaction */
static bool ParameterInteraction();
/* Initialize AutoBackup functionality */
static bool InitAutoBackup();
bool BackupWallet(const std::string& strDest);
/**