diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-07-09 21:07:10 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-07-09 21:07:13 +0200 |
commit | dac5374ccee6b21605127a6f8000666aab5caecc (patch) | |
tree | 8d974324eef46ed3c7117f7b5ae4528bddcf6dfd | |
parent | dac5d68fc6cf136e0d7b21b9ed4fa053d54e6059 (diff) | |
parent | 9fd3e0001fc20eecbfa823e12f66da4054a072a7 (diff) |
Merge #13455: [0.16.2] Backports
9fd3e0001fc20eecbfa823e12f66da4054a072a7 depends: Update Qt download url (fanquake)
f7401c86b9c9c58cfe57c2a49d3b4e00f80ded4a Fix parameter count check for importpubkey. (Kristaps Kaupe)
cbd2f70b75016bbadeb212c823b5c1ece95d5241 expose CBlockIndex::nTx in getblock(header) (Gregory Sanders)
ce8aa5491f35c2cca03ba1877cd4c926b506a961 Add Windows shutdown handler (Chun Kuan Lee)
18b0c69e2fc9f9d5cd56659abab467c2c6826be2 Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr)
Pull request description:
Backports:
* #12859 Bugfix: Include <memory> for std::unique_ptr
* #13131 Add Windows shutdown handler
* #13451 rpc: expose CBlockIndex::nTx in getblock(header)
* #13507 RPC: Fix parameter count check for importpubkey
* #13544 depends: Update Qt download url
to the 0.16 branch.
Tree-SHA512: eeaec52d001d5c81e67dda3a2d3fee7a9445e569366e597b18e81d802c1b7f89e545afd53d094740c37c1714050304979398b9860144454d3a5cb5abc9e9eaca
39 files changed, 71 insertions, 2 deletions
diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 745c9e1157..34b0fdc636 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,6 +1,6 @@ PACKAGE=qt $(package)_version=5.7.1 -$(package)_download_path=http://download.qt.io/official_releases/qt/5.7/$($(package)_version)/submodules +$(package)_download_path=https://download.qt.io/archive/qt/5.7/$($(package)_version)/submodules $(package)_suffix=opensource-src-$($(package)_version).tar.gz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=95f83e532d23b3ddbde7973f380ecae1bac13230340557276f75f2e37984e410 diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index e9ef75eb7b..2b42faf443 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -15,6 +15,7 @@ #include <util.h> #include <utilstrencodings.h> +#include <memory> #include <stdio.h> #include <event2/buffer.h> diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index f1cf7c9d2d..1522e6b37b 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -22,6 +22,7 @@ #include <utilmoneystr.h> #include <utilstrencodings.h> +#include <memory> #include <stdio.h> #include <boost/algorithm/string.hpp> diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 96e9b2727b..d7a2707ea4 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -11,6 +11,7 @@ #include <utilstrencodings.h> #include <assert.h> +#include <memory> #include <chainparamsseeds.h> diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index a03137f407..dfe7200141 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -9,6 +9,7 @@ #include <util.h> #include <assert.h> +#include <memory> const std::string CBaseChainParams::MAIN = "main"; const std::string CBaseChainParams::TESTNET = "test"; diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index 4e1e403f69..ac122a3545 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -4,6 +4,7 @@ #include <dbwrapper.h> +#include <memory> #include <random.h> #include <leveldb/cache.h> diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 5e9e419744..1d0cfcc55a 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -17,6 +17,8 @@ #include <crypto/hmac_sha256.h> #include <stdio.h> +#include <memory> + #include <boost/algorithm/string.hpp> // boost::trim /** WWW-Authenticate to present with 401 Unauthorized response */ diff --git a/src/httpserver.cpp b/src/httpserver.cpp index f78ce13737..860ca3b8a8 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -13,6 +13,7 @@ #include <sync.h> #include <ui_interface.h> +#include <memory> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/init.cpp b/src/init.cpp index 162c32c38c..382915a633 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -283,6 +283,7 @@ void Shutdown() * The execution context the handler is invoked in is not guaranteed, * so we restrict handler operations to just touching variables: */ +#ifndef WIN32 static void HandleSIGTERM(int) { fRequestShutdown = true; @@ -292,6 +293,14 @@ static void HandleSIGHUP(int) { fReopenDebugLog = true; } +#else +static BOOL WINAPI consoleCtrlHandler(DWORD dwCtrlType) +{ + fRequestShutdown = true; + Sleep(INFINITE); + return true; +} +#endif #ifndef WIN32 static void registerSignalHandler(int signal, void(*handler)(int)) @@ -880,6 +889,8 @@ bool AppInitBasicSetup() // Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly signal(SIGPIPE, SIG_IGN); +#else + SetConsoleCtrlHandler(consoleCtrlHandler, true); #endif std::set_new_handler(new_handler_terminate); diff --git a/src/memusage.h b/src/memusage.h index fea7ecdf9f..0b92e53b48 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -10,6 +10,7 @@ #include <stdlib.h> #include <map> +#include <memory> #include <set> #include <vector> #include <unordered_map> diff --git a/src/miner.cpp b/src/miner.cpp index 298ea066fd..85dbe9c228 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -27,6 +27,7 @@ #include <validationinterface.h> #include <algorithm> +#include <memory> #include <queue> #include <utility> diff --git a/src/net.cpp b/src/net.cpp index ff68b182f0..83bbaafb79 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -20,6 +20,7 @@ #include <ui_interface.h> #include <utilstrencodings.h> +#include <memory> #ifdef WIN32 #include <string.h> #else diff --git a/src/net_processing.cpp b/src/net_processing.cpp index f1260f3ae4..eb5c258049 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -30,6 +30,8 @@ #include <utilmoneystr.h> #include <utilstrencodings.h> +#include <memory> + #if defined(NDEBUG) # error "Bitcoin cannot be compiled without assertions." #endif diff --git a/src/policy/fees.h b/src/policy/fees.h index 96a842b7a1..f53bfbd867 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -12,6 +12,7 @@ #include <sync.h> #include <map> +#include <memory> #include <string> #include <vector> diff --git a/src/qt/bantablemodel.h b/src/qt/bantablemodel.h index a54f8793d0..636ec1f3b1 100644 --- a/src/qt/bantablemodel.h +++ b/src/qt/bantablemodel.h @@ -7,6 +7,8 @@ #include <net.h> +#include <memory> + #include <QAbstractTableModel> #include <QStringList> diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 06e1f1a37c..48e618e9f4 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -36,6 +36,7 @@ #include <wallet/wallet.h> #endif +#include <memory> #include <stdint.h> #include <boost/thread.hpp> diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index bc69d4f945..348308a467 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -16,6 +16,7 @@ #include <wallet/wallet.h> #include <cstdlib> +#include <memory> #include <openssl/x509_vfy.h> diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index e3c9c6e5a3..11bc3ad6fc 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -8,6 +8,8 @@ #include <net_processing.h> // For CNodeStateStats #include <net.h> +#include <memory> + #include <QAbstractTableModel> #include <QStringList> diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp index cd49292138..5c4f5cfc40 100644 --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -18,6 +18,8 @@ #include <qt/recentrequeststablemodel.h> #include <qt/receiverequestdialog.h> +#include <memory> + #include <QAbstractButton> #include <QAction> #include <QApplication> diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h index cd531dba4b..816b0c35af 100644 --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -7,6 +7,8 @@ #include <qt/walletmodel.h> +#include <memory> + #include <QObject> class SendCoinsRecipient; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 14d0541cd7..c092790d64 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -33,6 +33,7 @@ #include <boost/thread/thread.hpp> // boost::thread::interrupt +#include <memory> #include <mutex> #include <condition_variable> @@ -104,6 +105,7 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits))); result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); + result.push_back(Pair("nTx", (uint64_t)blockindex->nTx)); if (blockindex->pprev) result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); @@ -149,6 +151,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.push_back(Pair("bits", strprintf("%08x", block.nBits))); result.push_back(Pair("difficulty", GetDifficulty(blockindex))); result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); + result.push_back(Pair("nTx", (uint64_t)blockindex->nTx)); if (blockindex->pprev) result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); @@ -678,6 +681,7 @@ UniValue getblockheader(const JSONRPCRequest& request) " \"bits\" : \"1d00ffff\", (string) The bits\n" " \"difficulty\" : x.xxx, (numeric) The difficulty\n" " \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n" + " \"nTx\" : n, (numeric) The number of transactions in the block.\n" " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" " \"nextblockhash\" : \"hash\", (string) The hash of the next block\n" "}\n" @@ -747,6 +751,7 @@ UniValue getblock(const JSONRPCRequest& request) " \"bits\" : \"1d00ffff\", (string) The bits\n" " \"difficulty\" : x.xxx, (numeric) The difficulty\n" " \"chainwork\" : \"xxxx\", (string) Expected number of hashes required to produce the chain up to this block (in hex)\n" + " \"nTx\" : n, (numeric) The number of transactions in the block.\n" " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" "}\n" diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index d92ab02d6b..eae96e1429 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -27,6 +27,7 @@ #endif #include <algorithm> +#include <memory> LockedPoolManager* LockedPoolManager::_instance = nullptr; std::once_flag LockedPoolManager::init_flag; diff --git a/src/sync.cpp b/src/sync.cpp index ae6e721466..8b96ee6808 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -4,6 +4,7 @@ #include <sync.h> +#include <memory> #include <set> #include <util.h> #include <utilstrencodings.h> diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp index c177f0bf00..24cd88c7a7 100644 --- a/src/test/allocator_tests.cpp +++ b/src/test/allocator_tests.cpp @@ -7,6 +7,8 @@ #include <support/allocators/secure.h> #include <test/test_bitcoin.h> +#include <memory> + #include <boost/test/unit_test.hpp> BOOST_FIXTURE_TEST_SUITE(allocator_tests, BasicTestingSetup) diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index 754a86344f..4b04653b41 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -7,6 +7,8 @@ #include <random.h> #include <test/test_bitcoin.h> +#include <memory> + #include <boost/test/unit_test.hpp> // Test if a string consists entirely of null characters diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index ca57f58905..f64f23b2da 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -13,6 +13,8 @@ #include <chainparams.h> #include <util.h> +#include <memory> + class CAddrManSerializationMock : public CAddrMan { public: diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h index 234315dbca..fe8c46874e 100644 --- a/src/test/test_bitcoin.h +++ b/src/test/test_bitcoin.h @@ -14,6 +14,8 @@ #include <txdb.h> #include <txmempool.h> +#include <memory> + #include <boost/thread.hpp> extern uint256 insecure_rand_seed; diff --git a/src/test/test_bitcoin_fuzzy.cpp b/src/test/test_bitcoin_fuzzy.cpp index aaba2095e0..69e9804c2f 100644 --- a/src/test/test_bitcoin_fuzzy.cpp +++ b/src/test/test_bitcoin_fuzzy.cpp @@ -25,6 +25,7 @@ #include <unistd.h> #include <algorithm> +#include <memory> #include <vector> enum TEST_ID { diff --git a/src/test/test_bitcoin_main.cpp b/src/test/test_bitcoin_main.cpp index 64408e9c5b..e48c685b6b 100644 --- a/src/test/test_bitcoin_main.cpp +++ b/src/test/test_bitcoin_main.cpp @@ -6,6 +6,8 @@ #include <net.h> +#include <memory> + #include <boost/test/unit_test.hpp> std::unique_ptr<CConnman> g_connman; diff --git a/src/txdb.h b/src/txdb.h index 3edeb4648e..216a612bd7 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -11,6 +11,7 @@ #include <chain.h> #include <map> +#include <memory> #include <string> #include <utility> #include <vector> diff --git a/src/util.h b/src/util.h index c7d1600b4e..288c0437b0 100644 --- a/src/util.h +++ b/src/util.h @@ -23,6 +23,7 @@ #include <atomic> #include <exception> #include <map> +#include <memory> #include <stdint.h> #include <string> #include <vector> diff --git a/src/validation.h b/src/validation.h index 99cbfdf1ee..cd243e2049 100644 --- a/src/validation.h +++ b/src/validation.h @@ -22,6 +22,7 @@ #include <algorithm> #include <exception> #include <map> +#include <memory> #include <set> #include <stdint.h> #include <string> diff --git a/src/wallet/db.h b/src/wallet/db.h index 787135e400..067f7e6da2 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -15,6 +15,7 @@ #include <atomic> #include <map> +#include <memory> #include <string> #include <vector> diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 03fb824e7a..0468996ef5 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -432,7 +432,7 @@ UniValue importpubkey(const JSONRPCRequest& request) return NullUniValue; } - if (request.fHelp || request.params.size() < 1 || request.params.size() > 4) + if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) throw std::runtime_error( "importpubkey \"pubkey\" ( \"label\" rescan )\n" "\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n" diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h index c03aec7f87..e694f2a56a 100644 --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -9,6 +9,8 @@ #include <wallet/wallet.h> +#include <memory> + /** Testing setup and teardown for wallet. */ struct WalletTestingSetup: public TestingSetup { diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 863416760a..c923ab9b92 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -4,6 +4,7 @@ #include <wallet/wallet.h> +#include <memory> #include <set> #include <stdint.h> #include <utility> diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index a4684c2935..faee047aa6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -22,6 +22,7 @@ #include <algorithm> #include <atomic> #include <map> +#include <memory> #include <set> #include <stdexcept> #include <stdint.h> diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index 16ee5e617a..341d71c3cd 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -260,10 +260,17 @@ class PruneTest(BitcoinTestFramework): # should not prune because chain tip of node 3 (995) < PruneAfterHeight (1000) assert_raises_rpc_error(-1, "Blockchain is too short for pruning", node.pruneblockchain, height(500)) + # Save block transaction count before pruning, assert value + block1_details = node.getblock(node.getblockhash(1)) + assert_equal(block1_details["nTx"], len(block1_details["tx"])) + # mine 6 blocks so we are at height 1001 (i.e., above PruneAfterHeight) node.generate(6) assert_equal(node.getblockchaininfo()["blocks"], 1001) + # Pruned block should still know the number of transactions + assert_equal(node.getblockheader(node.getblockhash(1))["nTx"], block1_details["nTx"]) + # negative heights should raise an exception assert_raises_rpc_error(-8, "Negative", node.pruneblockchain, -10) diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 11acff4be1..68386ca0d9 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -185,6 +185,7 @@ class BlockchainTest(BitcoinTestFramework): assert_equal(header['confirmations'], 1) assert_equal(header['previousblockhash'], secondbesthash) assert_is_hex_string(header['chainwork']) + assert_equal(header['nTx'], 1) assert_is_hash_string(header['hash']) assert_is_hash_string(header['previousblockhash']) assert_is_hash_string(header['merkleroot']) |