From c166ed39b0441145a70bfc2fd66dd2b038c96323 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 1 Dec 2017 21:53:34 +0300 Subject: [PATCH] Allow compilation with `--disable-wallet` (#1733) * Allow compilation with `--disable-wallet` * fix remaining references * Drop wallet references/include in CActiveMasternode and fix other files affected by this change * Wrap privatesend-client.h include with ifdef/endif and fix other files affected by this change * Re-enable Travis build with no wallet reverts 267e57877be501ebff61dee31588d0bd6b43a841 --- .travis.yml | 2 +- src/Makefile.am | 18 +++++++-------- src/activemasternode.cpp | 2 -- src/activemasternode.h | 5 ++-- src/dsnotificationinterface.cpp | 8 +++++++ src/init.cpp | 14 ++++++++++- src/instantx.cpp | 6 +++++ src/masternode-sync.cpp | 1 + src/masternode.cpp | 7 ++++++ src/masternodeman.cpp | 7 +++++- src/net.cpp | 1 - src/net_processing.cpp | 4 ++++ src/privatesend-server.cpp | 1 + src/qt/bitcoingui.cpp | 2 ++ src/qt/optionsdialog.cpp | 9 ++++++-- src/qt/optionsmodel.cpp | 19 +++++++++++---- src/qt/walletmodel.h | 4 ++++ src/rpc/governance.cpp | 13 ++++++++++- src/rpc/masternode.cpp | 41 +++++++++++++++++++++++++++++---- src/rpc/mining.cpp | 6 ++--- src/rpc/misc.cpp | 21 ++++++++++++----- src/validation.h | 3 +++ src/wallet/wallet.h | 3 --- 23 files changed, 154 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index 484a7d8719..aa59542426 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,7 +46,7 @@ env: # dashd - HOST=x86_64-unknown-linux-gnu PPA="ppa:bitcoin/bitcoin" PACKAGES="bc python3-zmq" DEP_OPTS="NO_QT=1 NO_UPNP=1 DEBUG=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-zmq --enable-glibc-back-compat --enable-reduce-exports" CPPFLAGS="-DDEBUG_LOCKORDER -DENABLE_DASH_DEBUG" PYZMQ=true # No wallet -# - HOST=x86_64-unknown-linux-gnu PPA="ppa:bitcoin/bitcoin" PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" + - HOST=x86_64-unknown-linux-gnu PPA="ppa:bitcoin/bitcoin" PACKAGES="python3" DEP_OPTS="NO_WALLET=1" RUN_TESTS=true GOAL="install" BITCOIN_CONFIG="--enable-glibc-back-compat --enable-reduce-exports" # Cross-Mac - HOST=x86_64-apple-darwin11 PPA="ppa:bitcoin/bitcoin" PACKAGES="cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev" BITCOIN_CONFIG="--enable-gui --enable-reduce-exports" OSX_SDK=10.9 GOAL="deploy" diff --git a/src/Makefile.am b/src/Makefile.am index 6a0e317f08..1dff0430bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -211,15 +211,18 @@ libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_server_a_SOURCES = \ + activemasternode.cpp \ addrman.cpp \ addrdb.cpp \ alert.cpp \ bloom.cpp \ chain.cpp \ checkpoints.cpp \ + dsnotificationinterface.cpp \ httprpc.cpp \ httpserver.cpp \ init.cpp \ + instantx.cpp \ dbwrapper.cpp \ governance.cpp \ governance-classes.cpp \ @@ -227,6 +230,11 @@ libbitcoin_server_a_SOURCES = \ governance-validators.cpp \ governance-vote.cpp \ governance-votedb.cpp \ + masternode.cpp \ + masternode-payments.cpp \ + masternode-sync.cpp \ + masternodeconfig.cpp \ + masternodeman.cpp \ merkleblock.cpp \ messagesigner.cpp \ miner.cpp \ @@ -250,6 +258,7 @@ libbitcoin_server_a_SOURCES = \ rpc/server.cpp \ script/sigcache.cpp \ sendalert.cpp \ + spork.cpp \ timedata.cpp \ torcontrol.cpp \ txdb.cpp \ @@ -276,14 +285,6 @@ endif libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_wallet_a_SOURCES = \ - activemasternode.cpp \ - dsnotificationinterface.cpp \ - instantx.cpp \ - masternode.cpp \ - masternode-payments.cpp \ - masternode-sync.cpp \ - masternodeconfig.cpp \ - masternodeman.cpp \ keepass.cpp \ privatesend-client.cpp \ privatesend-util.cpp \ @@ -372,7 +373,6 @@ libbitcoin_common_a_SOURCES = \ script/script_error.cpp \ script/sign.cpp \ script/standard.cpp \ - spork.cpp \ $(BITCOIN_CORE_H) # util: shared between all executables. diff --git a/src/activemasternode.cpp b/src/activemasternode.cpp index 14a2dd4744..ecccbad314 100644 --- a/src/activemasternode.cpp +++ b/src/activemasternode.cpp @@ -8,8 +8,6 @@ #include "masternodeman.h" #include "protocol.h" -extern CWallet* pwalletMain; - // Keep track of the active Masternode CActiveMasternode activeMasternode; diff --git a/src/activemasternode.h b/src/activemasternode.h index 9436045f22..7617b434d3 100644 --- a/src/activemasternode.h +++ b/src/activemasternode.h @@ -5,9 +5,10 @@ #ifndef ACTIVEMASTERNODE_H #define ACTIVEMASTERNODE_H -#include "net.h" +#include "chainparams.h" #include "key.h" -#include "wallet/wallet.h" +#include "net.h" +#include "primitives/transaction.h" class CActiveMasternode; diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 60b316bd83..809c90496c 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -2,13 +2,17 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "chainparams.h" #include "dsnotificationinterface.h" #include "instantx.h" #include "governance.h" #include "masternodeman.h" #include "masternode-payments.h" #include "masternode-sync.h" +#include "privatesend.h" +#ifdef ENABLE_WALLET #include "privatesend-client.h" +#endif // ENABLE_WALLET #include "txmempool.h" void CDSNotificationInterface::InitializeCurrentBlockTip() @@ -47,19 +51,23 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con ::minRelayTxFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_MIN_RELAY_TX_FEE : DEFAULT_LEGACY_MIN_RELAY_TX_FEE); mempool.UpdateMinFee(::minRelayTxFee); } +#ifdef ENABLE_WALLET if (!mapArgs.count("-mintxfee")) { CWallet::minTxFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_TRANSACTION_MINFEE : DEFAULT_LEGACY_TRANSACTION_MINFEE); } if (!mapArgs.count("-fallbackfee")) { CWallet::fallbackFee = CFeeRate(fDIP0001ActiveAtTip ? DEFAULT_DIP0001_FALLBACK_FEE : DEFAULT_LEGACY_FALLBACK_FEE); } +#endif // ENABLE_WALLET } if (fInitialDownload) return; mnodeman.UpdatedBlockTip(pindexNew); +#ifdef ENABLE_WALLET privateSendClient.UpdatedBlockTip(pindexNew); +#endif // ENABLE_WALLET instantsend.UpdatedBlockTip(pindexNew); mnpayments.UpdatedBlockTip(pindexNew, connman); governance.UpdatedBlockTip(pindexNew, connman); diff --git a/src/init.cpp b/src/init.cpp index 978e29909e..200a9dec0a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -12,6 +12,7 @@ #include "addrman.h" #include "amount.h" +#include "base58.h" #include "chain.h" #include "chainparams.h" #include "checkpoints.h" @@ -59,7 +60,9 @@ #include "masternodeconfig.h" #include "messagesigner.h" #include "netfulfilledman.h" +#ifdef ENABLE_WALLET #include "privatesend-client.h" +#endif // ENABLE_WALLET #include "privatesend-server.h" #include "spork.h" @@ -586,12 +589,14 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-mnconflock=", strprintf(_("Lock masternodes from masternode configuration file (default: %u)"), 1)); strUsage += HelpMessageOpt("-masternodeprivkey=", _("Set the masternode private key")); +#ifdef ENABLE_WALLET strUsage += HelpMessageGroup(_("PrivateSend options:")); strUsage += HelpMessageOpt("-enableprivatesend=", strprintf(_("Enable use of automated PrivateSend for funds stored in this wallet (0-1, default: %u)"), 0)); strUsage += HelpMessageOpt("-privatesendmultisession=", strprintf(_("Enable multiple PrivateSend mixing sessions per block, experimental (0-1, default: %u)"), DEFAULT_PRIVATESEND_MULTISESSION)); strUsage += HelpMessageOpt("-privatesendrounds=", strprintf(_("Use N separate masternodes for each denominated input to mix funds (2-16, default: %u)"), DEFAULT_PRIVATESEND_ROUNDS)); strUsage += HelpMessageOpt("-privatesendamount=", strprintf(_("Keep N DASH anonymized (default: %u)"), DEFAULT_PRIVATESEND_AMOUNT)); strUsage += HelpMessageOpt("-liquidityprovider=", strprintf(_("Provide liquidity to PrivateSend by infrequently mixing coins on a continual basis (0-100, default: %u, 1=very frequent, high fees, 100=very infrequent, low fees)"), DEFAULT_PRIVATESEND_LIQUIDITY)); +#endif // ENABLE_WALLET strUsage += HelpMessageGroup(_("InstantSend options:")); strUsage += HelpMessageOpt("-enableinstantsend=", strprintf(_("Enable InstantSend, show confirmations for locked transactions (0-1, default: %u)"), 1)); @@ -903,6 +908,7 @@ void InitParameterInteraction() LogPrintf("%s: parameter interaction: -enableinstantsend=false -> setting -nInstantSendDepth=0\n", __func__); } +#ifdef ENABLE_WALLET int nLiqProvTmp = GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY); if (nLiqProvTmp > 0) { mapArgs["-enableprivatesend"] = "1"; @@ -920,6 +926,7 @@ void InitParameterInteraction() mapArgs.erase("-mnemonicpassphrase"); LogPrintf("%s: parameter interaction: can't use -hdseed and -mnemonic/-mnemonicpassphrase together, will prefer -seed\n", __func__); } +#endif // ENABLE_WALLET } void InitLogging() @@ -1894,6 +1901,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } +#ifdef ENABLE_WALLET LogPrintf("Using masternode config file %s\n", GetMasternodeConfigFile().string()); if(GetBoolArg("-mnconflock", true) && pwalletMain && (masternodeConfig.getCount() > 0)) { @@ -1915,7 +1923,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } } - privateSendClient.nLiquidityProvider = std::min(std::max((int)GetArg("-liquidityprovider", DEFAULT_PRIVATESEND_LIQUIDITY), 0), 100); if(privateSendClient.nLiquidityProvider) { // special case for liquidity providers only, normal clients should use default value @@ -1926,6 +1933,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) privateSendClient.fPrivateSendMultiSession = GetBoolArg("-privatesendmultisession", DEFAULT_PRIVATESEND_MULTISESSION); privateSendClient.nPrivateSendRounds = std::min(std::max((int)GetArg("-privatesendrounds", DEFAULT_PRIVATESEND_ROUNDS), 2), privateSendClient.nLiquidityProvider ? 99999 : 16); privateSendClient.nPrivateSendAmount = std::min(std::max((int)GetArg("-privatesendamount", DEFAULT_PRIVATESEND_AMOUNT), 2), 999999); +#endif // ENABLE_WALLET fEnableInstantSend = GetBoolArg("-enableinstantsend", 1); nInstantSendDepth = GetArg("-instantsenddepth", DEFAULT_INSTANTSEND_DEPTH); @@ -1939,8 +1947,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("fLiteMode %d\n", fLiteMode); LogPrintf("nInstantSendDepth %d\n", nInstantSendDepth); +#ifdef ENABLE_WALLET LogPrintf("PrivateSend rounds %d\n", privateSendClient.nPrivateSendRounds); LogPrintf("PrivateSend amount %d\n", privateSendClient.nPrivateSendAmount); +#endif // ENABLE_WALLET CPrivateSend::InitStandardDenominations(); @@ -1996,8 +2006,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) threadGroup.create_thread(boost::bind(&ThreadCheckPrivateSend, boost::ref(*g_connman))); if (fMasterNode) threadGroup.create_thread(boost::bind(&ThreadCheckPrivateSendServer, boost::ref(*g_connman))); +#ifdef ENABLE_WALLET else threadGroup.create_thread(boost::bind(&ThreadCheckPrivateSendClient, boost::ref(*g_connman))); +#endif // ENABLE_WALLET // ********************************************************* Step 12: start node diff --git a/src/instantx.cpp b/src/instantx.cpp index 8e849a758b..b7eb8bd142 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -16,11 +16,17 @@ #include "txmempool.h" #include "util.h" #include "consensus/validation.h" +#include "validationinterface.h" +#ifdef ENABLE_WALLET +#include "wallet/wallet.h" +#endif // ENABLE_WALLET #include #include +#ifdef ENABLE_WALLET extern CWallet* pwalletMain; +#endif // ENABLE_WALLET extern CTxMemPool mempool; bool fEnableInstantSend = true; diff --git a/src/masternode-sync.cpp b/src/masternode-sync.cpp index 4de27de604..12850703a0 100644 --- a/src/masternode-sync.cpp +++ b/src/masternode-sync.cpp @@ -12,6 +12,7 @@ #include "masternodeman.h" #include "netfulfilledman.h" #include "spork.h" +#include "ui_interface.h" #include "util.h" class CMasternodeSync; diff --git a/src/masternode.cpp b/src/masternode.cpp index 0360cba534..7a6d945171 100644 --- a/src/masternode.cpp +++ b/src/masternode.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "activemasternode.h" +#include "base58.h" #include "init.h" #include "netbase.h" #include "masternode.h" @@ -10,7 +11,11 @@ #include "masternode-sync.h" #include "masternodeman.h" #include "messagesigner.h" +#include "script/standard.h" #include "util.h" +#ifdef ENABLE_WALLET +#include "wallet/wallet.h" +#endif // ENABLE_WALLET #include @@ -356,6 +361,7 @@ void CMasternode::UpdateLastPaid(const CBlockIndex *pindex, int nMaxBlocksToScan // LogPrint("masternode", "CMasternode::UpdateLastPaidBlock -- searching for block with payment to %s -- keeping old %d\n", vin.prevout.ToStringShort(), nBlockLastPaid); } +#ifdef ENABLE_WALLET bool CMasternodeBroadcast::Create(std::string strService, std::string strKeyMasternode, std::string strTxHash, std::string strOutputIndex, std::string& strErrorRet, CMasternodeBroadcast &mnbRet, bool fOffline) { COutPoint outpoint; @@ -426,6 +432,7 @@ bool CMasternodeBroadcast::Create(const COutPoint& outpoint, const CService& ser return true; } +#endif // ENABLE_WALLET bool CMasternodeBroadcast::SimpleCheck(int& nDos) { diff --git a/src/masternodeman.cpp b/src/masternodeman.cpp index bb1bc6b33d..9de76d8176 100644 --- a/src/masternodeman.cpp +++ b/src/masternodeman.cpp @@ -10,7 +10,10 @@ #include "masternodeman.h" #include "messagesigner.h" #include "netfulfilledman.h" +#ifdef ENABLE_WALLET #include "privatesend-client.h" +#endif // ENABLE_WALLET +#include "script/standard.h" #include "util.h" /** Masternode manager */ @@ -732,8 +735,10 @@ void CMasternodeMan::ProcessMasternodeConnections(CConnman& connman) connman.ForEachNode(CConnman::AllNodes, [](CNode* pnode) { if(pnode->fMasternode) { - if(privateSendClient.infoMixingMasternode.fInfoValid && pnode->addr == privateSendClient.infoMixingMasternode.addr) +#ifdef ENABLE_WALLET + if(privateSendClient.infoMixingMasternode.fInfoValid && pnode->addr == privateSendClient.infoMixingMasternode.addr) return; +#endif // ENABLE_WALLET LogPrintf("Closing Masternode connection: peer=%d, addr=%s\n", pnode->id, pnode->addr.ToString()); pnode->fDisconnect = true; } diff --git a/src/net.cpp b/src/net.cpp index 524914b2d5..2762ed5f11 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -20,7 +20,6 @@ #include "netbase.h" #include "scheduler.h" #include "ui_interface.h" -#include "wallet/wallet.h" #include "utilstrencodings.h" #include "instantx.h" diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 0b0bba7d8d..c32256cc57 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -35,7 +35,9 @@ #include "masternode-payments.h" #include "masternode-sync.h" #include "masternodeman.h" +#ifdef ENABLE_WALLET #include "privatesend-client.h" +#endif // ENABLE_WALLET #include "privatesend-server.h" #include @@ -2163,7 +2165,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (found) { //probably one the extensions +#ifdef ENABLE_WALLET privateSendClient.ProcessMessage(pfrom, strCommand, vRecv, connman); +#endif // ENABLE_WALLET privateSendServer.ProcessMessage(pfrom, strCommand, vRecv, connman); mnodeman.ProcessMessage(pfrom, strCommand, vRecv, connman); mnpayments.ProcessMessage(pfrom, strCommand, vRecv, connman); diff --git a/src/privatesend-server.cpp b/src/privatesend-server.cpp index ec2e293c5b..6561db99fd 100644 --- a/src/privatesend-server.cpp +++ b/src/privatesend-server.cpp @@ -9,6 +9,7 @@ #include "init.h" #include "masternode-sync.h" #include "masternodeman.h" +#include "script/interpreter.h" #include "txmempool.h" #include "util.h" #include "utilmoneystr.h" diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 9b8006c927..f2513eb392 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -551,6 +551,7 @@ void BitcoinGUI::createMenuBar() void BitcoinGUI::createToolBars() { +#ifdef ENABLE_WALLET if(walletFrame) { QToolBar *toolbar = new QToolBar(tr("Tabs toolbar")); @@ -579,6 +580,7 @@ void BitcoinGUI::createToolBars() containerWidget->setLayout(layout); setCentralWidget(containerWidget); } +#endif // ENABLE_WALLET } void BitcoinGUI::setClientModel(ClientModel *clientModel) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 203197a8f8..e41881d8d0 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -19,9 +19,9 @@ #ifdef ENABLE_WALLET #include "wallet/wallet.h" // for CWallet::GetRequiredFee() -#endif #include "privatesend-client.h" +#endif // ENABLE_WALLET #include @@ -32,7 +32,9 @@ #include #include +#ifdef ENABLE_WALLET extern CWallet* pwalletMain; +#endif // ENABLE_WALLET OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : QDialog(parent), @@ -262,8 +264,11 @@ void OptionsDialog::on_resetButton_clicked() void OptionsDialog::on_okButton_clicked() { mapper->submit(); +#ifdef ENABLE_WALLET privateSendClient.nCachedNumBlocks = std::numeric_limits::max(); - pwalletMain->MarkDirty(); + if(pwalletMain) + pwalletMain->MarkDirty(); +#endif // ENABLE_WALLET accept(); updateDefaultProxyNets(); } diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 77f79eb298..6d03b4f9f9 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -22,12 +22,10 @@ #ifdef ENABLE_WALLET #include "wallet/wallet.h" #include "wallet/walletdb.h" -#endif -#ifdef ENABLE_WALLET #include "masternodeconfig.h" -#endif #include "privatesend-client.h" +#endif #include #include @@ -82,14 +80,16 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("strThirdPartyTxUrls", ""); strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString(); + if (!settings.contains("theme")) + settings.setValue("theme", ""); + +#ifdef ENABLE_WALLET if (!settings.contains("fCoinControlFeatures")) settings.setValue("fCoinControlFeatures", false); fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool(); if (!settings.contains("digits")) settings.setValue("digits", "2"); - if (!settings.contains("theme")) - settings.setValue("theme", ""); if (!settings.contains("fShowMasternodesTab")) settings.setValue("fShowMasternodesTab", masternodeConfig.getCount()); @@ -100,6 +100,7 @@ void OptionsModel::Init(bool resetSettings) if (!settings.contains("fLowKeysWarning")) settings.setValue("fLowKeysWarning", true); +#endif // ENABLE_WALLET // These are shared with the core or have a command-line parameter // and we want command-line parameters to overwrite the GUI settings. @@ -281,14 +282,18 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return nDisplayUnit; case ThirdPartyTxUrls: return strThirdPartyTxUrls; +#ifdef ENABLE_WALLET case Digits: return settings.value("digits"); +#endif // ENABLE_WALLET case Theme: return settings.value("theme"); case Language: return settings.value("language"); +#ifdef ENABLE_WALLET case CoinControlFeatures: return fCoinControlFeatures; +#endif // ENABLE_WALLET case DatabaseCache: return settings.value("nDatabaseCache"); case ThreadsScriptVerif: @@ -451,12 +456,14 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in setRestartRequired(true); } break; +#ifdef ENABLE_WALLET case Digits: if (settings.value("digits") != value) { settings.setValue("digits", value); setRestartRequired(true); } break; +#endif // ENABLE_WALLET case Theme: if (settings.value("theme") != value) { settings.setValue("theme", value); @@ -469,11 +476,13 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in setRestartRequired(true); } break; +#ifdef ENABLE_WALLET case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); Q_EMIT coinControlFeaturesChanged(fCoinControlFeatures); break; +#endif // ENABLE_WALLET case DatabaseCache: if (settings.value("nDatabaseCache") != value) { settings.setValue("nDatabaseCache", value); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index c4cd012534..87522d40c7 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -8,7 +8,9 @@ #include "paymentrequestplus.h" #include "walletmodeltransaction.h" +#ifdef ENABLE_WALLET #include "wallet/wallet.h" +#endif // ENABLE_WALLET #include "support/allocators/secure.h" #include @@ -49,7 +51,9 @@ public: // Todo: This is a hack, should be replaced with a cleaner solution! QString address; QString label; +#ifdef ENABLE_WALLET AvailableCoinsType inputType; +#endif // ENABLE_WALLET bool fUseInstantSend; CAmount amount; // If from a payment request, this is used for storing the memo diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index 9a82743bb7..bdf72c8173 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -19,6 +19,9 @@ #include "rpc/server.h" #include "util.h" #include "utilmoneystr.h" +#ifdef ENABLE_WALLET +#include "wallet/wallet.h" +#endif // ENABLE_WALLET #include @@ -29,7 +32,11 @@ UniValue gobject(const UniValue& params, bool fHelp) strCommand = params[0].get_str(); if (fHelp || - (strCommand != "vote-many" && strCommand != "vote-conf" && strCommand != "vote-alias" && strCommand != "prepare" && strCommand != "submit" && strCommand != "count" && + ( +#ifdef ENABLE_WALLET + strCommand != "prepare" && +#endif // ENABLE_WALLET + strCommand != "vote-many" && strCommand != "vote-conf" && strCommand != "vote-alias" && strCommand != "submit" && strCommand != "count" && strCommand != "deserialize" && strCommand != "get" && strCommand != "getvotes" && strCommand != "getcurrentvotes" && strCommand != "list" && strCommand != "diff" && strCommand != "check" )) throw std::runtime_error( @@ -37,7 +44,9 @@ UniValue gobject(const UniValue& params, bool fHelp) "Manage governance objects\n" "\nAvailable commands:\n" " check - Validate governance object data (proposal only)\n" +#ifdef ENABLE_WALLET " prepare - Prepare governance object by signing and creating tx\n" +#endif // ENABLE_WALLET " submit - Submit governance object to network\n" " deserialize - Deserialize governance object from hex string to JSON\n" " count - Count governance objects and votes\n" @@ -113,6 +122,7 @@ UniValue gobject(const UniValue& params, bool fHelp) return objResult; } +#ifdef ENABLE_WALLET // PREPARE THE GOVERNANCE OBJECT BY CREATING A COLLATERAL TRANSACTION if(strCommand == "prepare") { @@ -178,6 +188,7 @@ UniValue gobject(const UniValue& params, bool fHelp) return wtx.GetHash().ToString(); } +#endif // ENABLE_WALLET // AFTER COLLATERAL TRANSACTION HAS MATURED USER CAN SUBMIT GOVERNANCE OBJECT TO PROPAGATE NETWORK if(strCommand == "submit") diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index 30f0ef3e91..e391e7f22a 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "activemasternode.h" +#include "base58.h" #include "init.h" #include "netbase.h" #include "validation.h" @@ -10,7 +11,9 @@ #include "masternode-sync.h" #include "masternodeconfig.h" #include "masternodeman.h" +#ifdef ENABLE_WALLET #include "privatesend-client.h" +#endif // ENABLE_WALLET #include "privatesend-server.h" #include "rpc/server.h" #include "util.h" @@ -20,6 +23,7 @@ #include #include +#ifdef ENABLE_WALLET void EnsureWalletIsUnlocked(); UniValue privatesend(const UniValue& params, bool fHelp) @@ -61,6 +65,7 @@ UniValue privatesend(const UniValue& params, bool fHelp) return "Unknown command, please see \"help privatesend\""; } +#endif // ENABLE_WALLET UniValue getpoolinfo(const UniValue& params, bool fHelp) { @@ -69,6 +74,7 @@ UniValue getpoolinfo(const UniValue& params, bool fHelp) "getpoolinfo\n" "Returns an object containing mixing pool related information.\n"); +#ifdef ENABLE_WALLET CPrivateSendBase privateSend = fMasterNode ? (CPrivateSendBase)privateSendServer : (CPrivateSendBase)privateSendClient; UniValue obj(UniValue::VOBJ); @@ -88,6 +94,12 @@ UniValue getpoolinfo(const UniValue& params, bool fHelp) obj.push_back(Pair("warnings", pwalletMain->nKeysLeftSinceAutoBackup < PRIVATESEND_KEYS_THRESHOLD_WARNING ? "WARNING: keypool is almost depleted!" : "")); } +#else // ENABLE_WALLET + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("state", privateSendServer.GetStateString())); + obj.push_back(Pair("queue", privateSendServer.GetQueueSize())); + obj.push_back(Pair("entries", privateSendServer.GetEntriesCount())); +#endif // ENABLE_WALLET return obj; } @@ -100,14 +112,20 @@ UniValue masternode(const UniValue& params, bool fHelp) strCommand = params[0].get_str(); } +#ifdef ENABLE_WALLET if (strCommand == "start-many") throw JSONRPCError(RPC_INVALID_PARAMETER, "DEPRECATED, please use start-all instead"); +#endif // ENABLE_WALLET if (fHelp || - (strCommand != "start" && strCommand != "start-alias" && strCommand != "start-all" && strCommand != "start-missing" && - strCommand != "start-disabled" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && + ( +#ifdef ENABLE_WALLET + strCommand != "start-alias" && strCommand != "start-all" && strCommand != "start-missing" && + strCommand != "start-disabled" && strCommand != "outputs" && +#endif // ENABLE_WALLET + strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && strCommand != "debug" && strCommand != "current" && strCommand != "winner" && strCommand != "winners" && strCommand != "genkey" && - strCommand != "connect" && strCommand != "outputs" && strCommand != "status")) + strCommand != "connect" && strCommand != "status")) throw std::runtime_error( "masternode \"command\"...\n" "Set of commands to execute masternode related actions\n" @@ -117,9 +135,11 @@ UniValue masternode(const UniValue& params, bool fHelp) " count - Print number of all known masternodes (optional: 'ps', 'enabled', 'all', 'qualify')\n" " current - Print info on current masternode winner to be paid the next block (calculated locally)\n" " genkey - Generate new masternodeprivkey\n" +#ifdef ENABLE_WALLET " outputs - Print masternode compatible outputs\n" " start-alias - Start single remote masternode by assigned alias configured in masternode.conf\n" " start- - Start remote masternodes configured in masternode.conf (: 'all', 'missing', 'disabled')\n" +#endif // ENABLE_WALLET " status - Print masternode status information\n" " list - Print list of all known masternodes (see masternodelist for more info)\n" " list-conf - Print masternode.conf in JSON format\n" @@ -213,6 +233,7 @@ UniValue masternode(const UniValue& params, bool fHelp) return obj; } +#ifdef ENABLE_WALLET if (strCommand == "start-alias") { if (params.size() < 2) @@ -311,6 +332,7 @@ UniValue masternode(const UniValue& params, bool fHelp) return returnObj; } +#endif // ENABLE_WALLET if (strCommand == "genkey") { @@ -344,6 +366,7 @@ UniValue masternode(const UniValue& params, bool fHelp) return resultObj; } +#ifdef ENABLE_WALLET if (strCommand == "outputs") { // Find possible candidates std::vector vPossibleCoins; @@ -355,8 +378,8 @@ UniValue masternode(const UniValue& params, bool fHelp) } return obj; - } +#endif // ENABLE_WALLET if (strCommand == "status") { @@ -576,19 +599,26 @@ UniValue masternodebroadcast(const UniValue& params, bool fHelp) strCommand = params[0].get_str(); if (fHelp || - (strCommand != "create-alias" && strCommand != "create-all" && strCommand != "decode" && strCommand != "relay")) + ( +#ifdef ENABLE_WALLET + strCommand != "create-alias" && strCommand != "create-all" && +#endif // ENABLE_WALLET + strCommand != "decode" && strCommand != "relay")) throw std::runtime_error( "masternodebroadcast \"command\"...\n" "Set of commands to create and relay masternode broadcast messages\n" "\nArguments:\n" "1. \"command\" (string or set of strings, required) The command to execute\n" "\nAvailable commands:\n" +#ifdef ENABLE_WALLET " create-alias - Create single remote masternode broadcast message by assigned alias configured in masternode.conf\n" " create-all - Create remote masternode broadcast messages for all masternodes configured in masternode.conf\n" +#endif // ENABLE_WALLET " decode - Decode masternode broadcast message\n" " relay - Relay masternode broadcast message to the network\n" ); +#ifdef ENABLE_WALLET if (strCommand == "create-alias") { // wait for reindex and/or import to finish @@ -691,6 +721,7 @@ UniValue masternodebroadcast(const UniValue& params, bool fHelp) return returnObj; } +#endif // ENABLE_WALLET if (strCommand == "decode") { diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 353d4404c2..1a274b3e6a 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -21,14 +21,12 @@ #include "spork.h" #include "txmempool.h" #include "util.h" -#ifdef ENABLE_WALLET -#include "masternode-sync.h" -#endif #include "utilstrencodings.h" #include "validationinterface.h" -#include "masternode-payments.h" #include "governance-classes.h" +#include "masternode-payments.h" +#include "masternode-sync.h" #include diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index ef7897a560..31525a0674 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -7,21 +7,22 @@ #include "base58.h" #include "clientversion.h" #include "init.h" -#include "validation.h" #include "net.h" #include "netbase.h" #include "rpc/server.h" #include "timedata.h" #include "txmempool.h" #include "util.h" -#include "spork.h" #include "utilstrencodings.h" +#include "validation.h" #ifdef ENABLE_WALLET -#include "masternode-sync.h" #include "wallet/wallet.h" #include "wallet/walletdb.h" #endif +#include "masternode-sync.h" +#include "spork.h" + #include #include @@ -238,7 +239,9 @@ UniValue spork(const UniValue& params, bool fHelp) ret.push_back(Pair(sporkManager.GetSporkNameByID(nSporkID), sporkManager.IsSporkActive(nSporkID))); } return ret; - } else if (params.size() == 2){ + } +#ifdef ENABLE_WALLET + else if (params.size() == 2){ int nSporkID = sporkManager.GetSporkIDByName(params[0].get_str()); if(nSporkID == -1){ return "Invalid spork name"; @@ -262,9 +265,15 @@ UniValue spork(const UniValue& params, bool fHelp) throw runtime_error( "spork []\n" - " is the corresponding spork name, or 'show' to show all current spork settings, active to show which sporks are active" - " is a epoch datetime to enable or disable spork" + " is the corresponding spork name, or 'show' to show all current spork settings, active to show which sporks are active\n" + " is a epoch datetime to enable or disable spork\n" + HelpRequiringPassphrase()); +#else // ENABLE_WALLET + throw runtime_error( + "spork \n" + " is the corresponding spork name, or 'show' to show all current spork settings, active to show which sporks are active\n"); +#endif // ENABLE_WALLET + } UniValue validateaddress(const UniValue& params, bool fHelp) diff --git a/src/validation.h b/src/validation.h index 50b5fcfb0b..d8306262f0 100644 --- a/src/validation.h +++ b/src/validation.h @@ -163,6 +163,9 @@ extern CFeeRate minRelayTxFee; extern bool fAlerts; extern bool fEnableReplacement; +extern bool fLargeWorkForkFound; +extern bool fLargeWorkInvalidChainFound; + extern std::map mapRejectedBlocks; static const int DIP0001_PROTOCOL_VERSION = 70208; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d24c783c3f..e460ffe8e5 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -39,9 +39,6 @@ extern unsigned int nTxConfirmTarget; extern bool bSpendZeroConfChange; extern bool fSendFreeTransactions; -extern bool fLargeWorkForkFound; -extern bool fLargeWorkInvalidChainFound; - static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000; //! -paytxfee default static const CAmount DEFAULT_TRANSACTION_FEE = 0;