aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.md2
-rw-r--r--configure.ac15
-rw-r--r--contrib/macdeploy/README.md2
-rw-r--r--depends/builders/darwin.mk4
-rw-r--r--doc/bips.md14
-rw-r--r--doc/developer-notes.md29
-rw-r--r--src/.clang-format1
-rw-r--r--src/Makefile.test.include7
-rw-r--r--src/arith_uint256.cpp2
-rw-r--r--src/arith_uint256.h2
-rw-r--r--src/bench/base58.cpp1
-rw-r--r--src/bench/bench.h1
-rw-r--r--src/bench/block_assemble.cpp1
-rw-r--r--src/bench/chacha20.cpp1
-rw-r--r--src/bench/chacha_poly_aead.cpp1
-rw-r--r--src/bench/crypto_hash.cpp1
-rw-r--r--src/bench/duplicate_inputs.cpp3
-rw-r--r--src/bench/lockedpool.cpp1
-rw-r--r--src/bench/mempool_eviction.cpp2
-rw-r--r--src/bench/poly1305.cpp1
-rw-r--r--src/bench/rollingbloom.cpp1
-rw-r--r--src/bench/rpc_blockchain.cpp1
-rw-r--r--src/bench/rpc_mempool.cpp2
-rw-r--r--src/bitcoin-cli.cpp16
-rw-r--r--src/bitcoin-tx.cpp1
-rw-r--r--src/bitcoin-wallet.cpp2
-rw-r--r--src/bitcoind.cpp1
-rw-r--r--src/blockencodings.h1
-rw-r--r--src/compressor.cpp1
-rw-r--r--src/consensus/merkle.h2
-rw-r--r--src/consensus/params.h2
-rw-r--r--src/crypto/aes.cpp1
-rw-r--r--src/crypto/chacha_poly_aead.cpp1
-rw-r--r--src/crypto/sha256.cpp1
-rw-r--r--src/crypto/sha256_shani.cpp1
-rw-r--r--src/dbwrapper.h1
-rw-r--r--src/dummywallet.cpp1
-rw-r--r--src/httprpc.cpp2
-rw-r--r--src/httprpc.h2
-rw-r--r--src/httpserver.cpp1
-rw-r--r--src/httpserver.h1
-rw-r--r--src/index/base.h1
-rw-r--r--src/interfaces/chain.cpp7
-rw-r--r--src/interfaces/chain.h5
-rw-r--r--src/interfaces/node.cpp3
-rw-r--r--src/interfaces/wallet.cpp10
-rw-r--r--src/key_io.cpp1
-rw-r--r--src/logging.cpp24
-rw-r--r--src/miner.cpp2
-rw-r--r--src/net.cpp3
-rw-r--r--src/net_processing.cpp1
-rw-r--r--src/netaddress.h1
-rw-r--r--src/node/coinstats.cpp2
-rw-r--r--src/node/transaction.cpp1
-rw-r--r--src/node/transaction.h1
-rw-r--r--src/noui.cpp2
-rw-r--r--src/policy/fees.cpp1
-rw-r--r--src/prevector.h1
-rw-r--r--src/primitives/block.cpp1
-rw-r--r--src/protocol.h1
-rw-r--r--src/psbt.cpp1
-rw-r--r--src/qt/bantablemodel.cpp2
-rw-r--r--src/qt/bitcoin.cpp1
-rw-r--r--src/qt/bitcoingui.cpp2
-rw-r--r--src/qt/coincontroldialog.cpp1
-rw-r--r--src/qt/forms/signverifymessagedialog.ui18
-rw-r--r--src/qt/peertablemodel.cpp1
-rw-r--r--src/qt/rpcconsole.cpp16
-rw-r--r--src/qt/rpcconsole.h12
-rw-r--r--src/qt/signverifymessagedialog.cpp1
-rw-r--r--src/qt/splashscreen.cpp1
-rw-r--r--src/qt/test/paymentservertests.cpp1
-rw-r--r--src/qt/transactiondesc.cpp1
-rw-r--r--src/qt/walletframe.cpp1
-rw-r--r--src/qt/walletmodel.h1
-rw-r--r--src/qt/walletmodeltransaction.h1
-rw-r--r--src/random.cpp4
-rw-r--r--src/rest.cpp1
-rw-r--r--src/rpc/blockchain.cpp1
-rw-r--r--src/rpc/client.cpp1
-rw-r--r--src/rpc/misc.cpp1
-rw-r--r--src/rpc/net.cpp1
-rw-r--r--src/rpc/rawtransaction.cpp2
-rw-r--r--src/rpc/server.cpp2
-rw-r--r--src/rpc/server.h2
-rw-r--r--src/script/interpreter.h1
-rw-r--r--src/script/keyorigin.h1
-rw-r--r--src/script/sign.h1
-rw-r--r--src/script/standard.h1
-rw-r--r--src/serialize.h1
-rw-r--r--src/streams.h2
-rw-r--r--src/sync.cpp2
-rw-r--r--src/test/bip32_tests.cpp1
-rw-r--r--src/test/blockfilter_index_tests.cpp20
-rw-r--r--src/test/compress_tests.cpp1
-rw-r--r--src/test/fs_tests.cpp2
-rw-r--r--src/test/fuzz/spanparsing.cpp30
-rw-r--r--src/test/key_properties.cpp1
-rw-r--r--src/test/policyestimator_tests.cpp1
-rw-r--r--src/test/pow_tests.cpp1
-rw-r--r--src/test/skiplist_tests.cpp1
-rw-r--r--src/test/streams_tests.cpp1
-rw-r--r--src/test/txindex_tests.cpp1
-rw-r--r--src/test/util_tests.cpp18
-rw-r--r--src/threadinterrupt.h1
-rw-r--r--src/torcontrol.h1
-rw-r--r--src/txdb.h1
-rw-r--r--src/txmempool.h1
-rw-r--r--src/ui_interface.h1
-rw-r--r--src/uint256.cpp1
-rw-r--r--src/uint256.h1
-rw-r--r--src/util/moneystr.cpp1
-rw-r--r--src/util/moneystr.h1
-rw-r--r--src/util/string.h1
-rw-r--r--src/util/system.cpp1
-rw-r--r--src/util/threadnames.cpp1
-rw-r--r--src/util/translation.h1
-rw-r--r--src/validation.cpp3
-rw-r--r--src/validation.h2
-rw-r--r--src/validationinterface.cpp2
-rw-r--r--src/wallet/crypter.cpp3
-rw-r--r--src/wallet/crypter.h1
-rw-r--r--src/wallet/db.h2
-rw-r--r--src/wallet/feebumper.cpp78
-rw-r--r--src/wallet/feebumper.h8
-rw-r--r--src/wallet/fees.cpp1
-rw-r--r--src/wallet/init.cpp3
-rw-r--r--src/wallet/ismine.cpp1
-rw-r--r--src/wallet/psbtwallet.h2
-rw-r--r--src/wallet/rpcdump.cpp1
-rw-r--r--src/wallet/rpcwallet.cpp8
-rw-r--r--src/wallet/wallet.cpp9
-rw-r--r--src/wallet/wallet.h1
-rw-r--r--src/wallet/walletdb.h3
-rw-r--r--src/wallet/wallettool.h1
-rw-r--r--src/warnings.h1
-rw-r--r--src/zmq/zmqconfig.h2
-rw-r--r--src/zmq/zmqnotificationinterface.cpp1
-rw-r--r--src/zmq/zmqnotificationinterface.h2
-rwxr-xr-xtest/functional/feature_block.py6
-rwxr-xr-xtest/functional/p2p_segwit.py12
-rw-r--r--test/functional/test_framework/script.py6
142 files changed, 267 insertions, 269 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index bf094e8325..fb91208954 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,6 +1,6 @@
---
name: Bug report
-about: Create a report to help us improve
+about: Create a report to help us improve (use this for suspected bugs only, if not sure, open a regular issue below)
title: ''
labels: Bug
assignees: ''
diff --git a/configure.ac b/configure.ac
index d25e0f4496..715b65f091 100644
--- a/configure.ac
+++ b/configure.ac
@@ -753,12 +753,17 @@ if test x$use_hardening != xno; then
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"])
- AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
- AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
- HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
+ # When enable_debug is yes, all optimizations are disabled.
+ # However, FORTIFY_SOURCE requires that there is some level of optimization, otherwise it does nothing and just creates a compiler warning.
+ # Since FORTIFY_SOURCE is a no-op without optimizations, do not enable it when enable_debug is yes.
+ if test x$enable_debug != xyes; then
+ AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
+ AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
+ HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
+ ])
+ HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
])
- HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
- ])
+ fi
AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])
diff --git a/contrib/macdeploy/README.md b/contrib/macdeploy/README.md
index e90120ea79..29b49ebff4 100644
--- a/contrib/macdeploy/README.md
+++ b/contrib/macdeploy/README.md
@@ -11,5 +11,5 @@ This script should not be run manually, instead, after building as usual:
During the process, the disk image window will pop up briefly where the fancy
settings are applied. This is normal, please do not interfere.
-When finished, it will produce `Bitcoin-Core.dmg`.
+When finished, it will produce `Bitcoin-Qt.dmg`.
diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk
index c7671c1548..eb587fca89 100644
--- a/depends/builders/darwin.mk
+++ b/depends/builders/darwin.mk
@@ -10,8 +10,8 @@ build_darwin_SHA256SUM=shasum -a 256
build_darwin_DOWNLOAD=curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o
#darwin host on darwin builder. overrides darwin host preferences.
-darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION)
-darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++
+darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(shell xcrun --show-sdk-path)
+darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++ --sysroot $(shell xcrun --show-sdk-path)
darwin_AR:=$(shell xcrun -f ar)
darwin_RANLIB:=$(shell xcrun -f ranlib)
darwin_STRIP:=$(shell xcrun -f strip)
diff --git a/doc/bips.md b/doc/bips.md
index 90d0e341df..45562cec62 100644
--- a/doc/bips.md
+++ b/doc/bips.md
@@ -18,23 +18,23 @@ BIPs that are implemented by Bitcoin Core (up-to-date up to **v0.19.0**):
* [`BIP 61`](https://github.com/bitcoin/bips/blob/master/bip-0061.mediawiki): The 'reject' protocol message (and the protocol version bump to 70002) was added in **v0.9.0** ([PR #3185](https://github.com/bitcoin/bitcoin/pull/3185)). Starting **v0.17.0**, whether to send reject messages can be configured with the `-enablebip61` option, and support is deprecated (disabled by default) as of **v0.18.0**. Support was removed in **v0.20.0** ([PR #15437](https://github.com/bitcoin/bitcoin/pull/15437)).
* [`BIP 65`](https://github.com/bitcoin/bips/blob/master/bip-0065.mediawiki): The CHECKLOCKTIMEVERIFY softfork was merged in **v0.12.0** ([PR #6351](https://github.com/bitcoin/bitcoin/pull/6351)), and backported to **v0.11.2** and **v0.10.4**. Mempool-only CLTV was added in [PR #6124](https://github.com/bitcoin/bitcoin/pull/6124).
* [`BIP 66`](https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki): The strict DER rules and associated version 3 blocks have been implemented since **v0.10.0** ([PR #5713](https://github.com/bitcoin/bitcoin/pull/5713)).
-* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been activated since *block 419328*.
+* [`BIP 68`](https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki): Sequence locks have been implemented as of **v0.12.1** ([PR #7184](https://github.com/bitcoin/bitcoin/pull/7184)), and have been *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
* [`BIP 70`](https://github.com/bitcoin/bips/blob/master/bip-0070.mediawiki) [`71`](https://github.com/bitcoin/bips/blob/master/bip-0071.mediawiki) [`72`](https://github.com/bitcoin/bips/blob/master/bip-0072.mediawiki): Payment Protocol support has been available in Bitcoin Core GUI since **v0.9.0** ([PR #5216](https://github.com/bitcoin/bitcoin/pull/5216)). Support can be optionally disabled at build time since **v0.18.0** ([PR 14451](https://github.com/bitcoin/bitcoin/pull/14451)), and is disabled by default at build time since **v0.19.0** ([PR #15584](https://github.com/bitcoin/bitcoin/pull/15584)).
* [`BIP 90`](https://github.com/bitcoin/bips/blob/master/bip-0090.mediawiki): Trigger mechanism for activation of BIPs 34, 65, and 66 has been simplified to block height checks since **v0.14.0** ([PR #8391](https://github.com/bitcoin/bitcoin/pull/8391)).
* [`BIP 111`](https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki): `NODE_BLOOM` service bit added, and enforced for all peer versions as of **v0.13.0** ([PR #6579](https://github.com/bitcoin/bitcoin/pull/6579) and [PR #6641](https://github.com/bitcoin/bitcoin/pull/6641)).
-* [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki): The CHECKSEQUENCEVERIFY opcode has been implemented since **v0.12.1** ([PR #7524](https://github.com/bitcoin/bitcoin/pull/7524)) and has been activated since *block 419328*.
-* [`BIP 113`](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki): Median time past lock-time calculations have been implemented since **v0.12.1** ([PR #6566](https://github.com/bitcoin/bitcoin/pull/6566)) and have been activated since *block 419328*.
+* [`BIP 112`](https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki): The CHECKSEQUENCEVERIFY opcode has been implemented since **v0.12.1** ([PR #7524](https://github.com/bitcoin/bitcoin/pull/7524)), and has been *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
+* [`BIP 113`](https://github.com/bitcoin/bips/blob/master/bip-0113.mediawiki): Median time past lock-time calculations have been implemented since **v0.12.1** ([PR #6566](https://github.com/bitcoin/bitcoin/pull/6566)), and has been *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
* [`BIP 125`](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki): Opt-in full replace-by-fee signaling honoured in mempool and mining as of **v0.12.0** ([PR 6871](https://github.com/bitcoin/bitcoin/pull/6871)). Enabled by default in the wallet GUI as of **v0.18.1** ([PR #11605](https://github.com/bitcoin/bitcoin/pull/11605))
* [`BIP 130`](https://github.com/bitcoin/bips/blob/master/bip-0130.mediawiki): direct headers announcement is negotiated with peer versions `>=70012` as of **v0.12.0** ([PR 6494](https://github.com/bitcoin/bitcoin/pull/6494)).
* [`BIP 133`](https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki): feefilter messages are respected and sent for peer versions `>=70013` as of **v0.13.0** ([PR 7542](https://github.com/bitcoin/bitcoin/pull/7542)).
-* [`BIP 141`](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki): Segregated Witness (Consensus Layer) as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)), and defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
-* [`BIP 143`](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki): Transaction Signature Verification for Version 0 Witness Program as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)) and defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
+* [`BIP 141`](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki): Segregated Witness (Consensus Layer) as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)), defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)), and *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
+* [`BIP 143`](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki): Transaction Signature Verification for Version 0 Witness Program as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)), defined for mainnet as of **v0.13.1** ([PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)), and *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
* [`BIP 144`](https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki): Segregated Witness as of **0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)).
* [`BIP 145`](https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki): getblocktemplate updates for Segregated Witness as of **v0.13.0** ([PR 8149](https://github.com/bitcoin/bitcoin/pull/8149)).
-* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)).
+* [`BIP 147`](https://github.com/bitcoin/bips/blob/master/bip-0147.mediawiki): NULLDUMMY softfork as of **v0.13.1** ([PR 8636](https://github.com/bitcoin/bitcoin/pull/8636) and [PR 8937](https://github.com/bitcoin/bitcoin/pull/8937)), *buried* since **v0.19.0** ([PR #16060](https://github.com/bitcoin/bitcoin/pull/16060)).
* [`BIP 152`](https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki): Compact block transfer and related optimizations are used as of **v0.13.0** ([PR 8068](https://github.com/bitcoin/bitcoin/pull/8068)).
- [`BIP 158`](https://github.com/bitcoin/bips/blob/master/bip-0158.mediawiki): Compact Block Filters for Light Clients can be indexed as of **v0.19.0** ([PR #14121](https://github.com/bitcoin/bitcoin/pull/14121)).
-* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The NODE_NETWORK_LIMITED service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of **v0.17.0** ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
+* [`BIP 159`](https://github.com/bitcoin/bips/blob/master/bip-0159.mediawiki): The `NODE_NETWORK_LIMITED` service bit is signalled as of **v0.16.0** ([PR 11740](https://github.com/bitcoin/bitcoin/pull/11740)), and such nodes are connected to as of **v0.17.0** ([PR 10387](https://github.com/bitcoin/bitcoin/pull/10387)).
* [`BIP 173`](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki): Bech32 addresses for native Segregated Witness outputs are supported as of **v0.16.0** ([PR 11167](https://github.com/bitcoin/bitcoin/pull/11167)). Bech32 addresses are generated by default as of **v0.20.0** ([PR 16884](https://github.com/bitcoin/bitcoin/pull/16884)).
* [`BIP 174`](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki): RPCs to operate on Partially Signed Bitcoin Transactions (PSBT) are present as of **v0.17.0** ([PR 13557](https://github.com/bitcoin/bitcoin/pull/13557)).
* [`BIP 176`](https://github.com/bitcoin/bips/blob/master/bip-0176.mediawiki): Bits Denomination [QT only] is supported as of **v0.16.0** ([PR 12035](https://github.com/bitcoin/bitcoin/pull/12035)).
diff --git a/doc/developer-notes.md b/doc/developer-notes.md
index f4a5e2d330..9cf4b4b075 100644
--- a/doc/developer-notes.md
+++ b/doc/developer-notes.md
@@ -87,7 +87,6 @@ code.
- `++i` is preferred over `i++`.
- `nullptr` is preferred over `NULL` or `(void*)0`.
- `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
- - `enum class` is preferred over `enum` where possible. Scoped enumerations avoid two potential pitfalls/problems with traditional C++ enumerations: implicit conversions to int, and name clashes due to enumerators being exported to the surrounding scope.
Block style example:
```c++
@@ -563,6 +562,34 @@ class A
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
that are not language lawyers.
+- Prefer `enum class` (scoped enumerations) over `enum` (traditional enumerations) where possible.
+
+ - *Rationale*: Scoped enumerations avoid two potential pitfalls/problems with traditional C++ enumerations: implicit conversions to `int`, and name clashes due to enumerators being exported to the surrounding scope.
+
+- `switch` statement on an enumeration example:
+
+```cpp
+enum class Tabs {
+ INFO,
+ CONSOLE,
+ GRAPH,
+ PEERS
+};
+
+int GetInt(Tabs tab)
+{
+ switch (tab) {
+ case Tabs::INFO: return 0;
+ case Tabs::CONSOLE: return 1;
+ case Tabs::GRAPH: return 2;
+ case Tabs::PEERS: return 3;
+ } // no default case, so the compiler can warn about missing cases
+ assert(false);
+}
+```
+
+*Rationale*: The comment documents skipping `default:` label, and it complies with `clang-format` rules. The assertion prevents firing of `-Wreturn-type` warning on some compilers.
+
Strings and formatting
------------------------
diff --git a/src/.clang-format b/src/.clang-format
index 38e19edf2c..aae039dd77 100644
--- a/src/.clang-format
+++ b/src/.clang-format
@@ -5,6 +5,7 @@ AlignEscapedNewlinesLeft: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index b8957e52bd..7292ca0784 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -23,6 +23,7 @@ FUZZ_TARGETS = \
test/fuzz/netaddr_deserialize \
test/fuzz/script_flags \
test/fuzz/service_deserialize \
+ test/fuzz/spanparsing \
test/fuzz/transaction \
test/fuzz/txoutcompressor_deserialize \
test/fuzz/txundo_deserialize
@@ -270,6 +271,12 @@ test_fuzz_service_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_service_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
test_fuzz_service_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
+test_fuzz_spanparsing_SOURCES = $(FUZZ_SUITE) test/fuzz/spanparsing.cpp
+test_fuzz_spanparsing_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+test_fuzz_spanparsing_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+test_fuzz_spanparsing_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+test_fuzz_spanparsing_LDADD = $(FUZZ_SUITE_LD_COMMON)
+
test_fuzz_messageheader_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
test_fuzz_messageheader_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DMESSAGEHEADER_DESERIALIZE=1
test_fuzz_messageheader_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp
index be145a0e63..1111f27771 100644
--- a/src/arith_uint256.cpp
+++ b/src/arith_uint256.cpp
@@ -8,8 +8,6 @@
#include <uint256.h>
#include <crypto/common.h>
-#include <stdio.h>
-#include <string.h>
template <unsigned int BITS>
base_uint<BITS>::base_uint(const std::string& str)
diff --git a/src/arith_uint256.h b/src/arith_uint256.h
index bd0360087d..171135b01f 100644
--- a/src/arith_uint256.h
+++ b/src/arith_uint256.h
@@ -6,13 +6,11 @@
#ifndef BITCOIN_ARITH_UINT256_H
#define BITCOIN_ARITH_UINT256_H
-#include <assert.h>
#include <cstring>
#include <limits>
#include <stdexcept>
#include <stdint.h>
#include <string>
-#include <vector>
class uint256;
diff --git a/src/bench/base58.cpp b/src/bench/base58.cpp
index 0f4b52cf79..40a7b5e320 100644
--- a/src/bench/base58.cpp
+++ b/src/bench/base58.cpp
@@ -8,7 +8,6 @@
#include <array>
#include <vector>
-#include <string>
static void Base58Encode(benchmark::State& state)
diff --git a/src/bench/bench.h b/src/bench/bench.h
index 35eeab3393..3a8c487b9a 100644
--- a/src/bench/bench.h
+++ b/src/bench/bench.h
@@ -6,7 +6,6 @@
#define BITCOIN_BENCH_BENCH_H
#include <functional>
-#include <limits>
#include <map>
#include <string>
#include <vector>
diff --git a/src/bench/block_assemble.cpp b/src/bench/block_assemble.cpp
index fb33c09ab2..157f936a95 100644
--- a/src/bench/block_assemble.cpp
+++ b/src/bench/block_assemble.cpp
@@ -10,7 +10,6 @@
#include <validation.h>
-#include <list>
#include <vector>
static void AssembleBlock(benchmark::State& state)
diff --git a/src/bench/chacha20.cpp b/src/bench/chacha20.cpp
index 030067aca5..f1b0a9a989 100644
--- a/src/bench/chacha20.cpp
+++ b/src/bench/chacha20.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <iostream>
#include <bench/bench.h>
#include <crypto/chacha20.h>
diff --git a/src/bench/chacha_poly_aead.cpp b/src/bench/chacha_poly_aead.cpp
index f5f7297490..a02a5315a4 100644
--- a/src/bench/chacha_poly_aead.cpp
+++ b/src/bench/chacha_poly_aead.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <iostream>
#include <bench/bench.h>
#include <crypto/chacha_poly_aead.h>
diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp
index fb2bab9dee..674753c191 100644
--- a/src/bench/crypto_hash.cpp
+++ b/src/bench/crypto_hash.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <iostream>
#include <bench/bench.h>
#include <hash.h>
diff --git a/src/bench/duplicate_inputs.cpp b/src/bench/duplicate_inputs.cpp
index 2440341287..6cfa3750d6 100644
--- a/src/bench/duplicate_inputs.cpp
+++ b/src/bench/duplicate_inputs.cpp
@@ -4,15 +4,12 @@
#include <bench/bench.h>
#include <chainparams.h>
-#include <coins.h>
#include <consensus/merkle.h>
#include <consensus/validation.h>
#include <pow.h>
#include <txmempool.h>
#include <validation.h>
-#include <list>
-#include <vector>
static void DuplicateInputs(benchmark::State& state)
diff --git a/src/bench/lockedpool.cpp b/src/bench/lockedpool.cpp
index 0712eab4bc..0d9b123400 100644
--- a/src/bench/lockedpool.cpp
+++ b/src/bench/lockedpool.cpp
@@ -6,7 +6,6 @@
#include <support/lockedpool.h>
-#include <iostream>
#include <vector>
#define ASIZE 2048
diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp
index ac8a182358..a2a21c673b 100644
--- a/src/bench/mempool_eviction.cpp
+++ b/src/bench/mempool_eviction.cpp
@@ -6,8 +6,6 @@
#include <policy/policy.h>
#include <txmempool.h>
-#include <list>
-#include <vector>
static void AddTx(const CTransactionRef& tx, const CAmount& nFee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
{
diff --git a/src/bench/poly1305.cpp b/src/bench/poly1305.cpp
index 16342d0fbe..02e5fecc0d 100644
--- a/src/bench/poly1305.cpp
+++ b/src/bench/poly1305.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <iostream>
#include <bench/bench.h>
#include <crypto/poly1305.h>
diff --git a/src/bench/rollingbloom.cpp b/src/bench/rollingbloom.cpp
index 4016530dac..cffdb388f8 100644
--- a/src/bench/rollingbloom.cpp
+++ b/src/bench/rollingbloom.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <iostream>
#include <bench/bench.h>
#include <bloom.h>
diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp
index 29e448fc43..2fc6f116a4 100644
--- a/src/bench/rpc_blockchain.cpp
+++ b/src/bench/rpc_blockchain.cpp
@@ -7,7 +7,6 @@
#include <validation.h>
#include <streams.h>
-#include <consensus/validation.h>
#include <rpc/blockchain.h>
#include <univalue.h>
diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp
index b35a744055..bf63cccf09 100644
--- a/src/bench/rpc_mempool.cpp
+++ b/src/bench/rpc_mempool.cpp
@@ -8,8 +8,6 @@
#include <univalue.h>
-#include <list>
-#include <vector>
static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pool.cs)
{
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 73773c4ec5..93b7a7152c 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -9,7 +9,6 @@
#include <chainparamsbase.h>
#include <clientversion.h>
-#include <fs.h>
#include <rpc/client.h>
#include <rpc/protocol.h>
#include <rpc/request.h>
@@ -316,7 +315,20 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co
// Synchronously look up hostname
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
- evhttp_connection_set_timeout(evcon.get(), gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
+
+ // Set connection timeout
+ {
+ const int timeout = gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT);
+ if (timeout > 0) {
+ evhttp_connection_set_timeout(evcon.get(), timeout);
+ } else {
+ // Indefinite request timeouts are not possible in libevent-http, so we
+ // set the timeout to a very long time period instead.
+
+ constexpr int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
+ evhttp_connection_set_timeout(evcon.get(), 5 * YEAR_IN_SECONDS);
+ }
+ }
HTTPReply response;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index 88219f0d0f..cabea610f3 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -11,7 +11,6 @@
#include <consensus/consensus.h>
#include <core_io.h>
#include <key_io.h>
-#include <policy/policy.h>
#include <policy/rbf.h>
#include <primitives/transaction.h>
#include <script/script.h>
diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp
index eb7f0098ec..eda4f8ce78 100644
--- a/src/bitcoin-wallet.cpp
+++ b/src/bitcoin-wallet.cpp
@@ -9,13 +9,11 @@
#include <chainparams.h>
#include <chainparamsbase.h>
#include <logging.h>
-#include <util/strencodings.h>
#include <util/system.h>
#include <util/translation.h>
#include <wallet/wallettool.h>
#include <functional>
-#include <stdio.h>
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index 17989a4214..ddd6f8839c 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -10,7 +10,6 @@
#include <chainparams.h>
#include <clientversion.h>
#include <compat.h>
-#include <fs.h>
#include <init.h>
#include <interfaces/chain.h>
#include <noui.h>
diff --git a/src/blockencodings.h b/src/blockencodings.h
index 0c2b83ebcf..18a6e35f31 100644
--- a/src/blockencodings.h
+++ b/src/blockencodings.h
@@ -7,7 +7,6 @@
#include <primitives/block.h>
-#include <memory>
class CTxMemPool;
diff --git a/src/compressor.cpp b/src/compressor.cpp
index a2d9af8805..a7f45b5c1e 100644
--- a/src/compressor.cpp
+++ b/src/compressor.cpp
@@ -5,7 +5,6 @@
#include <compressor.h>
-#include <hash.h>
#include <pubkey.h>
#include <script/standard.h>
diff --git a/src/consensus/merkle.h b/src/consensus/merkle.h
index 7675877de5..f28f76bd34 100644
--- a/src/consensus/merkle.h
+++ b/src/consensus/merkle.h
@@ -5,10 +5,8 @@
#ifndef BITCOIN_CONSENSUS_MERKLE_H
#define BITCOIN_CONSENSUS_MERKLE_H
-#include <stdint.h>
#include <vector>
-#include <primitives/transaction.h>
#include <primitives/block.h>
#include <uint256.h>
diff --git a/src/consensus/params.h b/src/consensus/params.h
index 2f8c490dc4..e191fd6d26 100644
--- a/src/consensus/params.h
+++ b/src/consensus/params.h
@@ -8,8 +8,6 @@
#include <uint256.h>
#include <limits>
-#include <map>
-#include <string>
namespace Consensus {
diff --git a/src/crypto/aes.cpp b/src/crypto/aes.cpp
index b3fb927760..6ed9088434 100644
--- a/src/crypto/aes.cpp
+++ b/src/crypto/aes.cpp
@@ -4,7 +4,6 @@
#include <crypto/aes.h>
-#include <assert.h>
#include <string.h>
extern "C" {
diff --git a/src/crypto/chacha_poly_aead.cpp b/src/crypto/chacha_poly_aead.cpp
index 6a3d43deb1..0582a60c4f 100644
--- a/src/crypto/chacha_poly_aead.cpp
+++ b/src/crypto/chacha_poly_aead.cpp
@@ -4,7 +4,6 @@
#include <crypto/chacha_poly_aead.h>
-#include <crypto/common.h>
#include <crypto/poly1305.h>
#include <support/cleanse.h>
diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp
index cab37e0322..3257ee7f97 100644
--- a/src/crypto/sha256.cpp
+++ b/src/crypto/sha256.cpp
@@ -7,7 +7,6 @@
#include <assert.h>
#include <string.h>
-#include <atomic>
#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)
#if defined(USE_ASM)
diff --git a/src/crypto/sha256_shani.cpp b/src/crypto/sha256_shani.cpp
index e561da42c5..7ea0c34796 100644
--- a/src/crypto/sha256_shani.cpp
+++ b/src/crypto/sha256_shani.cpp
@@ -11,7 +11,6 @@
#include <stdint.h>
#include <immintrin.h>
-#include <crypto/common.h>
namespace {
diff --git a/src/dbwrapper.h b/src/dbwrapper.h
index 416f5e8399..061c9b6bca 100644
--- a/src/dbwrapper.h
+++ b/src/dbwrapper.h
@@ -11,7 +11,6 @@
#include <streams.h>
#include <util/system.h>
#include <util/strencodings.h>
-#include <version.h>
#include <leveldb/db.h>
#include <leveldb/write_batch.h>
diff --git a/src/dummywallet.cpp b/src/dummywallet.cpp
index 126e3479f3..e5e563f3e9 100644
--- a/src/dummywallet.cpp
+++ b/src/dummywallet.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <stdio.h>
#include <util/system.h>
#include <walletinitinterface.h>
#include <support/allocators/secure.h>
diff --git a/src/httprpc.cpp b/src/httprpc.cpp
index 306d718574..2c2f67b169 100644
--- a/src/httprpc.cpp
+++ b/src/httprpc.cpp
@@ -7,10 +7,8 @@
#include <chainparams.h>
#include <crypto/hmac_sha256.h>
#include <httpserver.h>
-#include <key_io.h>
#include <rpc/protocol.h>
#include <rpc/server.h>
-#include <sync.h>
#include <ui_interface.h>
#include <util/strencodings.h>
#include <util/system.h>
diff --git a/src/httprpc.h b/src/httprpc.h
index 2230a8ca4e..91c2ec0c9d 100644
--- a/src/httprpc.h
+++ b/src/httprpc.h
@@ -5,8 +5,6 @@
#ifndef BITCOIN_HTTPRPC_H
#define BITCOIN_HTTPRPC_H
-#include <string>
-#include <map>
/** Start HTTP RPC subsystem.
* Precondition; HTTP and RPC has been started.
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index d17667223b..8113777187 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -22,7 +22,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <signal.h>
#include <event2/thread.h>
#include <event2/buffer.h>
diff --git a/src/httpserver.h b/src/httpserver.h
index 7943f0094b..bc72fc8512 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -6,7 +6,6 @@
#define BITCOIN_HTTPSERVER_H
#include <string>
-#include <stdint.h>
#include <functional>
static const int DEFAULT_HTTP_THREADS=4;
diff --git a/src/index/base.h b/src/index/base.h
index 31acbed0c1..f95eeb8197 100644
--- a/src/index/base.h
+++ b/src/index/base.h
@@ -9,7 +9,6 @@
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <threadinterrupt.h>
-#include <uint256.h>
#include <validationinterface.h>
class CBlockIndex;
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
index b8b9ecded9..b2c20573fb 100644
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -18,12 +18,10 @@
#include <policy/settings.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
-#include <protocol.h>
#include <rpc/protocol.h>
#include <rpc/server.h>
#include <shutdown.h>
#include <sync.h>
-#include <threadsafety.h>
#include <timedata.h>
#include <txmempool.h>
#include <ui_interface.h>
@@ -298,6 +296,11 @@ public:
{
::mempool.GetTransactionAncestry(txid, ancestors, descendants);
}
+ void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) override
+ {
+ limit_ancestor_count = gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
+ limit_descendant_count = gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT);
+ }
bool checkChainLimits(const CTransactionRef& tx) override
{
LockPoints lp;
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index da670a3370..73a78e21fb 100644
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -163,6 +163,11 @@ public:
//! Calculate mempool ancestor and descendant counts for the given transaction.
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants) = 0;
+ //! Get the node's package limits.
+ //! Currently only returns the ancestor and descendant count limits, but could be enhanced to
+ //! return more policy settings.
+ virtual void getPackageLimits(unsigned int& limit_ancestor_count, unsigned int& limit_descendant_count) = 0;
+
//! Check if transaction will pass the mempool's chain limits.
virtual bool checkChainLimits(const CTransactionRef& tx) = 0;
diff --git a/src/interfaces/node.cpp b/src/interfaces/node.cpp
index 3d89e17163..0b7a1534ab 100644
--- a/src/interfaces/node.cpp
+++ b/src/interfaces/node.cpp
@@ -5,7 +5,6 @@
#include <interfaces/node.h>
#include <addrdb.h>
-#include <amount.h>
#include <banman.h>
#include <chain.h>
#include <chainparams.h>
@@ -19,7 +18,6 @@
#include <netbase.h>
#include <policy/feerate.h>
#include <policy/fees.h>
-#include <policy/policy.h>
#include <policy/settings.h>
#include <primitives/block.h>
#include <rpc/server.h>
@@ -36,7 +34,6 @@
#include <config/bitcoin-config.h>
#endif
-#include <atomic>
#include <univalue.h>
class CWallet;
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index 0c8d92eba5..2353fe0934 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -8,7 +8,6 @@
#include <consensus/validation.h>
#include <interfaces/chain.h>
#include <interfaces/handler.h>
-#include <policy/feerate.h>
#include <policy/fees.h>
#include <primitives/transaction.h>
#include <script/standard.h>
@@ -23,7 +22,6 @@
#include <wallet/rpcwallet.h>
#include <wallet/load.h>
#include <wallet/wallet.h>
-#include <wallet/walletutil.h>
#include <memory>
#include <string>
@@ -241,7 +239,7 @@ public:
}
bool transactionCanBeBumped(const uint256& txid) override
{
- return feebumper::TransactionCanBeBumped(m_wallet.get(), txid);
+ return feebumper::TransactionCanBeBumped(*m_wallet.get(), txid);
}
bool createBumpTransaction(const uint256& txid,
const CCoinControl& coin_control,
@@ -255,17 +253,17 @@ public:
return feebumper::CreateTotalBumpTransaction(m_wallet.get(), txid, coin_control, total_fee, errors, old_fee, new_fee, mtx) ==
feebumper::Result::OK;
} else {
- return feebumper::CreateRateBumpTransaction(m_wallet.get(), txid, coin_control, errors, old_fee, new_fee, mtx) ==
+ return feebumper::CreateRateBumpTransaction(*m_wallet.get(), txid, coin_control, errors, old_fee, new_fee, mtx) ==
feebumper::Result::OK;
}
}
- bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(m_wallet.get(), mtx); }
+ bool signBumpTransaction(CMutableTransaction& mtx) override { return feebumper::SignTransaction(*m_wallet.get(), mtx); }
bool commitBumpTransaction(const uint256& txid,
CMutableTransaction&& mtx,
std::vector<std::string>& errors,
uint256& bumped_txid) override
{
- return feebumper::CommitTransaction(m_wallet.get(), txid, std::move(mtx), errors, bumped_txid) ==
+ return feebumper::CommitTransaction(*m_wallet.get(), txid, std::move(mtx), errors, bumped_txid) ==
feebumper::Result::OK;
}
CTransactionRef getTx(const uint256& txid) override
diff --git a/src/key_io.cpp b/src/key_io.cpp
index cd41a93549..363055d6b3 100644
--- a/src/key_io.cpp
+++ b/src/key_io.cpp
@@ -6,7 +6,6 @@
#include <base58.h>
#include <bech32.h>
-#include <script/script.h>
#include <util/strencodings.h>
#include <boost/variant/apply_visitor.hpp>
diff --git a/src/logging.cpp b/src/logging.cpp
index dc2d130a2a..60ab486198 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -224,10 +224,32 @@ std::string BCLog::Logger::LogTimestampStr(const std::string& str)
return strStamped;
}
+namespace BCLog {
+ /** Belts and suspenders: make sure outgoing log messages don't contain
+ * potentially suspicious characters, such as terminal control codes.
+ *
+ * This escapes control characters except newline ('\n') in C syntax.
+ * It escapes instead of removes them to still allow for troubleshooting
+ * issues where they accidentally end up in strings.
+ */
+ std::string LogEscapeMessage(const std::string& str) {
+ std::string ret;
+ for (char ch_in : str) {
+ uint8_t ch = (uint8_t)ch_in;
+ if ((ch >= 32 || ch == '\n') && ch != '\x7f') {
+ ret += ch_in;
+ } else {
+ ret += strprintf("\\x%02x", ch);
+ }
+ }
+ return ret;
+ }
+}
+
void BCLog::Logger::LogPrintStr(const std::string& str)
{
std::lock_guard<std::mutex> scoped_lock(m_cs);
- std::string str_prefixed = str;
+ std::string str_prefixed = LogEscapeMessage(str);
if (m_log_threadnames && m_started_new_line) {
str_prefixed.insert(0, "[" + util::ThreadGetInternalName() + "] ");
diff --git a/src/miner.cpp b/src/miner.cpp
index 015645c9c6..4f51be8a08 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -17,14 +17,12 @@
#include <policy/policy.h>
#include <pow.h>
#include <primitives/transaction.h>
-#include <script/standard.h>
#include <timedata.h>
#include <util/moneystr.h>
#include <util/system.h>
#include <util/validation.h>
#include <algorithm>
-#include <queue>
#include <utility>
int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
diff --git a/src/net.cpp b/src/net.cpp
index 63b7833822..c1c70facf4 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -13,11 +13,9 @@
#include <chainparams.h>
#include <clientversion.h>
#include <consensus/consensus.h>
-#include <crypto/common.h>
#include <crypto/sha256.h>
#include <netbase.h>
#include <net_permissions.h>
-#include <primitives/transaction.h>
#include <scheduler.h>
#include <ui_interface.h>
#include <util/strencodings.h>
@@ -35,7 +33,6 @@
#ifdef USE_UPNP
#include <miniupnpc/miniupnpc.h>
-#include <miniupnpc/miniwget.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>
// The minimum supported miniUPnPc API version is set to 10. This keeps compatibility
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index b6839dcf21..43de12649e 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -7,7 +7,6 @@
#include <addrman.h>
#include <banman.h>
-#include <arith_uint256.h>
#include <blockencodings.h>
#include <chainparams.h>
#include <consensus/validation.h>
diff --git a/src/netaddress.h b/src/netaddress.h
index 673eaf8d7b..fbb1553338 100644
--- a/src/netaddress.h
+++ b/src/netaddress.h
@@ -11,7 +11,6 @@
#include <compat.h>
#include <serialize.h>
-#include <span.h>
#include <stdint.h>
#include <string>
diff --git a/src/node/coinstats.cpp b/src/node/coinstats.cpp
index e1891b9898..57fa158ad2 100644
--- a/src/node/coinstats.cpp
+++ b/src/node/coinstats.cpp
@@ -5,9 +5,7 @@
#include <node/coinstats.h>
-#include <amount.h>
#include <coins.h>
-#include <chain.h>
#include <hash.h>
#include <serialize.h>
#include <validation.h>
diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp
index 7e8291ddc8..7783671a6c 100644
--- a/src/node/transaction.cpp
+++ b/src/node/transaction.cpp
@@ -6,7 +6,6 @@
#include <consensus/validation.h>
#include <net.h>
#include <net_processing.h>
-#include <txmempool.h>
#include <util/validation.h>
#include <validation.h>
#include <validationinterface.h>
diff --git a/src/node/transaction.h b/src/node/transaction.h
index cf64fc28d9..a3e56544a7 100644
--- a/src/node/transaction.h
+++ b/src/node/transaction.h
@@ -7,7 +7,6 @@
#include <attributes.h>
#include <primitives/transaction.h>
-#include <uint256.h>
#include <util/error.h>
/**
diff --git a/src/noui.cpp b/src/noui.cpp
index c07939cc79..14d6183d24 100644
--- a/src/noui.cpp
+++ b/src/noui.cpp
@@ -8,8 +8,6 @@
#include <ui_interface.h>
#include <util/system.h>
-#include <cstdio>
-#include <stdint.h>
#include <string>
#include <boost/signals2/connection.hpp>
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
index 5d538606c2..8154bf105e 100644
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -6,7 +6,6 @@
#include <policy/fees.h>
#include <clientversion.h>
-#include <primitives/transaction.h>
#include <streams.h>
#include <txmempool.h>
#include <util/system.h>
diff --git a/src/prevector.h b/src/prevector.h
index 9d576321b6..d307495fbe 100644
--- a/src/prevector.h
+++ b/src/prevector.h
@@ -12,7 +12,6 @@
#include <algorithm>
#include <cstddef>
-#include <iterator>
#include <type_traits>
#pragma pack(push, 1)
diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp
index 60c7c2d160..0c84ed6da2 100644
--- a/src/primitives/block.cpp
+++ b/src/primitives/block.cpp
@@ -7,7 +7,6 @@
#include <hash.h>
#include <tinyformat.h>
-#include <crypto/common.h>
uint256 CBlockHeader::GetHash() const
{
diff --git a/src/protocol.h b/src/protocol.h
index e6b25ffa25..3032310fa1 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -15,7 +15,6 @@
#include <uint256.h>
#include <version.h>
-#include <atomic>
#include <stdint.h>
#include <string>
diff --git a/src/psbt.cpp b/src/psbt.cpp
index fe74002e82..c306079b1e 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -5,7 +5,6 @@
#include <psbt.h>
#include <util/strencodings.h>
-#include <numeric>
PartiallySignedTransaction::PartiallySignedTransaction(const CMutableTransaction& tx) : tx(tx)
{
diff --git a/src/qt/bantablemodel.cpp b/src/qt/bantablemodel.cpp
index efc726e09e..ae11b80347 100644
--- a/src/qt/bantablemodel.cpp
+++ b/src/qt/bantablemodel.cpp
@@ -7,8 +7,6 @@
#include <qt/clientmodel.h>
#include <interfaces/node.h>
-#include <sync.h>
-#include <util/time.h>
#include <algorithm>
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index 86f4dc91a1..f548dc9fe3 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -10,7 +10,6 @@
#include <qt/bitcoingui.h>
#include <chainparams.h>
-#include <fs.h>
#include <qt/clientmodel.h>
#include <qt/guiconstants.h>
#include <qt/guiutil.h>
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 2878a8eb14..2cfcf346fa 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -796,7 +796,7 @@ void BitcoinGUI::showDebugWindow()
void BitcoinGUI::showDebugWindowActivateConsole()
{
- rpcConsole->setTabFocus(RPCConsole::TAB_CONSOLE);
+ rpcConsole->setTabFocus(RPCConsole::TabTypes::CONSOLE);
showDebugWindow();
}
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index 03d18d2845..f928f1ca2a 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -19,7 +19,6 @@
#include <wallet/coincontrol.h>
#include <interfaces/node.h>
#include <key_io.h>
-#include <policy/fees.h>
#include <policy/policy.h>
#include <wallet/wallet.h>
diff --git a/src/qt/forms/signverifymessagedialog.ui b/src/qt/forms/signverifymessagedialog.ui
index c9ddd757c1..8a7bdfdbc6 100644
--- a/src/qt/forms/signverifymessagedialog.ui
+++ b/src/qt/forms/signverifymessagedialog.ui
@@ -285,10 +285,24 @@
</layout>
</item>
<item>
- <widget class="QPlainTextEdit" name="messageIn_VM"/>
+ <widget class="QPlainTextEdit" name="messageIn_VM">
+ <property name="toolTip">
+ <string>The signed message to verify</string>
+ </property>
+ <property name="placeholderText">
+ <string>The signed message to verify</string>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QValidatedLineEdit" name="signatureIn_VM"/>
+ <widget class="QValidatedLineEdit" name="signatureIn_VM">
+ <property name="toolTip">
+ <string>The signature given when the message was signed</string>
+ </property>
+ <property name="placeholderText">
+ <string>The signature given when the message was signed</string>
+ </property>
+ </widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2_VM">
diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp
index 99a9a12fe2..af2a1bb0e5 100644
--- a/src/qt/peertablemodel.cpp
+++ b/src/qt/peertablemodel.cpp
@@ -9,7 +9,6 @@
#include <qt/guiutil.h>
#include <interfaces/node.h>
-#include <sync.h>
#include <algorithm>
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 4f6629bfe1..3dd64c5273 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -1268,22 +1268,24 @@ void RPCConsole::showOrHideBanTableIfRequired()
void RPCConsole::setTabFocus(enum TabTypes tabType)
{
- ui->tabWidget->setCurrentIndex(tabType);
+ ui->tabWidget->setCurrentIndex(int(tabType));
}
QString RPCConsole::tabTitle(TabTypes tab_type) const
{
- return ui->tabWidget->tabText(tab_type);
+ return ui->tabWidget->tabText(int(tab_type));
}
QKeySequence RPCConsole::tabShortcut(TabTypes tab_type) const
{
switch (tab_type) {
- case TAB_INFO: return QKeySequence(Qt::CTRL + Qt::Key_I);
- case TAB_CONSOLE: return QKeySequence(Qt::CTRL + Qt::Key_T);
- case TAB_GRAPH: return QKeySequence(Qt::CTRL + Qt::Key_N);
- case TAB_PEERS: return QKeySequence(Qt::CTRL + Qt::Key_P);
- }
+ case TabTypes::INFO: return QKeySequence(Qt::CTRL + Qt::Key_I);
+ case TabTypes::CONSOLE: return QKeySequence(Qt::CTRL + Qt::Key_T);
+ case TabTypes::GRAPH: return QKeySequence(Qt::CTRL + Qt::Key_N);
+ case TabTypes::PEERS: return QKeySequence(Qt::CTRL + Qt::Key_P);
+ } // no default case, so the compiler can warn about missing cases
+
+ assert(false);
}
void RPCConsole::updateAlerts(const QString& warnings)
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 6b0f07baf1..f586d04022 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -58,14 +58,14 @@ public:
CMD_ERROR
};
- enum TabTypes {
- TAB_INFO = 0,
- TAB_CONSOLE = 1,
- TAB_GRAPH = 2,
- TAB_PEERS = 3
+ enum class TabTypes {
+ INFO,
+ CONSOLE,
+ GRAPH,
+ PEERS
};
- std::vector<TabTypes> tabs() const { return {TAB_INFO, TAB_CONSOLE, TAB_GRAPH, TAB_PEERS}; }
+ std::vector<TabTypes> tabs() const { return {TabTypes::INFO, TabTypes::CONSOLE, TabTypes::GRAPH, TabTypes::PEERS}; }
QString tabTitle(TabTypes tab_type) const;
QKeySequence tabShortcut(TabTypes tab_type) const;
diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp
index 71f5f2ae75..1d0e1323bc 100644
--- a/src/qt/signverifymessagedialog.cpp
+++ b/src/qt/signverifymessagedialog.cpp
@@ -14,7 +14,6 @@
#include <util/validation.h> // For strMessageMagic
#include <wallet/wallet.h>
-#include <string>
#include <vector>
#include <QClipboard>
diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp
index 0e5abb89f3..26c9fe7ad4 100644
--- a/src/qt/splashscreen.cpp
+++ b/src/qt/splashscreen.cpp
@@ -17,7 +17,6 @@
#include <ui_interface.h>
#include <util/system.h>
#include <util/translation.h>
-#include <version.h>
#include <QApplication>
#include <QCloseEvent>
diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp
index eca468a6ab..ef0808054d 100644
--- a/src/qt/test/paymentservertests.cpp
+++ b/src/qt/test/paymentservertests.cpp
@@ -8,7 +8,6 @@
#include <qt/test/paymentrequestdata.h>
#include <amount.h>
-#include <chainparams.h>
#include <interfaces/node.h>
#include <random.h>
#include <script/script.h>
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 648fdb7673..44ce5265cd 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -18,7 +18,6 @@
#include <key_io.h>
#include <validation.h>
#include <script/script.h>
-#include <timedata.h>
#include <util/system.h>
#include <policy/policy.h>
#include <wallet/ismine.h>
diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp
index 94413547d4..d7f0617315 100644
--- a/src/qt/walletframe.cpp
+++ b/src/qt/walletframe.cpp
@@ -9,7 +9,6 @@
#include <qt/walletview.h>
#include <cassert>
-#include <cstdio>
#include <QHBoxLayout>
#include <QLabel>
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index 54428aec08..f16fe81bd9 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -22,7 +22,6 @@
#include <interfaces/wallet.h>
#include <support/allocators/secure.h>
-#include <map>
#include <vector>
#include <QObject>
diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h
index a41d8f2457..242ba13897 100644
--- a/src/qt/walletmodeltransaction.h
+++ b/src/qt/walletmodeltransaction.h
@@ -7,7 +7,6 @@
#include <qt/walletmodel.h>
-#include <memory>
#include <amount.h>
#include <QObject>
diff --git a/src/random.cpp b/src/random.cpp
index 675b177af3..0f13228383 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -16,7 +16,6 @@
#include <util/time.h> // for GetTime()
#include <stdlib.h>
-#include <chrono>
#include <thread>
#include <support/allocators/secure.h>
@@ -41,7 +40,6 @@
#include <sys/sysctl.h>
#endif
-#include <mutex>
#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)
#include <cpuid.h>
@@ -113,7 +111,7 @@ static void InitHardwareRand()
static void ReportHardwareRand()
{
- // This must be done in a separate function, as HWRandInit() may be indirectly called
+ // This must be done in a separate function, as InitHardwareRand() may be indirectly called
// from global constructors, before logging is initialized.
if (g_rdseed_supported) {
LogPrintf("Using RdSeed as additional entropy source\n");
diff --git a/src/rest.cpp b/src/rest.cpp
index 2c4d475542..228c122de3 100644
--- a/src/rest.cpp
+++ b/src/rest.cpp
@@ -3,7 +3,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <attributes.h>
#include <chain.h>
#include <chainparams.h>
#include <core_io.h>
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 3463145f75..4bbd4aaf64 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -32,7 +32,6 @@
#include <util/validation.h>
#include <validation.h>
#include <validationinterface.h>
-#include <versionbitsinfo.h>
#include <warnings.h>
#include <assert.h>
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp
index c2714f9c83..32e18312e1 100644
--- a/src/rpc/client.cpp
+++ b/src/rpc/client.cpp
@@ -4,7 +4,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <rpc/client.h>
-#include <rpc/protocol.h>
#include <util/system.h>
#include <set>
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index 1516007201..d289274a37 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -3,7 +3,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <crypto/ripemd160.h>
#include <key_io.h>
#include <httpserver.h>
#include <outputtype.h>
diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp
index 7c4b3d0cc6..7b1507e4dc 100644
--- a/src/rpc/net.cpp
+++ b/src/rpc/net.cpp
@@ -11,7 +11,6 @@
#include <net_processing.h>
#include <net_permissions.h>
#include <netbase.h>
-#include <policy/policy.h>
#include <policy/settings.h>
#include <rpc/protocol.h>
#include <rpc/util.h>
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
index f94856a28e..a16e5cb61a 100644
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -5,7 +5,6 @@
#include <chain.h>
#include <coins.h>
-#include <compat/byteswap.h>
#include <consensus/validation.h>
#include <core_io.h>
#include <index/txindex.h>
@@ -23,7 +22,6 @@
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/script.h>
-#include <script/script_error.h>
#include <script/sign.h>
#include <script/signingprovider.h>
#include <script/standard.h>
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 3e5bb85c1c..91d3e1fca4 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -5,8 +5,6 @@
#include <rpc/server.h>
-#include <fs.h>
-#include <key_io.h>
#include <rpc/util.h>
#include <shutdown.h>
#include <sync.h>
diff --git a/src/rpc/server.h b/src/rpc/server.h
index b060db5bf9..be9c03bf6b 100644
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -8,9 +8,7 @@
#include <amount.h>
#include <rpc/request.h>
-#include <uint256.h>
-#include <list>
#include <map>
#include <stdint.h>
#include <string>
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index 276ff9a58a..d63d8b85b7 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -11,7 +11,6 @@
#include <vector>
#include <stdint.h>
-#include <string>
class CPubKey;
class CScript;
diff --git a/src/script/keyorigin.h b/src/script/keyorigin.h
index 610f233500..467605ce46 100644
--- a/src/script/keyorigin.h
+++ b/src/script/keyorigin.h
@@ -6,7 +6,6 @@
#define BITCOIN_SCRIPT_KEYORIGIN_H
#include <serialize.h>
-#include <streams.h>
#include <vector>
struct KeyOriginInfo
diff --git a/src/script/sign.h b/src/script/sign.h
index 0e751afd3b..9d0a5b4d70 100644
--- a/src/script/sign.h
+++ b/src/script/sign.h
@@ -6,7 +6,6 @@
#ifndef BITCOIN_SCRIPT_SIGN_H
#define BITCOIN_SCRIPT_SIGN_H
-#include <boost/optional.hpp>
#include <hash.h>
#include <pubkey.h>
#include <script/interpreter.h>
diff --git a/src/script/standard.h b/src/script/standard.h
index e45e2d92cc..6db28dbc2d 100644
--- a/src/script/standard.h
+++ b/src/script/standard.h
@@ -11,7 +11,6 @@
#include <boost/variant.hpp>
-#include <stdint.h>
static const bool DEFAULT_ACCEPT_DATACARRIER = true;
diff --git a/src/serialize.h b/src/serialize.h
index a38d76fc18..ef270dbbe3 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -9,7 +9,6 @@
#include <compat/endian.h>
#include <algorithm>
-#include <assert.h>
#include <ios>
#include <limits>
#include <map>
diff --git a/src/streams.h b/src/streams.h
index 517eefc932..b598dc1aeb 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -13,8 +13,6 @@
#include <assert.h>
#include <ios>
#include <limits>
-#include <map>
-#include <set>
#include <stdint.h>
#include <stdio.h>
#include <string>
diff --git a/src/sync.cpp b/src/sync.cpp
index 20258d8e9a..653800ae4e 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -13,10 +13,8 @@
#include <util/strencodings.h>
#include <util/threadnames.h>
-#include <stdio.h>
#include <map>
-#include <memory>
#include <set>
#ifdef DEBUG_LOCKCONTENTION
diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp
index 662878750e..660df00964 100644
--- a/src/test/bip32_tests.cpp
+++ b/src/test/bip32_tests.cpp
@@ -8,7 +8,6 @@
#include <key.h>
#include <key_io.h>
#include <streams.h>
-#include <util/system.h>
#include <util/strencodings.h>
#include <test/setup_common.h>
diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp
index cf87aa9303..ba293b7836 100644
--- a/src/test/blockfilter_index_tests.cpp
+++ b/src/test/blockfilter_index_tests.cpp
@@ -167,17 +167,23 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, TestChain100Setup)
LOCK(cs_main);
tip = ::ChainActive().Tip();
}
- CScript coinbase_script_pub_key = GetScriptForDestination(PKHash(coinbaseKey.GetPubKey()));
+ CKey coinbase_key_A, coinbase_key_B;
+ coinbase_key_A.MakeNewKey(true);
+ coinbase_key_B.MakeNewKey(true);
+ CScript coinbase_script_pub_key_A = GetScriptForDestination(PKHash(coinbase_key_A.GetPubKey()));
+ CScript coinbase_script_pub_key_B = GetScriptForDestination(PKHash(coinbase_key_B.GetPubKey()));
std::vector<std::shared_ptr<CBlock>> chainA, chainB;
- BOOST_REQUIRE(BuildChain(tip, coinbase_script_pub_key, 10, chainA));
- BOOST_REQUIRE(BuildChain(tip, coinbase_script_pub_key, 10, chainB));
+ BOOST_REQUIRE(BuildChain(tip, coinbase_script_pub_key_A, 10, chainA));
+ BOOST_REQUIRE(BuildChain(tip, coinbase_script_pub_key_B, 10, chainB));
// Check that new blocks on chain A get indexed.
uint256 chainA_last_header = last_header;
for (size_t i = 0; i < 2; i++) {
const auto& block = chainA[i];
BOOST_REQUIRE(ProcessNewBlock(Params(), block, true, nullptr));
-
+ }
+ for (size_t i = 0; i < 2; i++) {
+ const auto& block = chainA[i];
const CBlockIndex* block_index;
{
LOCK(cs_main);
@@ -193,7 +199,9 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, TestChain100Setup)
for (size_t i = 0; i < 3; i++) {
const auto& block = chainB[i];
BOOST_REQUIRE(ProcessNewBlock(Params(), block, true, nullptr));
-
+ }
+ for (size_t i = 0; i < 3; i++) {
+ const auto& block = chainB[i];
const CBlockIndex* block_index;
{
LOCK(cs_main);
@@ -221,7 +229,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, TestChain100Setup)
// Reorg back to chain A.
for (size_t i = 2; i < 4; i++) {
const auto& block = chainA[i];
- BOOST_REQUIRE(ProcessNewBlock(Params(), block, true, nullptr));
+ BOOST_REQUIRE(ProcessNewBlock(Params(), block, true, nullptr));
}
// Check that chain A and B blocks can be retrieved.
diff --git a/src/test/compress_tests.cpp b/src/test/compress_tests.cpp
index 6cef8cd8a8..e8f149470e 100644
--- a/src/test/compress_tests.cpp
+++ b/src/test/compress_tests.cpp
@@ -3,7 +3,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <compressor.h>
-#include <util/system.h>
#include <test/setup_common.h>
#include <stdint.h>
diff --git a/src/test/fs_tests.cpp b/src/test/fs_tests.cpp
index 6d5a6641f0..b504a3cbb1 100644
--- a/src/test/fs_tests.cpp
+++ b/src/test/fs_tests.cpp
@@ -15,7 +15,7 @@ BOOST_AUTO_TEST_CASE(fsbridge_fstream)
fs::path tmpfolder = GetDataDir();
// tmpfile1 should be the same as tmpfile2
fs::path tmpfile1 = tmpfolder / "fs_tests_₿_🏃";
- fs::path tmpfile2 = tmpfolder / L"fs_tests_₿_🏃";
+ fs::path tmpfile2 = tmpfolder / "fs_tests_₿_🏃";
{
fsbridge::ofstream file(tmpfile1);
file << "bitcoin";
diff --git a/src/test/fuzz/spanparsing.cpp b/src/test/fuzz/spanparsing.cpp
new file mode 100644
index 0000000000..8e5e7dad11
--- /dev/null
+++ b/src/test/fuzz/spanparsing.cpp
@@ -0,0 +1,30 @@
+// Copyright (c) 2019 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <util/spanparsing.h>
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+ const size_t query_size = fuzzed_data_provider.ConsumeIntegral<size_t>();
+ const std::string query = fuzzed_data_provider.ConsumeBytesAsString(std::min<size_t>(query_size, 1024 * 1024));
+ const std::string span_str = fuzzed_data_provider.ConsumeRemainingBytesAsString();
+ const Span<const char> const_span = MakeSpan(span_str);
+
+ Span<const char> mut_span = const_span;
+ (void)spanparsing::Const(query, mut_span);
+
+ mut_span = const_span;
+ (void)spanparsing::Func(query, mut_span);
+
+ mut_span = const_span;
+ (void)spanparsing::Expr(mut_span);
+
+ if (!query.empty()) {
+ mut_span = const_span;
+ (void)spanparsing::Split(mut_span, query.front());
+ }
+}
diff --git a/src/test/key_properties.cpp b/src/test/key_properties.cpp
index abcfc4547b..95587130fc 100644
--- a/src/test/key_properties.cpp
+++ b/src/test/key_properties.cpp
@@ -4,7 +4,6 @@
#include <key.h>
#include <uint256.h>
-#include <util/system.h>
#include <test/setup_common.h>
#include <vector>
diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp
index 016a4f471b..5368f82ffe 100644
--- a/src/test/policyestimator_tests.cpp
+++ b/src/test/policyestimator_tests.cpp
@@ -6,7 +6,6 @@
#include <policy/fees.h>
#include <txmempool.h>
#include <uint256.h>
-#include <util/system.h>
#include <util/time.h>
#include <test/setup_common.h>
diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp
index deac349867..6c99021d97 100644
--- a/src/test/pow_tests.cpp
+++ b/src/test/pow_tests.cpp
@@ -5,7 +5,6 @@
#include <chain.h>
#include <chainparams.h>
#include <pow.h>
-#include <util/system.h>
#include <test/setup_common.h>
#include <boost/test/unit_test.hpp>
diff --git a/src/test/skiplist_tests.cpp b/src/test/skiplist_tests.cpp
index 3d39dfdb75..1cba3a1297 100644
--- a/src/test/skiplist_tests.cpp
+++ b/src/test/skiplist_tests.cpp
@@ -3,7 +3,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chain.h>
-#include <util/system.h>
#include <test/setup_common.h>
#include <vector>
diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp
index 638819d564..6075fbfeca 100644
--- a/src/test/streams_tests.cpp
+++ b/src/test/streams_tests.cpp
@@ -2,7 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <random.h>
#include <streams.h>
#include <test/setup_common.h>
diff --git a/src/test/txindex_tests.cpp b/src/test/txindex_tests.cpp
index d794d09d30..0ac4b7ebc9 100644
--- a/src/test/txindex_tests.cpp
+++ b/src/test/txindex_tests.cpp
@@ -6,7 +6,6 @@
#include <index/txindex.h>
#include <script/standard.h>
#include <test/setup_common.h>
-#include <util/system.h>
#include <util/time.h>
#include <boost/test/unit_test.hpp>
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
index 31a66b6fa9..3995a3c732 100644
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -26,6 +26,11 @@
#include <boost/test/unit_test.hpp>
+/* defined in logging.cpp */
+namespace BCLog {
+ std::string LogEscapeMessage(const std::string& str);
+}
+
BOOST_FIXTURE_TEST_SUITE(util_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(util_criticalsection)
@@ -1696,4 +1701,17 @@ BOOST_AUTO_TEST_CASE(test_spanparsing)
BOOST_CHECK_EQUAL(SpanToStr(results[3]), "");
}
+BOOST_AUTO_TEST_CASE(test_LogEscapeMessage)
+{
+ // ASCII and UTF-8 must pass through unaltered.
+ BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("Valid log message貓"), "Valid log message貓");
+ // Newlines must pass through unaltered.
+ BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("Message\n with newlines\n"), "Message\n with newlines\n");
+ // Other control characters are escaped in C syntax.
+ BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage("\x01\x7f Corrupted log message\x0d"), R"(\x01\x7f Corrupted log message\x0d)");
+ // Embedded NULL characters are escaped too.
+ const std::string NUL("O\x00O", 3);
+ BOOST_CHECK_EQUAL(BCLog::LogEscapeMessage(NUL), R"(O\x00O)");
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/threadinterrupt.h b/src/threadinterrupt.h
index 2743571379..0654c2ab1f 100644
--- a/src/threadinterrupt.h
+++ b/src/threadinterrupt.h
@@ -10,7 +10,6 @@
#include <atomic>
#include <chrono>
#include <condition_variable>
-#include <mutex>
/*
A helper class for interruptible sleeps. Calling operator() will interrupt
diff --git a/src/torcontrol.h b/src/torcontrol.h
index 079146b540..e1a1a7937a 100644
--- a/src/torcontrol.h
+++ b/src/torcontrol.h
@@ -8,7 +8,6 @@
#ifndef BITCOIN_TORCONTROL_H
#define BITCOIN_TORCONTROL_H
-#include <scheduler.h>
extern const std::string DEFAULT_TOR_CONTROL;
static const bool DEFAULT_LISTEN_ONION = true;
diff --git a/src/txdb.h b/src/txdb.h
index 140ce2c7ff..05bf4e4453 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -11,7 +11,6 @@
#include <chain.h>
#include <primitives/block.h>
-#include <map>
#include <memory>
#include <string>
#include <utility>
diff --git a/src/txmempool.h b/src/txmempool.h
index 229a923a28..b51e800001 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -8,7 +8,6 @@
#include <atomic>
#include <map>
-#include <memory>
#include <set>
#include <string>
#include <utility>
diff --git a/src/ui_interface.h b/src/ui_interface.h
index 5e0380dc45..9efc2db391 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -8,7 +8,6 @@
#include <functional>
#include <memory>
-#include <stdint.h>
#include <string>
class CBlockIndex;
diff --git a/src/uint256.cpp b/src/uint256.cpp
index ea7164c1f0..ee597e1877 100644
--- a/src/uint256.cpp
+++ b/src/uint256.cpp
@@ -7,7 +7,6 @@
#include <util/strencodings.h>
-#include <stdio.h>
#include <string.h>
template <unsigned int BITS>
diff --git a/src/uint256.h b/src/uint256.h
index 97e0cfa015..60c5e0554c 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -8,7 +8,6 @@
#include <assert.h>
#include <cstring>
-#include <stdexcept>
#include <stdint.h>
#include <string>
#include <vector>
diff --git a/src/util/moneystr.cpp b/src/util/moneystr.cpp
index f4e41eea4f..ba5a12e58c 100644
--- a/src/util/moneystr.cpp
+++ b/src/util/moneystr.cpp
@@ -5,7 +5,6 @@
#include <util/moneystr.h>
-#include <primitives/transaction.h>
#include <tinyformat.h>
#include <util/strencodings.h>
diff --git a/src/util/moneystr.h b/src/util/moneystr.h
index b8e2812a96..4d0218911a 100644
--- a/src/util/moneystr.h
+++ b/src/util/moneystr.h
@@ -12,7 +12,6 @@
#include <amount.h>
#include <attributes.h>
-#include <cstdint>
#include <string>
/* Do not use these functions to represent or parse monetary amounts to or from
diff --git a/src/util/string.h b/src/util/string.h
index dec0c19b08..76a83a4949 100644
--- a/src/util/string.h
+++ b/src/util/string.h
@@ -5,7 +5,6 @@
#ifndef BITCOIN_UTIL_STRING_H
#define BITCOIN_UTIL_STRING_H
-#include <functional>
#include <string>
#include <vector>
diff --git a/src/util/system.cpp b/src/util/system.cpp
index f22256615f..6199e5daad 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -9,7 +9,6 @@
#include <util/strencodings.h>
#include <util/translation.h>
-#include <stdarg.h>
#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
#include <pthread.h>
diff --git a/src/util/threadnames.cpp b/src/util/threadnames.cpp
index 168f9325d0..20df403a66 100644
--- a/src/util/threadnames.cpp
+++ b/src/util/threadnames.cpp
@@ -6,7 +6,6 @@
#include <config/bitcoin-config.h>
#endif
-#include <atomic>
#include <thread>
#if (defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
diff --git a/src/util/translation.h b/src/util/translation.h
index f100dab20d..0e6eb5a094 100644
--- a/src/util/translation.h
+++ b/src/util/translation.h
@@ -7,7 +7,6 @@
#include <tinyformat.h>
-#include <utility>
/**
* Bilingual messages:
diff --git a/src/validation.cpp b/src/validation.cpp
index 726f251c5a..7db1ade315 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -28,7 +28,6 @@
#include <reverse_iterator.h>
#include <script/script.h>
#include <script/sigcache.h>
-#include <script/standard.h>
#include <shutdown.h>
#include <timedata.h>
#include <tinyformat.h>
@@ -46,8 +45,6 @@
#include <validationinterface.h>
#include <warnings.h>
-#include <future>
-#include <sstream>
#include <string>
#include <boost/algorithm/string/replace.hpp>
diff --git a/src/validation.h b/src/validation.h
index fbbe3757e0..9140bf16e1 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -24,12 +24,10 @@
#include <algorithm>
#include <atomic>
-#include <exception>
#include <map>
#include <memory>
#include <set>
#include <stdint.h>
-#include <string>
#include <utility>
#include <vector>
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index 59a620ab95..cf4a529a6d 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -9,8 +9,6 @@
#include <scheduler.h>
#include <txmempool.h>
-#include <list>
-#include <atomic>
#include <future>
#include <utility>
diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp
index 0b76c1a0eb..f6179aa298 100644
--- a/src/wallet/crypter.cpp
+++ b/src/wallet/crypter.cpp
@@ -6,11 +6,8 @@
#include <crypto/aes.h>
#include <crypto/sha512.h>
-#include <script/script.h>
-#include <script/standard.h>
#include <util/system.h>
-#include <string>
#include <vector>
int CCrypter::BytesToKeySHA512AES(const std::vector<unsigned char>& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const
diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h
index 17a4e9820c..4367a5047f 100644
--- a/src/wallet/crypter.h
+++ b/src/wallet/crypter.h
@@ -9,7 +9,6 @@
#include <support/allocators/secure.h>
#include <script/signingprovider.h>
-#include <atomic>
const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
diff --git a/src/wallet/db.h b/src/wallet/db.h
index 94f41eaf16..d9d2070cfc 100644
--- a/src/wallet/db.h
+++ b/src/wallet/db.h
@@ -10,9 +10,7 @@
#include <fs.h>
#include <serialize.h>
#include <streams.h>
-#include <sync.h>
#include <util/system.h>
-#include <version.h>
#include <atomic>
#include <map>
diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp
index b87231293f..fbcf8d4de7 100644
--- a/src/wallet/feebumper.cpp
+++ b/src/wallet/feebumper.cpp
@@ -17,15 +17,15 @@
//! Check whether transaction has descendant in wallet or mempool, or has been
//! mined, or conflicts with a mined transaction. Return a feebumper::Result.
-static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chain, const CWallet* wallet, const CWalletTx& wtx, std::vector<std::string>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet->cs_wallet)
+static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chain, const CWallet& wallet, const CWalletTx& wtx, std::vector<std::string>& errors) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
{
- if (wallet->HasWalletSpend(wtx.GetHash())) {
+ if (wallet.HasWalletSpend(wtx.GetHash())) {
errors.push_back("Transaction has descendants in the wallet");
return feebumper::Result::INVALID_PARAMETER;
}
{
- if (wallet->chain().hasDescendantsInMempool(wtx.GetHash())) {
+ if (wallet.chain().hasDescendantsInMempool(wtx.GetHash())) {
errors.push_back("Transaction has descendants in the mempool");
return feebumper::Result::INVALID_PARAMETER;
}
@@ -48,7 +48,7 @@ static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chai
// check that original tx consists entirely of our inputs
// if not, we can't bump the fee, because the wallet has no way of knowing the value of the other inputs (thus the fee)
- if (!wallet->IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
+ if (!wallet.IsAllFromMe(*wtx.tx, ISMINE_SPENDABLE)) {
errors.push_back("Transaction contains inputs that don't belong to this wallet");
return feebumper::Result::WALLET_ERROR;
}
@@ -58,13 +58,13 @@ static feebumper::Result PreconditionChecks(interfaces::Chain::Lock& locked_chai
}
//! Check if the user provided a valid feeRate
-static feebumper::Result CheckFeeRate(const CWallet* wallet, const CWalletTx& wtx, const CFeeRate& newFeerate, const int64_t maxTxSize, std::vector<std::string>& errors) {
+static feebumper::Result CheckFeeRate(const CWallet& wallet, const CWalletTx& wtx, const CFeeRate& newFeerate, const int64_t maxTxSize, std::vector<std::string>& errors) {
// check that fee rate is higher than mempool's minimum fee
// (no point in bumping fee if we know that the new tx won't be accepted to the mempool)
// This may occur if the user set FeeRate, TotalFee or paytxfee too low, if fallbackfee is too low, or, perhaps,
// in a rare situation where the mempool minimum fee increased significantly since the fee estimation just a
// moment earlier. In this case, we report an error to the user, who may adjust the fee.
- CFeeRate minMempoolFeeRate = wallet->chain().mempoolMinFee();
+ CFeeRate minMempoolFeeRate = wallet.chain().mempoolMinFee();
if (newFeerate.GetFeePerK() < minMempoolFeeRate.GetFeePerK()) {
errors.push_back(strprintf(
@@ -76,7 +76,7 @@ static feebumper::Result CheckFeeRate(const CWallet* wallet, const CWalletTx& wt
CAmount new_total_fee = newFeerate.GetFee(maxTxSize);
- CFeeRate incrementalRelayFee = std::max(wallet->chain().relayIncrementalFee(), CFeeRate(WALLET_INCREMENTAL_RELAY_FEE));
+ CFeeRate incrementalRelayFee = std::max(wallet.chain().relayIncrementalFee(), CFeeRate(WALLET_INCREMENTAL_RELAY_FEE));
// Given old total fee and transaction size, calculate the old feeRate
CAmount old_fee = wtx.GetDebit(ISMINE_SPENDABLE) - wtx.tx->GetValueOut();
@@ -91,7 +91,7 @@ static feebumper::Result CheckFeeRate(const CWallet* wallet, const CWalletTx& wt
return feebumper::Result::INVALID_PARAMETER;
}
- CAmount requiredFee = GetRequiredFee(*wallet, maxTxSize);
+ CAmount requiredFee = GetRequiredFee(wallet, maxTxSize);
if (new_total_fee < requiredFee) {
errors.push_back(strprintf("Insufficient total fee (cannot be less than required fee %s)",
FormatMoney(requiredFee)));
@@ -99,7 +99,7 @@ static feebumper::Result CheckFeeRate(const CWallet* wallet, const CWalletTx& wt
}
// Check that in all cases the new fee doesn't violate maxTxFee
- const CAmount max_tx_fee = wallet->m_default_max_tx_fee;
+ const CAmount max_tx_fee = wallet.m_default_max_tx_fee;
if (new_total_fee > max_tx_fee) {
errors.push_back(strprintf("Specified or calculated fee %s is too high (cannot be higher than -maxtxfee %s)",
FormatMoney(new_total_fee), FormatMoney(max_tx_fee)));
@@ -109,7 +109,7 @@ static feebumper::Result CheckFeeRate(const CWallet* wallet, const CWalletTx& wt
return feebumper::Result::OK;
}
-static CFeeRate EstimateFeeRate(CWallet* wallet, const CWalletTx& wtx, CCoinControl& coin_control, CAmount& old_fee)
+static CFeeRate EstimateFeeRate(const CWallet& wallet, const CWalletTx& wtx, CCoinControl& coin_control, CAmount& old_fee)
{
// Get the fee rate of the original transaction. This is calculated from
// the tx fee/vsize, so it may have been rounded down. Add 1 satoshi to the
@@ -123,15 +123,15 @@ static CFeeRate EstimateFeeRate(CWallet* wallet, const CWalletTx& wtx, CCoinCont
// the minimum of that and the wallet's conservative
// WALLET_INCREMENTAL_RELAY_FEE value to future proof against changes to
// network wide policy for incremental relay fee that our node may not be
- // aware of. This ensures we're over the over the required relay fee rate
+ // aware of. This ensures we're over the required relay fee rate
// (BIP 125 rule 4). The replacement tx will be at least as large as the
// original tx, so the total fee will be greater (BIP 125 rule 3)
- CFeeRate node_incremental_relay_fee = wallet->chain().relayIncrementalFee();
+ CFeeRate node_incremental_relay_fee = wallet.chain().relayIncrementalFee();
CFeeRate wallet_incremental_relay_fee = CFeeRate(WALLET_INCREMENTAL_RELAY_FEE);
feerate += std::max(node_incremental_relay_fee, wallet_incremental_relay_fee);
// Fee rate must also be at least the wallet's GetMinimumFeeRate
- CFeeRate min_feerate(GetMinimumFeeRate(*wallet, coin_control, /* feeCalc */ nullptr));
+ CFeeRate min_feerate(GetMinimumFeeRate(wallet, coin_control, /* feeCalc */ nullptr));
// Set the required fee rate for the replacement transaction in coin control.
return std::max(feerate, min_feerate);
@@ -139,11 +139,11 @@ static CFeeRate EstimateFeeRate(CWallet* wallet, const CWalletTx& wtx, CCoinCont
namespace feebumper {
-bool TransactionCanBeBumped(const CWallet* wallet, const uint256& txid)
+bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid)
{
- auto locked_chain = wallet->chain().lock();
- LOCK(wallet->cs_wallet);
- const CWalletTx* wtx = wallet->GetWalletTx(txid);
+ auto locked_chain = wallet.chain().lock();
+ LOCK(wallet.cs_wallet);
+ const CWalletTx* wtx = wallet.GetWalletTx(txid);
if (wtx == nullptr) return false;
std::vector<std::string> errors_dummy;
@@ -166,7 +166,7 @@ Result CreateTotalBumpTransaction(const CWallet* wallet, const uint256& txid, co
}
const CWalletTx& wtx = it->second;
- Result result = PreconditionChecks(*locked_chain, wallet, wtx, errors);
+ Result result = PreconditionChecks(*locked_chain, *wallet, wtx, errors);
if (result != Result::OK) {
return result;
}
@@ -276,17 +276,17 @@ Result CreateTotalBumpTransaction(const CWallet* wallet, const uint256& txid, co
}
-Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<std::string>& errors,
+Result CreateRateBumpTransaction(CWallet& wallet, const uint256& txid, const CCoinControl& coin_control, std::vector<std::string>& errors,
CAmount& old_fee, CAmount& new_fee, CMutableTransaction& mtx)
{
// We are going to modify coin control later, copy to re-use
CCoinControl new_coin_control(coin_control);
- auto locked_chain = wallet->chain().lock();
- LOCK(wallet->cs_wallet);
+ auto locked_chain = wallet.chain().lock();
+ LOCK(wallet.cs_wallet);
errors.clear();
- auto it = wallet->mapWallet.find(txid);
- if (it == wallet->mapWallet.end()) {
+ auto it = wallet.mapWallet.find(txid);
+ if (it == wallet.mapWallet.end()) {
errors.push_back("Invalid or non-wallet transaction id");
return Result::INVALID_ADDRESS_OR_KEY;
}
@@ -300,7 +300,7 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
// Fill in recipients(and preserve a single change key if there is one)
std::vector<CRecipient> recipients;
for (const auto& output : wtx.tx->vout) {
- if (!wallet->IsChange(output)) {
+ if (!wallet.IsChange(output)) {
CRecipient recipient = {output.scriptPubKey, output.nValue, false};
recipients.push_back(recipient);
} else {
@@ -313,8 +313,8 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
if (coin_control.m_feerate) {
// The user provided a feeRate argument.
// We calculate this here to avoid compiler warning on the cs_wallet lock
- const int64_t maxTxSize = CalculateMaximumSignedTxSize(*wtx.tx, wallet);
- Result res = CheckFeeRate(wallet, wtx, *(new_coin_control.m_feerate), maxTxSize, errors);
+ const int64_t maxTxSize = CalculateMaximumSignedTxSize(*wtx.tx, &wallet);
+ Result res = CheckFeeRate(wallet, wtx, *new_coin_control.m_feerate, maxTxSize, errors);
if (res != Result::OK) {
return res;
}
@@ -342,7 +342,7 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
CAmount fee_ret;
int change_pos_in_out = -1; // No requested location for change
std::string fail_reason;
- if (!wallet->CreateTransaction(*locked_chain, recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, false)) {
+ if (!wallet.CreateTransaction(*locked_chain, recipients, tx_new, fee_ret, change_pos_in_out, fail_reason, new_coin_control, false)) {
errors.push_back("Unable to create transaction: " + fail_reason);
return Result::WALLET_ERROR;
}
@@ -353,7 +353,7 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
// Write back transaction
mtx = CMutableTransaction(*tx_new);
// Mark new tx not replaceable, if requested.
- if (!coin_control.m_signal_bip125_rbf.get_value_or(wallet->m_signal_rbf)) {
+ if (!coin_control.m_signal_bip125_rbf.get_value_or(wallet.m_signal_rbf)) {
for (auto& input : mtx.vin) {
if (input.nSequence < 0xfffffffe) input.nSequence = 0xfffffffe;
}
@@ -362,21 +362,21 @@ Result CreateRateBumpTransaction(CWallet* wallet, const uint256& txid, const CCo
return Result::OK;
}
-bool SignTransaction(CWallet* wallet, CMutableTransaction& mtx) {
- auto locked_chain = wallet->chain().lock();
- LOCK(wallet->cs_wallet);
- return wallet->SignTransaction(mtx);
+bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx) {
+ auto locked_chain = wallet.chain().lock();
+ LOCK(wallet.cs_wallet);
+ return wallet.SignTransaction(mtx);
}
-Result CommitTransaction(CWallet* wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<std::string>& errors, uint256& bumped_txid)
+Result CommitTransaction(CWallet& wallet, const uint256& txid, CMutableTransaction&& mtx, std::vector<std::string>& errors, uint256& bumped_txid)
{
- auto locked_chain = wallet->chain().lock();
- LOCK(wallet->cs_wallet);
+ auto locked_chain = wallet.chain().lock();
+ LOCK(wallet.cs_wallet);
if (!errors.empty()) {
return Result::MISC_ERROR;
}
- auto it = txid.IsNull() ? wallet->mapWallet.end() : wallet->mapWallet.find(txid);
- if (it == wallet->mapWallet.end()) {
+ auto it = txid.IsNull() ? wallet.mapWallet.end() : wallet.mapWallet.find(txid);
+ if (it == wallet.mapWallet.end()) {
errors.push_back("Invalid or non-wallet transaction id");
return Result::MISC_ERROR;
}
@@ -394,7 +394,7 @@ Result CommitTransaction(CWallet* wallet, const uint256& txid, CMutableTransacti
mapValue["replaces_txid"] = oldWtx.GetHash().ToString();
CValidationState state;
- if (!wallet->CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm, state)) {
+ if (!wallet.CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm, state)) {
// NOTE: CommitTransaction never returns false, so this should never happen.
errors.push_back(strprintf("The transaction was rejected: %s", FormatStateMessage(state)));
return Result::WALLET_ERROR;
@@ -408,7 +408,7 @@ Result CommitTransaction(CWallet* wallet, const uint256& txid, CMutableTransacti
}
// mark the original tx as bumped
- if (!wallet->MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
+ if (!wallet.MarkReplaced(oldWtx.GetHash(), bumped_txid)) {
// TODO: see if JSON-RPC has a standard way of returning a response
// along with an exception. It would be good to return information about
// wtxBumped to the caller even if marking the original transaction
diff --git a/src/wallet/feebumper.h b/src/wallet/feebumper.h
index 0c4e1cb7dd..9357397606 100644
--- a/src/wallet/feebumper.h
+++ b/src/wallet/feebumper.h
@@ -26,7 +26,7 @@ enum class Result
};
//! Return whether transaction can be bumped.
-bool TransactionCanBeBumped(const CWallet* wallet, const uint256& txid);
+bool TransactionCanBeBumped(const CWallet& wallet, const uint256& txid);
//! Create bumpfee transaction based on total amount.
Result CreateTotalBumpTransaction(const CWallet* wallet,
@@ -39,7 +39,7 @@ Result CreateTotalBumpTransaction(const CWallet* wallet,
CMutableTransaction& mtx);
//! Create bumpfee transaction based on feerate estimates.
-Result CreateRateBumpTransaction(CWallet* wallet,
+Result CreateRateBumpTransaction(CWallet& wallet,
const uint256& txid,
const CCoinControl& coin_control,
std::vector<std::string>& errors,
@@ -50,13 +50,13 @@ Result CreateRateBumpTransaction(CWallet* wallet,
//! Sign the new transaction,
//! @return false if the tx couldn't be found or if it was
//! impossible to create the signature(s)
-bool SignTransaction(CWallet* wallet, CMutableTransaction& mtx);
+bool SignTransaction(CWallet& wallet, CMutableTransaction& mtx);
//! Commit the bumpfee transaction.
//! @return success in case of CWallet::CommitTransaction was successful,
//! but sets errors if the tx could not be added to the mempool (will try later)
//! or if the old transaction could not be marked as replaced.
-Result CommitTransaction(CWallet* wallet,
+Result CommitTransaction(CWallet& wallet,
const uint256& txid,
CMutableTransaction&& mtx,
std::vector<std::string>& errors,
diff --git a/src/wallet/fees.cpp b/src/wallet/fees.cpp
index 2792058f2a..249bc833c6 100644
--- a/src/wallet/fees.cpp
+++ b/src/wallet/fees.cpp
@@ -5,7 +5,6 @@
#include <wallet/fees.h>
-#include <util/system.h>
#include <wallet/coincontrol.h>
#include <wallet/wallet.h>
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 43b6ead028..3657a157b6 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -11,7 +11,6 @@
#include <util/system.h>
#include <util/translation.h>
#include <wallet/wallet.h>
-#include <wallet/walletutil.h>
#include <walletinitinterface.h>
class WalletInit : public WalletInitInterface {
@@ -122,8 +121,6 @@ bool WalletInit::ParameterInteraction() const
if (gArgs.GetBoolArg("-sysperms", false))
return InitError("-sysperms is not allowed in combination with enabled wallet functionality");
- if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false))
- return InitError(_("Rescans are not possible in pruned mode. You will need to use -reindex which will download the whole blockchain again.").translated);
return true;
}
diff --git a/src/wallet/ismine.cpp b/src/wallet/ismine.cpp
index b7ef2d4490..029b922785 100644
--- a/src/wallet/ismine.cpp
+++ b/src/wallet/ismine.cpp
@@ -7,7 +7,6 @@
#include <key.h>
#include <script/script.h>
-#include <script/sign.h>
#include <script/signingprovider.h>
#include <wallet/wallet.h>
diff --git a/src/wallet/psbtwallet.h b/src/wallet/psbtwallet.h
index a24a0967d2..a7e52df6d9 100644
--- a/src/wallet/psbtwallet.h
+++ b/src/wallet/psbtwallet.h
@@ -5,9 +5,7 @@
#ifndef BITCOIN_WALLET_PSBTWALLET_H
#define BITCOIN_WALLET_PSBTWALLET_H
-#include <node/transaction.h>
#include <psbt.h>
-#include <primitives/transaction.h>
#include <wallet/wallet.h>
/**
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index f52e4318c8..1cd4cb93b4 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -7,7 +7,6 @@
#include <interfaces/chain.h>
#include <key_io.h>
#include <merkleblock.h>
-#include <rpc/server.h>
#include <rpc/util.h>
#include <script/descriptor.h>
#include <script/script.h>
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index dc437e5cd8..c8dbbf8108 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -9,7 +9,6 @@
#include <init.h>
#include <interfaces/chain.h>
#include <key_io.h>
-#include <node/transaction.h>
#include <outputtype.h>
#include <policy/feerate.h>
#include <policy/fees.h>
@@ -37,7 +36,6 @@
#include <univalue.h>
-#include <functional>
static const std::string WALLET_ENDPOINT_BASE = "/wallet/";
@@ -3417,7 +3415,7 @@ static UniValue bumpfee(const JSONRPCRequest& request)
res = feebumper::CreateTotalBumpTransaction(pwallet, hash, coin_control, totalFee, errors, old_fee, new_fee, mtx);
} else {
// Targeting feerate bump.
- res = feebumper::CreateRateBumpTransaction(pwallet, hash, coin_control, errors, old_fee, new_fee, mtx);
+ res = feebumper::CreateRateBumpTransaction(*pwallet, hash, coin_control, errors, old_fee, new_fee, mtx);
}
if (res != feebumper::Result::OK) {
switch(res) {
@@ -3440,12 +3438,12 @@ static UniValue bumpfee(const JSONRPCRequest& request)
}
// sign bumped transaction
- if (!feebumper::SignTransaction(pwallet, mtx)) {
+ if (!feebumper::SignTransaction(*pwallet, mtx)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Can't sign transaction.");
}
// commit the bumped transaction
uint256 txid;
- if (feebumper::CommitTransaction(pwallet, hash, std::move(mtx), errors, txid) != feebumper::Result::OK) {
+ if (feebumper::CommitTransaction(*pwallet, hash, std::move(mtx), errors, txid) != feebumper::Result::OK) {
throw JSONRPCError(RPC_WALLET_ERROR, errors[0]);
}
UniValue result(UniValue::VOBJ);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 09f08220db..ca1f16f692 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -27,13 +27,11 @@
#include <util/rbf.h>
#include <util/translation.h>
#include <util/validation.h>
-#include <validation.h>
#include <wallet/coincontrol.h>
#include <wallet/fees.h>
#include <algorithm>
#include <assert.h>
-#include <future>
#include <boost/algorithm/string/replace.hpp>
@@ -2739,8 +2737,11 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
}
std::vector<OutputGroup> groups = GroupOutputs(vCoins, !coin_control.m_avoid_partial_spends);
- size_t max_ancestors = (size_t)std::max<int64_t>(1, gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT));
- size_t max_descendants = (size_t)std::max<int64_t>(1, gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT));
+ unsigned int limit_ancestor_count;
+ unsigned int limit_descendant_count;
+ chain().getPackageLimits(limit_ancestor_count, limit_descendant_count);
+ size_t max_ancestors = (size_t)std::max<int64_t>(1, limit_ancestor_count);
+ size_t max_descendants = (size_t)std::max<int64_t>(1, limit_descendant_count);
bool fRejectLongChains = gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS);
bool res = nTargetValue <= nValueFromPresetInputs ||
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 006775e83b..62641fceec 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -11,7 +11,6 @@
#include <interfaces/handler.h>
#include <outputtype.h>
#include <policy/feerate.h>
-#include <script/sign.h>
#include <tinyformat.h>
#include <ui_interface.h>
#include <util/strencodings.h>
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index 0fee35934d..918dac9ecf 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -7,15 +7,12 @@
#define BITCOIN_WALLET_WALLETDB_H
#include <amount.h>
-#include <primitives/transaction.h>
#include <script/sign.h>
#include <wallet/db.h>
#include <key.h>
-#include <list>
#include <stdint.h>
#include <string>
-#include <utility>
#include <vector>
/**
diff --git a/src/wallet/wallettool.h b/src/wallet/wallettool.h
index 7ee2505631..bd08da42d6 100644
--- a/src/wallet/wallettool.h
+++ b/src/wallet/wallettool.h
@@ -5,7 +5,6 @@
#ifndef BITCOIN_WALLET_WALLETTOOL_H
#define BITCOIN_WALLET_WALLETTOOL_H
-#include <wallet/ismine.h>
#include <wallet/wallet.h>
namespace WalletTool {
diff --git a/src/warnings.h b/src/warnings.h
index 16c8f7b52e..e6701ebd9e 100644
--- a/src/warnings.h
+++ b/src/warnings.h
@@ -6,7 +6,6 @@
#ifndef BITCOIN_WARNINGS_H
#define BITCOIN_WARNINGS_H
-#include <stdlib.h>
#include <string>
void SetMiscWarning(const std::string& strWarning);
diff --git a/src/zmq/zmqconfig.h b/src/zmq/zmqconfig.h
index 5219ffad40..e3fdbf7402 100644
--- a/src/zmq/zmqconfig.h
+++ b/src/zmq/zmqconfig.h
@@ -10,13 +10,11 @@
#endif
#include <stdarg.h>
-#include <string>
#if ENABLE_ZMQ
#include <zmq.h>
#endif
-#include <primitives/block.h>
#include <primitives/transaction.h>
void zmqError(const char *str);
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp
index de59b71b8f..ebbaf8683d 100644
--- a/src/zmq/zmqnotificationinterface.cpp
+++ b/src/zmq/zmqnotificationinterface.cpp
@@ -5,7 +5,6 @@
#include <zmq/zmqnotificationinterface.h>
#include <zmq/zmqpublishnotifier.h>
-#include <version.h>
#include <validation.h>
#include <util/system.h>
diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h
index a0cc26a162..6be0554a65 100644
--- a/src/zmq/zmqnotificationinterface.h
+++ b/src/zmq/zmqnotificationinterface.h
@@ -6,8 +6,6 @@
#define BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H
#include <validationinterface.h>
-#include <string>
-#include <map>
#include <list>
class CBlockIndex;
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
index c74270febc..c7e98bd4db 100755
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -46,7 +46,7 @@ from test_framework.script import (
OP_RETURN,
OP_TRUE,
SIGHASH_ALL,
- SignatureHash,
+ LegacySignatureHash,
hash160,
)
from test_framework.test_framework import BitcoinTestFramework
@@ -532,7 +532,7 @@ class FullBlockTest(BitcoinTestFramework):
# second input is corresponding P2SH output from b39
tx.vin.append(CTxIn(COutPoint(b39.vtx[i].sha256, 0), b''))
# Note: must pass the redeem_script (not p2sh_script) to the signature hash function
- (sighash, err) = SignatureHash(redeem_script, tx, 1, SIGHASH_ALL)
+ (sighash, err) = LegacySignatureHash(redeem_script, tx, 1, SIGHASH_ALL)
sig = self.coinbase_key.sign_ecdsa(sighash) + bytes(bytearray([SIGHASH_ALL]))
scriptSig = CScript([sig, redeem_script])
@@ -1312,7 +1312,7 @@ class FullBlockTest(BitcoinTestFramework):
if (scriptPubKey[0] == OP_TRUE): # an anyone-can-spend
tx.vin[0].scriptSig = CScript()
return
- (sighash, err) = SignatureHash(spend_tx.vout[0].scriptPubKey, tx, 0, SIGHASH_ALL)
+ (sighash, err) = LegacySignatureHash(spend_tx.vout[0].scriptPubKey, tx, 0, SIGHASH_ALL)
tx.vin[0].scriptSig = CScript([self.coinbase_key.sign_ecdsa(sighash) + bytes(bytearray([SIGHASH_ALL]))])
def create_and_sign_transaction(self, spend_tx, value, script=CScript([OP_TRUE])):
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 98f6b1d71d..0c7edbf434 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -67,8 +67,8 @@ from test_framework.script import (
SIGHASH_ANYONECANPAY,
SIGHASH_NONE,
SIGHASH_SINGLE,
- SegwitVersion1SignatureHash,
- SignatureHash,
+ SegwitV0SignatureHash,
+ LegacySignatureHash,
hash160,
)
from test_framework.test_framework import BitcoinTestFramework
@@ -103,7 +103,7 @@ def get_p2pkh_script(pubkeyhash):
def sign_p2pk_witness_input(script, tx_to, in_idx, hashtype, value, key):
"""Add signature for a P2PK witness program."""
- tx_hash = SegwitVersion1SignatureHash(script, tx_to, in_idx, hashtype, value)
+ tx_hash = SegwitV0SignatureHash(script, tx_to, in_idx, hashtype, value)
signature = key.sign_ecdsa(tx_hash) + chr(hashtype).encode('latin-1')
tx_to.wit.vtxinwit[in_idx].scriptWitness.stack = [signature, script]
tx_to.rehash()
@@ -1489,7 +1489,7 @@ class SegWitTest(BitcoinTestFramework):
tx2.vin.append(CTxIn(COutPoint(tx.sha256, 0), b""))
tx2.vout.append(CTxOut(tx.vout[0].nValue - 1000, script_wsh))
script = get_p2pkh_script(pubkeyhash)
- sig_hash = SegwitVersion1SignatureHash(script, tx2, 0, SIGHASH_ALL, tx.vout[0].nValue)
+ sig_hash = SegwitV0SignatureHash(script, tx2, 0, SIGHASH_ALL, tx.vout[0].nValue)
signature = key.sign_ecdsa(sig_hash) + b'\x01' # 0x1 is SIGHASH_ALL
tx2.wit.vtxinwit.append(CTxInWitness())
tx2.wit.vtxinwit[0].scriptWitness.stack = [signature, pubkey]
@@ -1543,7 +1543,7 @@ class SegWitTest(BitcoinTestFramework):
tx5 = CTransaction()
tx5.vin.append(CTxIn(COutPoint(tx4.sha256, 0), b""))
tx5.vout.append(CTxOut(tx4.vout[0].nValue - 1000, CScript([OP_TRUE])))
- (sig_hash, err) = SignatureHash(script_pubkey, tx5, 0, SIGHASH_ALL)
+ (sig_hash, err) = LegacySignatureHash(script_pubkey, tx5, 0, SIGHASH_ALL)
signature = key.sign_ecdsa(sig_hash) + b'\x01' # 0x1 is SIGHASH_ALL
tx5.vin[0].scriptSig = CScript([signature, pubkey])
tx5.rehash()
@@ -1693,7 +1693,7 @@ class SegWitTest(BitcoinTestFramework):
tx2.vout.append(CTxOut(tx.vout[0].nValue, CScript([OP_TRUE])))
script = get_p2pkh_script(pubkeyhash)
- sig_hash = SegwitVersion1SignatureHash(script, tx2, 0, SIGHASH_ALL, tx.vout[0].nValue)
+ sig_hash = SegwitV0SignatureHash(script, tx2, 0, SIGHASH_ALL, tx.vout[0].nValue)
signature = key.sign_ecdsa(sig_hash) + b'\x01' # 0x1 is SIGHASH_ALL
# Check that we can't have a scriptSig
diff --git a/test/functional/test_framework/script.py b/test/functional/test_framework/script.py
index 384062b808..51aa9057f7 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -2,7 +2,7 @@
# Copyright (c) 2015-2019 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
-"""Functionality to build scripts, as well as SignatureHash().
+"""Functionality to build scripts, as well as signature hash functions.
This file is modified from python-bitcoinlib.
"""
@@ -608,7 +608,7 @@ def FindAndDelete(script, sig):
return CScript(r)
-def SignatureHash(script, txTo, inIdx, hashtype):
+def LegacySignatureHash(script, txTo, inIdx, hashtype):
"""Consensus-correct SignatureHash
Returns (hash, err) to precisely match the consensus-critical behavior of
@@ -662,7 +662,7 @@ def SignatureHash(script, txTo, inIdx, hashtype):
# Performance optimization probably not necessary for python tests, however.
# Note that this corresponds to sigversion == 1 in EvalScript, which is used
# for version 0 witnesses.
-def SegwitVersion1SignatureHash(script, txTo, inIdx, hashtype, amount):
+def SegwitV0SignatureHash(script, txTo, inIdx, hashtype, amount):
hashPrevouts = 0
hashSequence = 0