diff options
-rw-r--r-- | doc/coding.md | 40 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/main.h | 3 | ||||
-rw-r--r-- | src/miner.cpp | 4 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 64 | ||||
-rw-r--r-- | src/qt/guiconstants.h | 5 | ||||
-rw-r--r-- | src/qt/intro.cpp | 7 | ||||
-rw-r--r-- | src/qt/intro.h | 2 | ||||
-rw-r--r-- | src/test/data/script_invalid.json | 4 | ||||
-rw-r--r-- | src/test/data/script_valid.json | 4 |
10 files changed, 77 insertions, 58 deletions
diff --git a/doc/coding.md b/doc/coding.md index 3581d7deb2..ab3a73494a 100644 --- a/doc/coding.md +++ b/doc/coding.md @@ -63,32 +63,32 @@ and its cs_KeyStore lock for example). ------- Threads +- ThreadScriptCheck : Verifies block scripts. + +- ThreadImport : Loads blocks from blk*.dat files or bootstrap.dat. + - StartNode : Starts other threads. -- ThreadGetMyExternalIP : Determines outside-the-firewall IP address, sends addr message to connected peers when it determines it. +- ThreadGetMyExternalIP : Determines outside-the-firewall IP address, sends addr message to connected peers when it determines it. + +- ThreadDNSAddressSeed : Loads addresses of peers from the DNS. + +- ThreadMapPort : Universal plug-and-play startup/shutdown - ThreadSocketHandler : Sends/Receives data from peers on port 8333. - -- ThreadMessageHandler : Higher-level message handling (sending and receiving). - + +- ThreadOpenAddedConnections : Opens network connections to added nodes. + - ThreadOpenConnections : Initiates new connections to peers. -- ThreadTopUpKeyPool : replenishes the keystore's keypool. - -- ThreadCleanWalletPassphrase : re-locks an encrypted wallet after user has unlocked it for a period of time. - -- SendingDialogStartTransfer : used by pay-via-ip-address code (obsolete) - -- ThreadDelayedRepaint : repaint the gui +- ThreadMessageHandler : Higher-level message handling (sending and receiving). + +- DumpAddresses : Dumps IP addresses of nodes to peers.dat. - ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used in 500ms. - + - ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them. - -- ThreadBitcoinMiner : Generates bitcoins - -- ThreadMapPort : Universal plug-and-play startup/shutdown - -- Shutdown : Does an orderly shutdown of everything - -- ExitTimeout : Windows-only, sleeps 5 seconds then exits application + +- BitcoinMiner : Generates bitcoins (if wallet is enabled). + +- Shutdown : Does an orderly shutdown of everything. diff --git a/src/main.cpp b/src/main.cpp index 9fdd76101a..5f50e05780 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ unsigned int nCoinCacheSize = 5000; /** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ int64_t CTransaction::nMinTxFee = 10000; // Override with -mintxfee -/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */ +/** Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) */ int64_t CTransaction::nMinRelayTxFee = 1000; static CMedianFilter<int> cPeerBlockCounts(8, 0); // Amount of blocks that other nodes claim to have diff --git a/src/main.h b/src/main.h index 1b1aca4e05..b9c8dd7050 100644 --- a/src/main.h +++ b/src/main.h @@ -35,8 +35,9 @@ class CInv; /** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 1000000; -/** Default for -blockmaxsize, maximum size for mined blocks **/ +/** Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create **/ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000; +static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0; /** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/ static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000; /** The maximum size for transactions we're willing to relay/mine */ diff --git a/src/miner.cpp b/src/miner.cpp index e52f539085..3351908e65 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -136,7 +136,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Minimum block size you want to create; block will be filled with free transactions // until there are no more or the block reaches this size: - unsigned int nBlockMinSize = GetArg("-blockminsize", 0); + unsigned int nBlockMinSize = GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE); nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); // Collect memory pool transactions into the block @@ -254,7 +254,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) continue; // Skip free transactions if we're past the minimum block size: - if (fSortedByFee && (dFeePerKb < CTransaction::nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + if (fSortedByFee && (dFeePerKb < CTransaction::nMinRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) continue; // Prioritize by fee once past the priority size or we run out of high-priority diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 652d39a5ce..d8e21c4aa6 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -78,6 +78,12 @@ static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTrans { QSettings settings; + // Remove old translators + QApplication::removeTranslator(&qtTranslatorBase); + QApplication::removeTranslator(&qtTranslator); + QApplication::removeTranslator(&translatorBase); + QApplication::removeTranslator(&translator); + // Get desired locale (e.g. "de_DE") // 1) System default language QString lang_territory = QLocale::system().name(); @@ -439,21 +445,9 @@ void BitcoinApplication::handleRunawayException(const QString &message) #ifndef BITCOIN_QT_TEST int main(int argc, char *argv[]) { - bool fSelParFromCLFailed = false; /// 1. Parse command-line options. These take precedence over anything else. // Command-line options take precedence: ParseParameters(argc, argv); - // Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause) - if (!SelectParamsFromCommandLine()) { - fSelParFromCLFailed = true; - } -#ifdef ENABLE_WALLET - // Parse URIs on command line -- this can affect Params() - if (!PaymentServer::ipcParseCommandLine(argc, argv)) - exit(0); -#endif - - bool isaTestNet = Params().NetworkID() != CChainParams::MAIN; // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory @@ -480,12 +474,9 @@ int main(int argc, char *argv[]) /// 3. Application identification // must be set before OptionsModel is initialized or translations are loaded, // as it is used to locate QSettings - QApplication::setOrganizationName("Bitcoin"); - QApplication::setOrganizationDomain("bitcoin.org"); - if (isaTestNet) // Separate UI settings for testnets - QApplication::setApplicationName("Bitcoin-Qt-testnet"); - else - QApplication::setApplicationName("Bitcoin-Qt"); + QApplication::setOrganizationName(QAPP_ORG_NAME); + QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN); + QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT); /// 4. Initialization of translations, so that intro dialog is in user's language // Now that QSettings are accessible, initialize translations @@ -501,17 +492,13 @@ int main(int argc, char *argv[]) help.showOrPrint(); return 1; } - // Now that translations are initialized, check for earlier errors and show a translatable error message - if (fSelParFromCLFailed) { - QMessageBox::critical(0, QObject::tr("Bitcoin"), QObject::tr("Error: Invalid combination of -regtest and -testnet.")); - return 1; - } /// 5. Now that settings and translations are available, ask user for data directory // User language is set up: pick a data directory - Intro::pickDataDirectory(isaTestNet); + Intro::pickDataDirectory(); /// 6. Determine availability of data directory and parse bitcoin.conf + /// - Do not call GetDataDir(true) before this step finishes if (!boost::filesystem::is_directory(GetDataDir(false))) { QMessageBox::critical(0, QObject::tr("Bitcoin"), @@ -520,8 +507,33 @@ int main(int argc, char *argv[]) } ReadConfigFile(mapArgs, mapMultiArgs); + /// 7. Determine network (and switch to network specific options) + // - Do not call Params() before this step + // - Do this after parsing the configuration file, as the network can be switched there + // - QSettings() will use the new application name after this, resulting in network-specific settings + // - Needs to be done before createOptionsModel + + // Check for -testnet or -regtest parameter (Params() calls are only valid after this clause) + if (!SelectParamsFromCommandLine()) { + QMessageBox::critical(0, QObject::tr("Bitcoin"), QObject::tr("Error: Invalid combination of -regtest and -testnet.")); + return 1; + } +#ifdef ENABLE_WALLET + // Parse URIs on command line -- this can affect Params() + if (!PaymentServer::ipcParseCommandLine(argc, argv)) + exit(0); +#endif + bool isaTestNet = Params().NetworkID() != CChainParams::MAIN; + // Allow for separate UI settings for testnets + if (isaTestNet) + QApplication::setApplicationName(QAPP_APP_NAME_TESTNET); + else + QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT); + // Re-initialize translations after changing application name (language in network-specific settings can be different) + initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator); + #ifdef ENABLE_WALLET - /// 7. URI IPC sending + /// 8. URI IPC sending // - Do this early as we don't want to bother initializing if we are just calling IPC // - Do this *after* setting up the data directory, as the data directory hash is used in the name // of the server. @@ -535,7 +547,7 @@ int main(int argc, char *argv[]) app.createPaymentServer(); #endif - /// 8. Main GUI initialization + /// 9. Main GUI initialization // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); // Install qDebug() message handler to route to debug.log diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 9f6588bc9e..5ae4bc833d 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -41,4 +41,9 @@ static const int MAX_PAYMENT_REQUEST_SIZE = 50000; // bytes /* Number of frames in spinner animation */ #define SPINNER_FRAMES 35 +#define QAPP_ORG_NAME "Bitcoin" +#define QAPP_ORG_DOMAIN "bitcoin.org" +#define QAPP_APP_NAME_DEFAULT "Bitcoin-Qt" +#define QAPP_APP_NAME_TESTNET "Bitcoin-Qt-testnet" + #endif // GUICONSTANTS_H diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index 42833a8a33..3bc19f8645 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -146,7 +146,7 @@ QString Intro::getDefaultDataDirectory() return QString::fromStdString(GetDefaultDataDir().string()); } -void Intro::pickDataDirectory(bool fIsTestnet) +void Intro::pickDataDirectory() { namespace fs = boost::filesystem; QSettings settings; @@ -164,10 +164,7 @@ void Intro::pickDataDirectory(bool fIsTestnet) /* If current default data directory does not exist, let the user choose one */ Intro intro; intro.setDataDirectory(dataDir); - if (!fIsTestnet) - intro.setWindowIcon(QIcon(":icons/bitcoin")); - else - intro.setWindowIcon(QIcon(":icons/bitcoin_testnet")); + intro.setWindowIcon(QIcon(":icons/bitcoin")); while(true) { diff --git a/src/qt/intro.h b/src/qt/intro.h index 72693d5544..295a75562f 100644 --- a/src/qt/intro.h +++ b/src/qt/intro.h @@ -36,7 +36,7 @@ public: * @note do NOT call global GetDataDir() before calling this function, this * will cause the wrong path to be cached. */ - static void pickDataDirectory(bool fIsTestnet); + static void pickDataDirectory(); /** * Determine default data directory for operating system. diff --git a/src/test/data/script_invalid.json b/src/test/data/script_invalid.json index 761cc4a008..8cb365a46f 100644 --- a/src/test/data/script_invalid.json +++ b/src/test/data/script_invalid.json @@ -325,5 +325,7 @@ ["NOP1 0x01 1", "HASH160 0x14 0xda1745e9b549bd0bfa1a569971c77eba30cd5a4b EQUAL"], ["0 0x01 0x50", "HASH160 0x14 0xece424a6bb6ddf4db592c0faed60685047a361b1 EQUAL", "OP_RESERVED in P2SH should fail"], -["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "OP_VER in P2SH should fail"] +["0 0x01 VER", "HASH160 0x14 0x0f4d7845db968f2a81b530b6f3c1d6246d4c7e01 EQUAL", "OP_VER in P2SH should fail"], + +["0x00", "'00' EQUAL", "Basic OP_0 execution"] ] diff --git a/src/test/data/script_valid.json b/src/test/data/script_valid.json index e4c181cae8..3b4c191865 100644 --- a/src/test/data/script_valid.json +++ b/src/test/data/script_valid.json @@ -411,5 +411,7 @@ ["0x4c 0x40 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242", "0x4d 0x4000 0x42424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 EQUAL", -"Basic PUSHDATA1 signedness check"] +"Basic PUSHDATA1 signedness check"], + +["0x00", "SIZE 0 EQUAL", "Basic OP_0 execution"] ] |