diff --git a/src/init.cpp b/src/init.cpp index a64d18b7af..16f5ac4e49 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 7199222e47..531dae006d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -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) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 9b78f2301d..ce22d952df 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1042,6 +1042,9 @@ public: /* Wallets parameter interaction */ static bool ParameterInteraction(); + /* Initialize AutoBackup functionality */ + static bool InitAutoBackup(); + bool BackupWallet(const std::string& strDest); /**