Skip to content

Commit 9b1d1c6

Browse files
committed
Move AutoBackup initialization into CWallet::InitAutoBackup
1 parent 205ff35 commit 9b1d1c6

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

src/init.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,20 +1241,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
12411241

12421242
// ********************************************************* Step 5: Backup wallet and verify wallet database integrity
12431243
#ifdef ENABLE_WALLET
1244-
std::string strWarning;
1245-
std::string strError;
1246-
1247-
nWalletBackups = GetArg("-createwalletbackups", 10);
1248-
nWalletBackups = std::max(0, std::min(10, nWalletBackups));
1249-
1250-
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
1251-
1252-
if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) {
1253-
if (!strWarning.empty())
1254-
InitWarning(strWarning);
1255-
if (!strError.empty())
1256-
return InitError(strError);
1257-
}
1244+
if (!CWallet::InitAutoBackup())
1245+
return false;
12581246

12591247
if (!CWallet::Verify())
12601248
return false;

src/wallet/wallet.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4840,6 +4840,29 @@ bool CWallet::ParameterInteraction()
48404840
return true;
48414841
}
48424842

4843+
bool CWallet::InitAutoBackup()
4844+
{
4845+
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
4846+
return true;
4847+
4848+
std::string strWarning;
4849+
std::string strError;
4850+
4851+
nWalletBackups = GetArg("-createwalletbackups", 10);
4852+
nWalletBackups = std::max(0, std::min(10, nWalletBackups));
4853+
4854+
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
4855+
4856+
if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) {
4857+
if (!strWarning.empty())
4858+
InitWarning(strWarning);
4859+
if (!strError.empty())
4860+
return InitError(strError);
4861+
}
4862+
4863+
return true;
4864+
}
4865+
48434866
bool CWallet::BackupWallet(const std::string& strDest)
48444867
{
48454868
if (!fFileBacked)

src/wallet/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,9 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
10421042
/* Wallets parameter interaction */
10431043
static bool ParameterInteraction();
10441044

1045+
/* Initialize AutoBackup functionality */
1046+
static bool InitAutoBackup();
1047+
10451048
bool BackupWallet(const std::string& strDest);
10461049

10471050
/**

0 commit comments

Comments
 (0)