X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Finit.cpp;h=5f1e4f53071044043ba9bea3e9f84e198265807d;hb=b2de28c74040595fa3fe5353ea063a8c3874f6b1;hp=367e75f39bc3982f2aba4f742cc514788b165623;hpb=cba18514c0d5b364ee96a984c255dc9e29a00d68;p=novacoin.git diff --git a/src/init.cpp b/src/init.cpp index 367e75f..5f1e4f5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" #include "db.h" #include "bitcoinrpc.h" @@ -20,6 +20,7 @@ Q_IMPORT_PLUGIN(qcncodecs) Q_IMPORT_PLUGIN(qjpcodecs) Q_IMPORT_PLUGIN(qtwcodecs) Q_IMPORT_PLUGIN(qkrcodecs) +Q_IMPORT_PLUGIN(qtaccessiblewidgets) #endif using namespace std; @@ -190,6 +191,7 @@ bool AppInit2(int argc, char* argv[]) " -maxconnections=\t " + _("Maintain at most connections to peers (default: 125)\n") + " -addnode= \t " + _("Add a node to connect to\n") + " -connect= \t\t " + _("Connect only to the specified node\n") + + " -noirc \t " + _("Don't find peers using internet relay chat\n") + " -nolisten \t " + _("Don't accept connections from outside\n") + " -nodnsseed \t " + _("Don't bootstrap list of peers using DNS\n") + " -banscore= \t " + _("Threshold for disconnecting misbehaving peers (default: 100)\n") + @@ -203,11 +205,11 @@ bool AppInit2(int argc, char* argv[]) " -upnp \t " + _("Attempt to use UPnP to map the listening port\n") + #endif #endif - " -paytxfee= \t " + _("Fee per KB to add to transactions you send\n") + -#ifdef GUI + " -paytxfee= \t " + _("Fee per kB to add to transactions you send\n") + +#ifdef QT_GUI " -server \t\t " + _("Accept command line and JSON-RPC commands\n") + #endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(QT_GUI) " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + #endif " -testnet \t\t " + _("Use the test network\n") + @@ -239,14 +241,19 @@ bool AppInit2(int argc, char* argv[]) // Remove tabs strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end()); +#if defined(QT_GUI) && defined(WIN32) + // On windows, show a message box, as there is no stderr + wxMessageBox(strUsage, "Usage"); +#else fprintf(stderr, "%s", strUsage.c_str()); +#endif return false; } + fTestNet = GetBoolArg("-testnet"); fDebug = GetBoolArg("-debug"); - fAllowDNS = GetBoolArg("-dns"); -#ifndef WIN32 +#if !defined(WIN32) && !defined(QT_GUI) fDaemon = GetBoolArg("-daemon"); #else fDaemon = false; @@ -263,10 +270,6 @@ bool AppInit2(int argc, char* argv[]) #endif fPrintToConsole = GetBoolArg("-printtoconsole"); fPrintToDebugger = GetBoolArg("-printtodebugger"); - - fTestNet = GetBoolArg("-testnet"); - bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); - fNoListen = GetBoolArg("-nolisten") || fTOR; fLogTimestamps = GetBoolArg("-logtimestamps"); #ifndef QT_GUI @@ -281,7 +284,7 @@ bool AppInit2(int argc, char* argv[]) } #endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(QT_GUI) if (fDaemon) { // Daemonize @@ -328,16 +331,7 @@ bool AppInit2(int argc, char* argv[]) return false; } - // Bind to the port early so we can tell if another instance is already running. string strErrors; - if (!fNoListen) - { - if (!BindListenPort(strErrors)) - { - wxMessageBox(strErrors, "Bitcoin"); - return false; - } - } // // Load data files @@ -376,12 +370,14 @@ bool AppInit2(int argc, char* argv[]) else if (nLoadWalletRet == DB_NEED_REWRITE) { strErrors += _("Wallet needed to be rewritten: restart Bitcoin to complete \n"); + printf("%s", strErrors.c_str()); wxMessageBox(strErrors, "Bitcoin", wxOK | wxICON_ERROR); return false; } else strErrors += _("Error loading wallet.dat \n"); } + printf("%s", strErrors.c_str()); printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); RegisterWallet(pwalletMain); @@ -424,6 +420,10 @@ bool AppInit2(int argc, char* argv[]) // Add wallet transactions that aren't already in a block to mapTransactions pwalletMain->ReacceptWalletTransactions(); + // Note: Bitcoin-QT stores several settings in the wallet, so we want + // to load the wallet BEFORE parsing command-line arguments, so + // the command-line/bitcoin.conf settings override GUI setting. + // // Parameters // @@ -476,6 +476,37 @@ bool AppInit2(int argc, char* argv[]) } } + bool fTor = (fUseProxy && addrProxy.port == htons(9050)); + if (fTor) + { + // Use SoftSetArg here so user can override any of these if they wish. + // Note: the GetBoolArg() calls for all of these must happen later. + SoftSetArg("-nolisten", true); + SoftSetArg("-noirc", true); + SoftSetArg("-nodnsseed", true); + SoftSetArg("-noupnp", true); + SoftSetArg("-upnp", false); + SoftSetArg("-dns", false); + } + + fAllowDNS = GetBoolArg("-dns"); + fNoListen = GetBoolArg("-nolisten"); + + // Command-line args override in-wallet settings: + if (mapArgs.count("-upnp")) + fUseUPnP = GetBoolArg("-upnp"); + else if (mapArgs.count("-noupnp")) + fUseUPnP = !GetBoolArg("-noupnp"); + + if (!fNoListen) + { + if (!BindListenPort(strErrors)) + { + wxMessageBox(strErrors, "Bitcoin"); + return false; + } + } + if (mapArgs.count("-addnode")) { BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"]) @@ -487,11 +518,6 @@ bool AppInit2(int argc, char* argv[]) } } - if (GetBoolArg("-nodnsseed")) - printf("DNS seeding disabled\n"); - else - DNSAddressSeed(); - if (mapArgs.count("-paytxfee")) { if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee)) @@ -503,17 +529,6 @@ bool AppInit2(int argc, char* argv[]) wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION); } - if (fHaveUPnP) - { -#if USE_UPNP - if (GetBoolArg("-noupnp")) - fUseUPnP = false; -#else - if (GetBoolArg("-upnp")) - fUseUPnP = true; -#endif - } - // // Start the node //