Merge #8768: init: Get rid of fDisableWallet

fa58edb [wallet] Introduce DEFAULT_DISABLE_WALLET (MarcoFalke)
fab9107 init: Get rid of fDisableWallet (MarcoFalke)
This commit is contained in:
Wladimir J. van der Laan 2016-09-21 12:27:47 +02:00 committed by Alexander Block
parent ac3fdd3d27
commit 06f41f3586
5 changed files with 38 additions and 33 deletions

View File

@ -1103,9 +1103,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
RegisterAllCoreRPCCommands(tableRPC); RegisterAllCoreRPCCommands(tableRPC);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool fDisableWallet = GetBoolArg("-disablewallet", false); RegisterWalletRPCCommands(tableRPC);
if (!fDisableWallet)
RegisterWalletRPCCommands(tableRPC);
#endif #endif
nConnectTimeout = GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT); nConnectTimeout = GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
@ -1133,7 +1131,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
nBytesPerSigOp = GetArg("-bytespersigop", nBytesPerSigOp); nBytesPerSigOp = GetArg("-bytespersigop", nBytesPerSigOp);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (!fDisableWallet && !CWallet::ParameterInteraction()) if (!CWallet::ParameterInteraction())
return false; return false;
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
@ -1243,29 +1241,26 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 5: Backup wallet and verify wallet database integrity // ********************************************************* Step 5: Backup wallet and verify wallet database integrity
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (!fDisableWallet) { std::string strWarning;
std::string strWarning; std::string strError;
std::string strError;
nWalletBackups = GetArg("-createwalletbackups", 10); nWalletBackups = GetArg("-createwalletbackups", 10);
nWalletBackups = std::max(0, std::min(10, nWalletBackups)); nWalletBackups = std::max(0, std::min(10, nWalletBackups));
std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); std::string strWalletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) { if(!AutoBackupWallet(NULL, strWalletFile, strWarning, strError)) {
if (!strWarning.empty()) if (!strWarning.empty())
InitWarning(strWarning); InitWarning(strWarning);
if (!strError.empty()) if (!strError.empty())
return InitError(strError); return InitError(strError);
} }
if (!CWallet::Verify()) if (!CWallet::Verify())
return false; return false;
// Initialize KeePass Integration // Initialize KeePass Integration
keePassInt.init(); keePassInt.init();
} // (!fDisableWallet)
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
// ********************************************************* Step 6: network initialization // ********************************************************* Step 6: network initialization
// Note that we absolutely cannot open any actual connections // Note that we absolutely cannot open any actual connections
@ -1613,17 +1608,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// ********************************************************* Step 8: load wallet // ********************************************************* Step 8: load wallet
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (fDisableWallet) { if (!CWallet::InitLoadWallet())
pwalletMain = NULL; return false;
LogPrintf("Wallet disabled!\n"); #else
} else {
CWallet::InitLoadWallet();
if (!pwalletMain)
return false;
}
#else // ENABLE_WALLET
LogPrintf("No wallet support compiled in!\n"); LogPrintf("No wallet support compiled in!\n");
#endif // !ENABLE_WALLET #endif
// ********************************************************* Step 9: data directory maintenance // ********************************************************* Step 9: data directory maintenance

View File

@ -134,7 +134,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
QString windowTitle = tr(PACKAGE_NAME) + " - "; QString windowTitle = tr(PACKAGE_NAME) + " - ";
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
/* if compiled with wallet support, -disablewallet can still disable the wallet */ /* if compiled with wallet support, -disablewallet can still disable the wallet */
enableWallet = !GetBoolArg("-disablewallet", false); enableWallet = !GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
#else #else
enableWallet = false; enableWallet = false;
#endif // ENABLE_WALLET #endif // ENABLE_WALLET

View File

@ -2762,6 +2762,9 @@ static const CRPCCommand commands[] =
void RegisterWalletRPCCommands(CRPCTable &t) void RegisterWalletRPCCommands(CRPCTable &t)
{ {
if (GetBoolArg("-disablewallet", false))
return;
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]); t.appendCommand(commands[vcidx].name, &commands[vcidx]);
} }

View File

@ -596,6 +596,9 @@ void CWallet::Flush(bool shutdown)
bool CWallet::Verify() bool CWallet::Verify()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true;
LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0)); LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0));
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
@ -4561,6 +4564,12 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
bool CWallet::InitLoadWallet() bool CWallet::InitLoadWallet()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
pwalletMain = NULL;
LogPrintf("Wallet disabled!\n");
return true;
}
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT); std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
// needed to restore wallet transaction meta data after -zapwallettxes // needed to restore wallet transaction meta data after -zapwallettxes
@ -4758,6 +4767,9 @@ bool CWallet::InitLoadWallet()
bool CWallet::ParameterInteraction() bool CWallet::ParameterInteraction()
{ {
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
return true;
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && SoftSetBoolArg("-walletbroadcast", false)) { if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && SoftSetBoolArg("-walletbroadcast", false)) {
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__); LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
} }

View File

@ -61,6 +61,7 @@ static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 2;
//! Largest (in bytes) free transaction we're willing to create //! Largest (in bytes) free transaction we're willing to create
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000; static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
static const bool DEFAULT_WALLETBROADCAST = true; static const bool DEFAULT_WALLETBROADCAST = true;
static const bool DEFAULT_DISABLE_WALLET = false;
extern const char * DEFAULT_WALLET_DAT; extern const char * DEFAULT_WALLET_DAT;