Skip to content

Commit

Permalink
init: Get rid of fDisableWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed May 7, 2021
1 parent 0ac6709 commit d098e5b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
20 changes: 7 additions & 13 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,6 @@ namespace { // Variables internal to initialization process only
ServiceFlags nLocalServices = NODE_NETWORK;

std::string strWalletFile;
bool fDisableWallet = false;
}

bool AppInitBasicSetup()
Expand Down Expand Up @@ -1137,18 +1136,14 @@ bool AppInitParameterInteraction()
setvbuf(stdout, NULL, _IOLBF, 0); /// ***TODO*** do we still need this after -printtoconsole is gone?

RegisterAllCoreRPCCommands(tableRPC);

// Staking needs a CWallet instance, so make sure wallet is enabled
#ifdef ENABLE_WALLET
bool fDisableWallet = gArgs.GetBoolArg("-disablewallet", false);
if (fDisableWallet) {
#endif
if (gArgs.SoftSetBoolArg("-staking", false))
LogPrintf("AppInit2 : parameter interaction: wallet functionality not enabled -> setting -staking=0\n");
#ifdef ENABLE_WALLET
} else {
// Register wallet RPC commands
RegisterWalletRPCCommands(tableRPC);
}
// Register wallet RPC commands
RegisterWalletRPCCommands(tableRPC);
#else
if (gArgs.SoftSetBoolArg("-staking", false))
LogPrintf("AppInit2 : parameter interaction: wallet functionality not enabled -> setting -staking=0\n");
#endif

nConnectTimeout = gArgs.GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
Expand Down Expand Up @@ -1315,7 +1310,7 @@ bool AppInitMain()

// ********************************************************* Step 5: Backup wallet and verify wallet database integrity
#ifdef ENABLE_WALLET
if (!fDisableWallet) {
// not fixing indentation as this block of code will be moved away from here in the following commits
fs::path backupDir = GetDataDir() / "backups";
if (!fs::exists(backupDir)) {
// Always create backup folder to not confuse the operating system's file browser
Expand Down Expand Up @@ -1422,7 +1417,6 @@ bool AppInitMain()
if (!CWallet::Verify())
return false;

} // (!fDisableWallet)
#endif // ENABLE_WALLET

// ********************************************************* Step 6: network initialization
Expand Down
6 changes: 5 additions & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4154,6 +4154,10 @@ static const CRPCCommand commands[] =

void RegisterWalletRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
if (gArgs.GetBoolArg("-disablewallet", false)) {
return;
}
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) {
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
}
8 changes: 8 additions & 0 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ void CWallet::SyncMetaData(std::pair<typename TxSpendMap<T>::iterator, typename

bool CWallet::ParameterInteraction()
{
if (gArgs.GetBoolArg("-disablewallet", false)) {
return true;
}

if (gArgs.IsArgSet("-mintxfee")) {
CAmount n = 0;
if (ParseMoney(gArgs.GetArg("-mintxfee", ""), n) && n > 0)
Expand Down Expand Up @@ -2063,6 +2067,10 @@ std::set<uint256> CWalletTx::GetConflicts() const

bool CWallet::Verify()
{
if (gArgs.GetBoolArg("-disablewallet", false)) {
return true;
}

uiInterface.InitMessage(_("Verifying wallet..."));
std::string walletFile = gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT);
std::string strDataDir = GetDataDir().string();
Expand Down

0 comments on commit d098e5b

Please sign in to comment.