diff --git a/README.md b/README.md index c3c5cdc5..a79ca725 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ While the Komodo assetchains provide advanced privacy features, the main KMD coi KomodoOcean is available on three OS platforms: `Windows`, `Linux`, and `macOS`. -Use the default `static` branch and the following scripts to build, depending on your target platform and architecture: +Use the default `static` branch and the following scripts in `./zcutil` to build, depending on your target platform and architecture: - **Linux**: - `build.sh`: Native build for Linux. diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 75105565..3d2da322 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -27,7 +27,6 @@ #include "util.h" #include "httpserver.h" #include "httprpc.h" - #include "komodo.h" #include "komodo_defs.h" #include "komodo_gateway.h" @@ -68,14 +67,12 @@ void WaitForShutdown(boost::thread_group* threadGroup) { int32_t i,height; CBlockIndex *pindex; bool fShutdown = ShutdownRequested(); static const uint256 zeroid; //!< null uint256 constant - // Tell the main threads to shutdown. if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT)) { - LogPrintf("error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT); + fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT); StartShutdown(); } - while (!fShutdown) { /* TODO: move to ThreadUpdateKomodoInternals */ @@ -117,7 +114,6 @@ void WaitForShutdown(boost::thread_group* threadGroup) // // Start // - bool AppInit(int argc, char* argv[]) { boost::thread_group threadGroup; @@ -156,7 +152,7 @@ bool AppInit(int argc, char* argv[]) { // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) if (!SelectParamsFromCommandLine()) { - LogPrintf("Error: Invalid combination of -regtest and -testnet.\n"); + fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n"); return false; } void komodo_args(char *argv0); @@ -164,36 +160,18 @@ bool AppInit(int argc, char* argv[]) void chainparams_commandline(); chainparams_commandline(); - LogPrintf("call komodo_args.(%s) NOTARY_PUBKEY.(%s)\n",argv[0],NOTARY_PUBKEY.c_str()); - LogPrintf("initialized %s at %u\n",chainName.symbol().c_str(),(uint32_t)time(NULL)); + fprintf(stderr, "call komodo_args.(%s) NOTARY_PUBKEY.(%s)\n",argv[0],NOTARY_PUBKEY.c_str()); + fprintf(stdout, "initialized %s at %u\n",chainName.symbol().c_str(),(uint32_t)time(NULL)); if (!boost::filesystem::is_directory(GetDataDir(false))) { - LogPrintf("Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); + fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); return false; } try { ReadConfigFile(mapArgs, mapMultiArgs); - } catch (const missing_zcash_conf& e) { - LogPrintf( - (_("Before starting komodod, you need to create a configuration file:\n" - "%s\n" - "It can be completely empty! That indicates you are happy with the default\n" - "configuration of komodod. But requiring a configuration file to start ensures\n" - "that komodod won't accidentally compromise your privacy if there was a default\n" - "option you needed to change.\n" - "\n" - "You can look at the example configuration file for suggestions of default\n" - "options that you may want to change. It should be in one of these locations,\n" - "depending on how you installed Komodo:\n") + - _("- Source code: %s\n" - "- .deb package: %s\n")).c_str(), - GetConfigFile().string().c_str(), - "contrib/debian/examples/komodo.conf", - "/usr/share/doc/komodo/examples/komodo.conf"); - return false; } catch (const std::exception& e) { - LogPrintf("Error reading configuration file: %s\n", e.what()); + fprintf(stderr,"Error reading configuration file: %s\n", e.what()); return false; } @@ -205,7 +183,7 @@ bool AppInit(int argc, char* argv[]) if (fCommandLine) { - LogPrintf( "Error: There is no RPC client functionality in komodod. Use the komodo-cli utility instead.\n"); + fprintf(stderr, "Error: There is no RPC client functionality in komodod. Use the komodo-cli utility instead.\n"); exit(EXIT_FAILURE); } @@ -213,13 +191,13 @@ bool AppInit(int argc, char* argv[]) fDaemon = GetBoolArg("-daemon", false); if (fDaemon) { - LogPrintf("Komodo %s server starting\n",chainName.symbol().c_str()); + fprintf(stdout, "Komodo %s server starting\n",chainName.symbol().c_str()); // Daemonize pid_t pid = fork(); if (pid < 0) { - LogPrintf( "Error: fork() returned %d errno %d\n", pid, errno); + fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno); return false; } if (pid > 0) // Parent process, pid is child process id @@ -230,7 +208,7 @@ bool AppInit(int argc, char* argv[]) pid_t sid = setsid(); if (sid < 0) - LogPrintf( "Error: setsid() returned %d errno %d\n", sid, errno); + fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno); } #endif SoftSetBoolArg("-server", true); diff --git a/src/init.cpp b/src/init.cpp index 54570c88..92ccbd28 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -416,7 +416,7 @@ std::string HelpMessage(HelpMessageMode mode) #if !defined(WIN32) strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); #endif - strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), 0)); + strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX)); strUsage += HelpMessageOpt("-addressindex", strprintf(_("Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX)); strUsage += HelpMessageOpt("-timestampindex", strprintf(_("Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX)); strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX)); @@ -1046,7 +1046,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // if using block pruning, then disable txindex // also disable the wallet (for now, until SPV support is implemented in wallet) if (GetArg("-prune", 0)) { - if (GetBoolArg("-txindex", true)) + if (GetBoolArg("-txindex", DEFAULT_TXINDEX)) return InitError(_("Prune mode is incompatible with -txindex.")); #ifdef ENABLE_WALLET if (!GetBoolArg("-disablewallet", false)) { @@ -1578,7 +1578,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // enable 3/4 of the cache if addressindex and/or spentindex is enabled nBlockTreeDBCache = nTotalCache * 3 / 4; } else { - if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) { + if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", DEFAULT_TXINDEX)) { nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB } } @@ -1671,7 +1671,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } KOMODO_LOADINGBLOCKS = false; // Check for changed -txindex state - if (fTxIndex != GetBoolArg("-txindex", true)) { + if (fTxIndex != GetBoolArg("-txindex", DEFAULT_TXINDEX)) { strLoadError = _("You need to rebuild the database using -reindex to change -txindex"); break; } diff --git a/src/main.cpp b/src/main.cpp index d78f5f5e..4a4fd31e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6660,7 +6660,7 @@ bool InitBlockIndex() { if ( pblocktree != nullptr ) { // Use the provided setting for -txindex in the new database - fTxIndex = GetBoolArg("-txindex", true); + fTxIndex = GetBoolArg("-txindex", DEFAULT_TXINDEX); pblocktree->WriteFlag("txindex", fTxIndex); // Use the provided setting for -addressindex in the new database fAddressIndex = GetBoolArg("-addressindex", DEFAULT_ADDRESSINDEX); diff --git a/src/main.h b/src/main.h index e0295f21..895c0553 100644 --- a/src/main.h +++ b/src/main.h @@ -122,6 +122,7 @@ static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111; static const unsigned int DEFAULT_LIMITFREERELAY = 15; static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60; +static const bool DEFAULT_TXINDEX = true; //static const bool DEFAULT_ADDRESSINDEX = false; //static const bool DEFAULT_SPENTINDEX = false; #define DEFAULT_ADDRESSINDEX (GetArg("-ac_cc",0) != 0 || GetArg("-ac_ccactivate",0) != 0) diff --git a/src/qt/komodoapp.cpp b/src/qt/komodoapp.cpp index a6aa7957..642358b2 100644 --- a/src/qt/komodoapp.cpp +++ b/src/qt/komodoapp.cpp @@ -736,7 +736,6 @@ int main(int argc, char *argv[]) } try { -// ReadConfigFile(GetArg("-conf", KOMODO_CONF_FILENAME)); ReadConfigFile(mapArgs, mapMultiArgs); } catch (const std::exception& e) { QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), diff --git a/src/util.cpp b/src/util.cpp index 5733b863..97de282b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -749,7 +749,7 @@ void ReadConfigFile(map& mapSettingsRet, { boost::filesystem::ifstream streamConfig(GetConfigFile()); if (!streamConfig.good()) - throw missing_zcash_conf(); + return; // No komodo.conf file is OK set setOptions; setOptions.insert("*"); diff --git a/src/util.h b/src/util.h index 3b0305b9..4d0afe92 100644 --- a/src/util.h +++ b/src/util.h @@ -166,10 +166,6 @@ boost::filesystem::path GetConfigFile(); boost::filesystem::path GetPidFile(); void CreatePidFile(const boost::filesystem::path &path, pid_t pid); #endif -class missing_zcash_conf : public std::runtime_error { -public: - missing_zcash_conf() : std::runtime_error("Missing komodo.conf") { } -}; void ReadConfigFile(std::map& mapSettingsRet, std::map >& mapMultiSettingsRet); #ifdef _WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate = true);