mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Fix issue #659, and cleanup wallet/command-line argument handling a bit
This commit is contained in:
70
src/init.cpp
70
src/init.cpp
@@ -194,6 +194,7 @@ bool AppInit2(int argc, char* argv[])
|
||||
" -maxconnections=<n>\t " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" +
|
||||
" -addnode=<ip> \t " + _("Add a node to connect to") + "\n" +
|
||||
" -connect=<ip> \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=<n> \t " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" +
|
||||
@@ -248,7 +249,6 @@ bool AppInit2(int argc, char* argv[])
|
||||
}
|
||||
|
||||
fDebug = GetBoolArg("-debug");
|
||||
fAllowDNS = GetBoolArg("-dns");
|
||||
|
||||
#ifndef WIN32
|
||||
fDaemon = GetBoolArg("-daemon");
|
||||
@@ -267,10 +267,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
|
||||
@@ -332,17 +328,6 @@ bool AppInit2(int argc, char* argv[])
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind to the port early so we can tell if another instance is already running.
|
||||
if (!fNoListen)
|
||||
{
|
||||
std::string strError;
|
||||
if (!BindListenPort(strError))
|
||||
{
|
||||
wxMessageBox(strError, "Bitcoin");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream strErrors;
|
||||
//
|
||||
// Load data files
|
||||
@@ -428,6 +413,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
|
||||
//
|
||||
@@ -480,6 +469,44 @@ bool AppInit2(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
fTestNet = GetBoolArg("-testnet");
|
||||
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");
|
||||
|
||||
if (fHaveUPnP)
|
||||
{
|
||||
#if USE_UPNP
|
||||
if (GetBoolArg("-noupnp"))
|
||||
fUseUPnP = false;
|
||||
#else
|
||||
if (GetBoolArg("-upnp"))
|
||||
fUseUPnP = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!fNoListen)
|
||||
{
|
||||
std::string strError;
|
||||
if (!BindListenPort(strError))
|
||||
{
|
||||
wxMessageBox(strError, "Bitcoin");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mapArgs.count("-addnode"))
|
||||
{
|
||||
BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"])
|
||||
@@ -502,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
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user