Skip to content

Commit 886e8c9

Browse files
committed
Merge #8768: init: Get rid of fDisableWallet
fa58edb [wallet] Introduce DEFAULT_DISABLE_WALLET (MarcoFalke) fab9107 init: Get rid of fDisableWallet (MarcoFalke)
2 parents 84c9a04 + fa58edb commit 886e8c9

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

src/init.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -935,9 +935,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
935935

936936
RegisterAllCoreRPCCommands(tableRPC);
937937
#ifdef ENABLE_WALLET
938-
bool fDisableWallet = GetBoolArg("-disablewallet", false);
939-
if (!fDisableWallet)
940-
RegisterWalletRPCCommands(tableRPC);
938+
RegisterWalletRPCCommands(tableRPC);
941939
#endif
942940

943941
nConnectTimeout = GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
@@ -965,9 +963,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
965963
nBytesPerSigOp = GetArg("-bytespersigop", nBytesPerSigOp);
966964

967965
#ifdef ENABLE_WALLET
968-
if (!fDisableWallet && !CWallet::ParameterInteraction())
966+
if (!CWallet::ParameterInteraction())
969967
return false;
970-
#endif // ENABLE_WALLET
968+
#endif
971969

972970
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
973971
fAcceptDatacarrier = GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER);
@@ -1095,11 +1093,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
10951093

10961094
// ********************************************************* Step 5: verify wallet database integrity
10971095
#ifdef ENABLE_WALLET
1098-
if (!fDisableWallet) {
1099-
if (!CWallet::Verify())
1100-
return false;
1101-
} // (!fDisableWallet)
1102-
#endif // ENABLE_WALLET
1096+
if (!CWallet::Verify())
1097+
return false;
1098+
#endif
11031099
// ********************************************************* Step 6: network initialization
11041100

11051101
assert(!g_connman);
@@ -1427,17 +1423,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
14271423

14281424
// ********************************************************* Step 8: load wallet
14291425
#ifdef ENABLE_WALLET
1430-
if (fDisableWallet) {
1431-
pwalletMain = NULL;
1432-
LogPrintf("Wallet disabled!\n");
1433-
} else {
1434-
CWallet::InitLoadWallet();
1435-
if (!pwalletMain)
1436-
return false;
1437-
}
1438-
#else // ENABLE_WALLET
1426+
if (!CWallet::InitLoadWallet())
1427+
return false;
1428+
#else
14391429
LogPrintf("No wallet support compiled in!\n");
1440-
#endif // !ENABLE_WALLET
1430+
#endif
14411431

14421432
// ********************************************************* Step 9: data directory maintenance
14431433

src/qt/bitcoingui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
123123
QString windowTitle = tr(PACKAGE_NAME) + " - ";
124124
#ifdef ENABLE_WALLET
125125
/* if compiled with wallet support, -disablewallet can still disable the wallet */
126-
enableWallet = !GetBoolArg("-disablewallet", false);
126+
enableWallet = !GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
127127
#else
128128
enableWallet = false;
129129
#endif // ENABLE_WALLET

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,9 @@ static const CRPCCommand commands[] =
26302630

26312631
void RegisterWalletRPCCommands(CRPCTable &t)
26322632
{
2633+
if (GetBoolArg("-disablewallet", false))
2634+
return;
2635+
26332636
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
26342637
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
26352638
}

src/wallet/wallet.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ void CWallet::Flush(bool shutdown)
414414

415415
bool CWallet::Verify()
416416
{
417+
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
418+
return true;
419+
417420
LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0));
418421
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
419422

@@ -3293,6 +3296,12 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
32933296

32943297
bool CWallet::InitLoadWallet()
32953298
{
3299+
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
3300+
pwalletMain = NULL;
3301+
LogPrintf("Wallet disabled!\n");
3302+
return true;
3303+
}
3304+
32963305
std::string walletFile = GetArg("-wallet", DEFAULT_WALLET_DAT);
32973306

32983307
// needed to restore wallet transaction meta data after -zapwallettxes
@@ -3464,6 +3473,9 @@ bool CWallet::InitLoadWallet()
34643473

34653474
bool CWallet::ParameterInteraction()
34663475
{
3476+
if (GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET))
3477+
return true;
3478+
34673479
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && SoftSetBoolArg("-walletbroadcast", false)) {
34683480
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
34693481
}

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const bool DEFAULT_WALLET_RBF = false;
5959
//! Largest (in bytes) free transaction we're willing to create
6060
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
6161
static const bool DEFAULT_WALLETBROADCAST = true;
62-
62+
static const bool DEFAULT_DISABLE_WALLET = false;
6363
//! if set, all keys will be derived by using BIP32
6464
static const bool DEFAULT_USE_HD_WALLET = true;
6565

0 commit comments

Comments
 (0)