From bba596df3edbeea3b0c5ff01b8ba6b0070019896 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 9 Jul 2020 15:43:17 +0200 Subject: [PATCH 1/9] Merge #19317: Add a left-justified width field to log2_work component for a uniform debug.log output c8583022800410afeb75e0154df7290d080d581d Change format of log2_work for uniform output (zero-padded) (jmorgan) Pull request description: Motivation: It's jarring to watch the output of `tail -f ~/btcdata/debug.log` scroll by and very frequently see columns not lining up correctly because `log2_work` somtimes has less precision than 8 digits. Current display: ``` 2020-06-18T02:54:42Z UpdateTip: new best=0000000000000000107f877e4920643f9fb06090fa7551cd1cdd83b857f520aa height=382038 version=0x00000003 log2_work=83.558653 tx=90953616 date='2015-11-04T17:11:44Z' progress=0.166675 cache=117.6MiB(966410txo) 2020-06-18T02:54:51Z UpdateTip: new best=0000000000000000019a4de585d30d1a8cc13c7a1972d11b4945635c9556acb5 height=382039 version=0x00000003 log2_work=83.55868 tx=90955936 date='2015-11-04T17:19:39Z' progress=0.166679 cache=117.9MiB(968799txo) ``` Display with this commit: ``` 2020-06-18T02:54:42Z UpdateTip: new best=0000000000000000107f877e4920643f9fb06090fa7551cd1cdd83b857f520aa height=382038 version=0x00000003 log2_work=83.558653 tx=90953616 date='2015-11-04T17:11:44Z' progress=0.166675 cache=117.6MiB(966410txo) 2020-06-18T02:54:51Z UpdateTip: new best=0000000000000000019a4de585d30d1a8cc13c7a1972d11b4945635c9556acb5 height=382039 version=0x00000003 log2_work=83.55868 tx=90955936 date='2015-11-04T17:19:39Z' progress=0.166679 cache=117.9MiB(968799txo) ``` ACKs for top commit: practicalswift: ACK c8583022800410afeb75e0154df7290d080d581d -- patch looks great :) achow101: ACK c8583022800410afeb75e0154df7290d080d581d laanwj: Tested ACK c8583022800410afeb75e0154df7290d080d581d Tree-SHA512: 16cbe419c4993ad51019c676e8ca409ef1025b803cc598437c780dd7ca003d7e4ad421f451e9a374e0070ee9b3ee601b7aba849e1f346798f9321d1bce5c4401 --- src/validation.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 8a39c3b439..ca12e0f20e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1374,12 +1374,12 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew) pindexBestHeader = m_chain.Tip(); } - LogPrintf("%s: invalid block=%s height=%d log2_work=%.8f date=%s\n", __func__, + LogPrintf("%s: invalid block=%s height=%d log2_work=%f date=%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, log(pindexNew->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(pindexNew->GetBlockTime())); CBlockIndex *tip = m_chain.Tip(); assert (tip); - LogPrintf("%s: current best=%s height=%d log2_work=%.8f date=%s\n", __func__, + LogPrintf("%s: current best=%s height=%d log2_work=%f date=%s\n", __func__, tip->GetBlockHash().ToString(), m_chain.Height(), log(tip->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(tip->GetBlockTime())); CheckForkWarningConditions(); @@ -1391,12 +1391,12 @@ void CChainState::ConflictingChainFound(CBlockIndex* pindexNew) statsClient.inc("warnings.ConflictingChainFound", 1.0f); - LogPrintf("%s: conflicting block=%s height=%d log2_work=%.8f date=%s\n", __func__, + LogPrintf("%s: conflicting block=%s height=%d log2_work=%f date=%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, log(pindexNew->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(pindexNew->GetBlockTime())); CBlockIndex *tip = m_chain.Tip(); assert (tip); - LogPrintf("%s: current best=%s height=%d log2_work=%.8f date=%s\n", __func__, + LogPrintf("%s: current best=%s height=%d log2_work=%f date=%s\n", __func__, tip->GetBlockHash().ToString(), m_chain.Height(), log(tip->nChainWork.getdouble())/log(2.0), FormatISO8601DateTime(tip->GetBlockTime())); CheckForkWarningConditions(); @@ -2704,7 +2704,7 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew) } } assert(std::addressof(::ChainstateActive()) == std::addressof(*this)); - LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo) evodb_cache=%.1fMiB%s\n", __func__, + LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%f tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo) evodb_cache=%.1fMiB%s\n", __func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion, log(pindexNew->nChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx, FormatISO8601DateTime(pindexNew->GetBlockTime()), From b64081bf3d0b00037b67e8fb94112ddf8b6f5d90 Mon Sep 17 00:00:00 2001 From: Samuel Dobson Date: Sat, 11 Jul 2020 22:19:05 +1200 Subject: [PATCH 2/9] Merge #18850: wallet: Fix ZapSelectTx to sync wallet spends 9c59f9c285303659ee1beed7555bbb322e6e6981 Fix ZapSelectTx to sync wallet spends (Anthony Fieroni) Pull request description: Signed-off-by: Anthony Fieroni ACKs for top commit: achow101: ACK 9c59f9c285303659ee1beed7555bbb322e6e6981 ryanofsky: Code review ACK 9c59f9c285303659ee1beed7555bbb322e6e6981. Only change since last review tweaking the for loop as suggested jonatack: ACK 9c59f9c285303659ee1beed7555bbb322e6e6981 tested rebased on current master b33136b6ba9887f7d and the new unit test does indeed fail without the change. meshcollider: utACK 9c59f9c285303659ee1beed7555bbb322e6e6981 Tree-SHA512: 71672a5ab0c659550c3a40577614ea896412b79566b5672636ab18765e4c71b9d0a990d94dc6b6e623b03a05737022b04026b5699438809c7c54782d0fd0a5d2 --- src/wallet/test/wallet_tests.cpp | 33 ++++++++++++++++++++++++++++++++ src/wallet/wallet.cpp | 4 +++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 4f88664d53..29754a962a 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -1360,4 +1360,37 @@ BOOST_FIXTURE_TEST_CASE(dummy_input_size_test, TestChain100Setup) BOOST_CHECK_EQUAL(CalculateNestedKeyhashInputSize(true), DUMMY_NESTED_P2PKH_INPUT_SIZE + 1); } +BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup) +{ + auto chain = interfaces::MakeChain(m_node); + auto wallet = TestLoadWallet(m_node); + CKey key; + key.MakeNewKey(true); + AddKey(*wallet, key); + + std::string error; + m_coinbase_txns.push_back(CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]); + auto block_tx = TestSimpleSpend(*m_coinbase_txns[0], 0, coinbaseKey, GetScriptForRawPubKey(key.GetPubKey())); + CreateAndProcessBlock({block_tx}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); + + SyncWithValidationInterfaceQueue(); + + { + auto block_hash = block_tx.GetHash(); + auto prev_hash = m_coinbase_txns[0]->GetHash(); + + LOCK(wallet->cs_wallet); + BOOST_CHECK(wallet->HasWalletSpend(prev_hash)); + BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 1); + + std::vector vHashIn{ block_hash }, vHashOut; + BOOST_CHECK_EQUAL(wallet->ZapSelectTx(vHashIn, vHashOut), DBErrors::LOAD_OK); + + BOOST_CHECK(!wallet->HasWalletSpend(prev_hash)); + BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 0); + } + + TestUnloadWallet(std::move(wallet)); +} + BOOST_AUTO_TEST_SUITE_END() diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1737d6b515..c42ffc6dd3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3912,9 +3912,11 @@ DBErrors CWallet::ZapSelectTx(std::vector& vHashIn, std::vectorsecond.m_it_wtxOrdered); + for (const auto& txin : it->second.tx->vin) + mapTxSpends.erase(txin.prevout); mapWallet.erase(it); NotifyTransactionChanged(this, hash, CT_DELETED); } From 21e1a4a881d8c6236b66411b47a1c1bfe5a9ecda Mon Sep 17 00:00:00 2001 From: mrbandrews Date: Fri, 9 Dec 2016 13:45:27 -0500 Subject: [PATCH 3/9] partial Merge #8456: [RPC] Simplified bumpfee command. It includes only this commit for sake of backporting HasWalletSpent [RPC] bumpfee This command allows a user to increase the fee on a wallet transaction T, creating a "bumper" transaction B. T must signal that it is BIP-125 replaceable. T's change output is decremented to pay the additional fee. (B will not add inputs to T.) T cannot have any descendant transactions. Once B bumps T, neither T nor B's outputs can be spent until either T or (more likely) B is mined. Includes code by @jonasschnelli and @ryanofsky --- src/wallet/wallet.cpp | 7 +++++++ src/wallet/wallet.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c42ffc6dd3..9d52273549 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -495,6 +495,13 @@ std::set CWallet::GetConflicts(const uint256& txid) const return result; } +bool CWallet::HasWalletSpend(const uint256& txid) const +{ + AssertLockHeld(cs_wallet); + auto iter = mapTxSpends.lower_bound(COutPoint(txid, 0)); + return (iter != mapTxSpends.end() && iter->first.hash == txid); +} + void CWallet::Flush() { GetDatabase().Flush(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 55024c86c4..3db4953c20 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1190,6 +1190,9 @@ public: //! Get wallet transactions that conflict with given transaction (spend same outputs) std::set GetConflicts(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); + //! Check if a given transaction has any of its outputs spent by another transaction in the wallet + bool HasWalletSpend(const uint256& txid) const; + //! Flush wallet (bitdb flush) void Flush(); From c95bbed0aa6430b2dd44093e631b13dd32767ec1 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sat, 11 Jul 2020 19:12:34 +0200 Subject: [PATCH 4/9] Merge #19493: wallet: Fix clang build in Mac 1e58bcc9afefcf009653567c6373b4f7facba8f5 wallet: Fix clang build in Mac (Anthony Fieroni) Pull request description: Signed-off-by: Anthony Fieroni Top commit has no ACKs. Tree-SHA512: 19312929af14dab97c37cf4547fbd6589a6de960f1a499c2118bb684240639af4b127cf8dc4d201b41d253cfbb645614a0606d4ecce29f300b10c210d38a961b --- src/wallet/test/wallet_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 29754a962a..8639db32cf 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -1381,13 +1381,13 @@ BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup) LOCK(wallet->cs_wallet); BOOST_CHECK(wallet->HasWalletSpend(prev_hash)); - BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 1); + BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 1u); std::vector vHashIn{ block_hash }, vHashOut; BOOST_CHECK_EQUAL(wallet->ZapSelectTx(vHashIn, vHashOut), DBErrors::LOAD_OK); BOOST_CHECK(!wallet->HasWalletSpend(prev_hash)); - BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 0); + BOOST_CHECK_EQUAL(wallet->mapWallet.count(block_hash), 0u); } TestUnloadWallet(std::move(wallet)); From feb636352a21c781bd25c729f3dd003fc50e4526 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 25 Aug 2020 11:09:05 +0800 Subject: [PATCH 5/9] Merge #15704: Move Win32 defines to configure.ac to ensure they are globally defined 1ccb9f30c040daf688f89f0d63e9f5e7b131d193 Move Win32 defines to configure.ac to ensure they are globally defined (Luke Dashjr) Pull request description: #9245 no longer needs this, since the main `_WIN32_WINNT` got bumped by something else. So rather than just lose it, might as well get it merged in independently. I'm not aware of any practical effects, but it seems safer to use the same API versions everywhere. ACKs for top commit: fanquake: ACK 1ccb9f30c040daf688f89f0d63e9f5e7b131d193 - checked that the binaries produced are the same. Tree-SHA512: 273e9186579197be01b443b6968e26b9a8031d356fabc5b73aa967fcdb837df195b7ce0fc4e4529c85d9b86da6f2d7ff1bf56a3ff0cbbcd8cee8a9c2bf70a244 --- configure.ac | 2 +- src/compat.h | 3 --- src/qt/guiutil.cpp | 5 ----- src/support/lockedpool.cpp | 1 - src/util/system.cpp | 6 ------ 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 206b4935b1..bc003af93c 100644 --- a/configure.ac +++ b/configure.ac @@ -691,7 +691,7 @@ case $host in AC_MSG_ERROR("windres not found") fi - CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0601" + CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override diff --git a/src/compat.h b/src/compat.h index 39650bfe51..61399a7a2a 100644 --- a/src/compat.h +++ b/src/compat.h @@ -11,9 +11,6 @@ #endif #ifdef WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif #ifndef NOMINMAX #define NOMINMAX #endif diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 8eb39b501d..4b8d564701 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -27,11 +27,6 @@ #include #ifdef WIN32 -#ifdef _WIN32_IE -#undef _WIN32_IE -#endif -#define _WIN32_IE 0x0501 -#define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX #endif diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index a0ba8ed142..bd4f64234b 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -10,7 +10,6 @@ #endif #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX #endif diff --git a/src/util/system.cpp b/src/util/system.cpp index f68d7ccb7e..55dd227270 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -52,12 +52,6 @@ #pragma warning(disable:4717) #endif -#ifdef _WIN32_IE -#undef _WIN32_IE -#endif -#define _WIN32_IE 0x0501 - -#define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX #endif From fb274b16da68efd74616de3a7de2a8349ebe9940 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 28 Aug 2020 16:44:45 +0200 Subject: [PATCH 6/9] Merge #19739: refactor: remove c-string interfaces for DecodeBase58{Check} d3e8adfada889a3c9fba930086eda609509aca07 util: remove c-string interfaces for DecodeBase58{Check} (Sebastian Falbesoner) Pull request description: This micro-PR gets rid of base58 function interfaces that are redundant in terms of c-string / std::string variants; the c-string interface for `DecodeBase58Check` is completely unused outside the base58 module, while the c-string interface for `DecodeBase58` is only used in unit tests, where an implicit conversion to std::string is not problematic. ACKs for top commit: practicalswift: ACK d3e8adfada889a3c9fba930086eda609509aca07 -- patch looks correct laanwj: Code review ACK d3e8adfada889a3c9fba930086eda609509aca07 Tree-SHA512: 006a4a1e23b11385f60820c188b8e6b1634a182ca36e29a6580f72150214c65a3fdb273ec439165f26ba88a42d2bf5bab1cf3666a9eaee222fb4e1c00aeba433 --- src/base58.cpp | 4 ++-- src/base58.h | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/base58.cpp b/src/base58.cpp index 1454cc6f87..dd2f9eea9a 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -35,7 +35,7 @@ static const int8_t mapBase58[256] = { -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, }; -bool DecodeBase58(const char* psz, std::vector& vch, int max_ret_len) +[[nodiscard]] static bool DecodeBase58(const char* psz, std::vector& vch, int max_ret_len) { // Skip leading spaces. while (*psz && IsSpace(*psz)) @@ -141,7 +141,7 @@ std::string EncodeBase58Check(Span input) return EncodeBase58(vch); } -bool DecodeBase58Check(const char* psz, std::vector& vchRet, int max_ret_len) +[[nodiscard]] static bool DecodeBase58Check(const char* psz, std::vector& vchRet, int max_ret_len) { if (!DecodeBase58(psz, vchRet, max_ret_len > std::numeric_limits::max() - 4 ? std::numeric_limits::max() : max_ret_len + 4) || (vchRet.size() < 4)) { diff --git a/src/base58.h b/src/base58.h index d339e48ceb..60551a12ae 100644 --- a/src/base58.h +++ b/src/base58.h @@ -25,13 +25,6 @@ */ std::string EncodeBase58(Span input); -/** - * Decode a base58-encoded string (psz) into a byte vector (vchRet). - * return true if decoding is successful. - * psz cannot be nullptr. - */ -[[nodiscard]] bool DecodeBase58(const char* psz, std::vector& vchRet, int max_ret_len); - /** * Decode a base58-encoded string (str) into a byte vector (vchRet). * return true if decoding is successful. @@ -43,12 +36,6 @@ std::string EncodeBase58(Span input); */ std::string EncodeBase58Check(Span input); -/** - * Decode a base58-encoded string (psz) that includes a checksum into a byte - * vector (vchRet), return true if decoding is successful - */ -[[nodiscard]] bool DecodeBase58Check(const char* psz, std::vector& vchRet, int max_ret_len); - /** * Decode a base58-encoded string (str) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful From 2870a683f7722a3664fbe95e825b2a20932f6074 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 15 Sep 2020 11:27:50 +0800 Subject: [PATCH 7/9] Merge #19903: Update build-openbsd.md with GUI support d11020019a0c93dcc56859cdfcd9f0c6a777424f Add OpenBSD instructions for building the Qt GUI (grubles) Pull request description: Using OpenBSD as a desktop OS is prevalent enough IMO to warrant updating the documentation for building the GUI. ACKs for top commit: fanquake: ACK d11020019a0c93dcc56859cdfcd9f0c6a777424f - looks fine. Have not tested. Tree-SHA512: a8078334fdd35438bcf87c3f5eae851c2a1ce961eb48ae50770bf2c556489da86b6ee198fe9fb732dcaddb2e0f2f4f55a3126971aae8f7d4e2e320dbb024e204 --- doc/build-openbsd.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index 9ad2dd006b..addfe4c8b2 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -2,9 +2,7 @@ OpenBSD build guide ====================== (updated for OpenBSD 6.2) -This guide describes how to build dashd and command-line utilities on OpenBSD. - -OpenBSD is most commonly used as a server OS, so this guide does not contain instructions for building the GUI. +This guide describes how to build dashd, dash-qt, and command-line utilities on OpenBSD. Preparation ------------- @@ -13,6 +11,7 @@ Run the following as root to install the base dependencies for building: ```bash pkg_add git gmake libevent libtool +pkg_add qt5 # (optional for enabling the GUI) pkg_add autoconf # (select highest version, e.g. 2.69) pkg_add automake # (select highest version, e.g. 1.15) pkg_add python # (select highest version, e.g. 3.6) @@ -75,6 +74,14 @@ To configure without wallet: ./configure --disable-wallet --with-gui=no CC=cc CXX=c++ MAKE=gmake ``` +To configure with GUI: +```bash +./configure --with-gui=yes CC=cc CXX=c++ \ + BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" \ + BDB_CFLAGS="-I${BDB_PREFIX}/include" \ + MAKE=gmake +``` + Build and run the tests: ```bash gmake # use -jX here for parallelism From a5cb05792721d90de9e438119e715f81d73bc779 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 15 Sep 2020 15:45:11 +0200 Subject: [PATCH 8/9] Merge #19241: help: Generate checkpoint height from chainparams 916d3596c493fec44da86aeb92b61eafeea0b596 help: Generate checkpoint height from chainparams (Luke Dashjr) Pull request description: Not sure if this is worth putting in Core, but might as well until checkpoints are removed entirely. ACKs for top commit: laanwj: re-ACK 916d3596c493fec44da86aeb92b61eafeea0b596 Tree-SHA512: d8eb26b570ee730fdd75ca916507134db5f2f68987a911e33544b7f1c9ccfd1c76b9c9db63056971956b6daf16910f17ecfc197481c2f7b0773afdfbf7d381cf --- src/chainparams.h | 5 +++++ src/init.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/chainparams.h b/src/chainparams.h index bf36b4b851..e665b6aaf5 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -23,6 +23,11 @@ typedef std::map MapCheckpoints; struct CCheckpointData { MapCheckpoints mapCheckpoints; + + int GetHeight() const { + const auto& final_checkpoint = mapCheckpoints.rbegin(); + return final_checkpoint->first /* height */; + } }; struct AssumeutxoHash : public BaseHash { diff --git a/src/init.cpp b/src/init.cpp index df6f3c4a95..33eab110c2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -705,7 +705,7 @@ void SetupServerArgs(NodeContext& node) argsman.AddArg("-checkblocks=", strprintf("How many blocks to check at startup (default: %u, 0 = all)", DEFAULT_CHECKBLOCKS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-checklevel=", strprintf("How thorough the block verification of -checkblocks is: %s (0-4, default: %u)", Join(CHECKLEVEL_DOC, ", "), DEFAULT_CHECKLEVEL), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-checkmempool=", strprintf("Run checks every transactions (default: %u, regtest: %u)", defaultChainParams->DefaultConsistencyChecks(), regtestChainParams->DefaultConsistencyChecks()), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); - argsman.AddArg("-checkpoints", strprintf("Enable rejection of any forks from the known historical chain until block 1450000 (default: %u)", DEFAULT_CHECKPOINTS_ENABLED), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); + argsman.AddArg("-checkpoints", strprintf("Enable rejection of any forks from the known historical chain until block %s (default: %u)", defaultChainParams->Checkpoints().GetHeight(), DEFAULT_CHECKPOINTS_ENABLED), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-deprecatedrpc=", "Allows deprecated RPC method(s) to be used", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-limitancestorcount=", strprintf("Do not accept transactions if number of in-mempool ancestors is or more (default: %u)", DEFAULT_ANCESTOR_LIMIT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-limitancestorsize=", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); From 4293cbdb53d29247a47a872b17c90c198a4518f7 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 29 Sep 2020 15:16:44 +0200 Subject: [PATCH 9/9] Merge #20003: net: Exit with error message if -proxy is specified without arguments (instead of continuing without proxy server) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 9b4fa0af40cd88ed25dd77962235fbf268bdcaa7 net: Print error message if -proxy is specified without arguments (instead of continuing without proxy server) (practicalswift) Pull request description: Exit with error message if `-proxy` is specified without arguments (instead of continuing without proxy server). Continuing without a proxy server when the end-user has specified `-proxy` may result in accidental loss of privacy. (The end-user might think he/she is using a proxy when he/she is not.) Before this patch: ``` $ src/bitcoind -proxy … 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -proxy set -> setting -listen=0 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -proxy set -> setting -upnp=0 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -proxy set -> setting -discover=0 2020-09-23T00:24:33Z InitParameterInteraction: parameter interaction: -listen=0 -> setting -listenonion=0 … 2020-09-23T00:24:33Z init message: Starting network threads... ``` `bitcoind` is now running *without* a proxy server (`GetProxy(…, …) == false`, `HaveNameProxy() == false`, etc.). Note that the "-proxy set" log messages above which the end-user might interpret as "good, my traffic is now routed via the proxy". After this patch: ``` $ src/bitcoind -proxy Error: No proxy server specified. Use -proxy= or -proxy=. $ echo $? 1 ``` ACKs for top commit: laanwj: re-ACK 9b4fa0af40cd88ed25dd77962235fbf268bdcaa7 kristapsk: ACK 9b4fa0af40cd88ed25dd77962235fbf268bdcaa7, I have tested the code. hebasto: re-ACK 9b4fa0af40cd88ed25dd77962235fbf268bdcaa7 Tree-SHA512: 4ba7a011991699a54b5bb87ec68367c681231bf5dcd36f8c89ff9ddc2e8d29df453817b7e362597e652ad6b341a22b7274be0fd78d435e5f0fd8058e5221c4ce --- src/init.cpp | 4 ++++ test/functional/feature_config_args.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 33eab110c2..9548a6573c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1419,6 +1419,10 @@ bool AppInitParameterInteraction(const ArgsManager& args) nMaxTipAge = args.GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); + if (args.IsArgSet("-proxy") && args.GetArg("-proxy", "").empty()) { + return InitError(_("No proxy server specified. Use -proxy= or -proxy=.")); + } + try { const bool fRecoveryEnabled{llmq::utils::QuorumDataRecoveryEnabled()}; const bool fQuorumVvecRequestsEnabled{llmq::utils::GetEnabledQuorumVvecSyncEntries().size() > 0}; diff --git a/test/functional/feature_config_args.py b/test/functional/feature_config_args.py index f7e913320f..fd161bf4ae 100755 --- a/test/functional/feature_config_args.py +++ b/test/functional/feature_config_args.py @@ -81,6 +81,11 @@ class ConfArgsTest(BitcoinTestFramework): with open(inc_conf_file2_path, 'w', encoding='utf-8') as conf: conf.write('') # clear + def test_invalid_command_line_options(self): + self.nodes[0].assert_start_raises_init_error( + expected_msg='Error: No proxy server specified. Use -proxy= or -proxy=.', + extra_args=['-proxy'], + ) def test_log_buffer(self): with self.nodes[0].assert_debug_log(expected_msgs=['Warning: parsed potentially confusing double-negative -connect=0\n']): @@ -124,6 +129,7 @@ class ConfArgsTest(BitcoinTestFramework): self.test_config_file_parser() + self.test_invalid_command_line_options() # Remove the -datadir argument so it doesn't override the config file self.nodes[0].args = [arg for arg in self.nodes[0].args if not arg.startswith("-datadir")]