aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/good_first_issue.md7
-rw-r--r--CONTRIBUTING.md58
-rw-r--r--configure.ac2
-rw-r--r--doc/release-notes-16528.md120
-rw-r--r--doc/release-notes-18918.md3
-rw-r--r--doc/release-notes.md171
-rw-r--r--doc/release-notes/release-notes-0.20.0.md987
-rw-r--r--src/Makefile.bench.include1
-rw-r--r--src/Makefile.test.include35
-rw-r--r--src/bench/hashpadding.cpp47
-rw-r--r--src/blockfilter.h8
-rw-r--r--src/interfaces/chain.cpp4
-rw-r--r--src/interfaces/chain.h3
-rw-r--r--src/net.cpp23
-rw-r--r--src/net_processing.cpp91
-rw-r--r--src/protocol.cpp4
-rw-r--r--src/protocol.h11
-rw-r--r--src/psbt.h2
-rw-r--r--src/qt/bitcoin.cpp32
-rw-r--r--src/qt/walletview.cpp2
-rw-r--r--src/rpc/blockchain.cpp2
-rw-r--r--src/rpc/mining.cpp2
-rw-r--r--src/rpc/server.cpp4
-rw-r--r--src/script/sigcache.cpp12
-rw-r--r--src/support/lockedpool.cpp1
-rw-r--r--src/support/lockedpool.h4
-rw-r--r--src/test/fuzz/process_message.cpp7
-rw-r--r--src/test/fuzz/process_messages.cpp3
-rw-r--r--src/test/fuzz/script.cpp39
-rw-r--r--src/test/fuzz/script_bitcoin_consensus.cpp31
-rw-r--r--src/test/fuzz/script_descriptor_cache.cpp42
-rw-r--r--src/test/fuzz/script_interpreter.cpp41
-rw-r--r--src/test/fuzz/script_sigcache.cpp45
-rw-r--r--src/test/fuzz/script_sign.cpp149
-rw-r--r--src/test/fuzz/string.cpp5
-rw-r--r--src/test/fuzz/util.h57
-rw-r--r--src/test/raii_event_tests.cpp19
-rw-r--r--src/txmempool.cpp2
-rw-r--r--src/txmempool.h6
-rw-r--r--src/validation.cpp37
-rw-r--r--src/validationinterface.cpp20
-rw-r--r--src/validationinterface.h9
-rw-r--r--src/wallet/db.cpp3
-rw-r--r--src/wallet/wallet.cpp53
-rw-r--r--src/wallet/wallet.h2
-rw-r--r--src/wallet/walletdb.cpp14
-rw-r--r--test/config.ini.in1
-rwxr-xr-xtest/functional/feature_notifications.py9
-rwxr-xr-xtest/functional/mempool_persist.py10
-rwxr-xr-xtest/functional/mempool_unbroadcast.py12
-rwxr-xr-xtest/functional/p2p_blockfilters.py74
-rwxr-xr-xtest/functional/rpc_getaddressinfo_label_deprecation.py2
-rw-r--r--test/functional/test_framework/address.py49
-rwxr-xr-xtest/functional/test_framework/messages.py51
-rwxr-xr-xtest/functional/test_framework/mininode.py11
-rwxr-xr-xtest/functional/test_framework/test_framework.py5
-rwxr-xr-xtest/functional/test_runner.py1
-rwxr-xr-xtest/functional/wallet_hd.py52
-rwxr-xr-xtest/functional/wallet_labels.py27
-rwxr-xr-xtest/functional/wallet_resendwallettransactions.py15
60 files changed, 2216 insertions, 323 deletions
diff --git a/.github/ISSUE_TEMPLATE/good_first_issue.md b/.github/ISSUE_TEMPLATE/good_first_issue.md
index c441f7a307..8be78a1f6e 100644
--- a/.github/ISSUE_TEMPLATE/good_first_issue.md
+++ b/.github/ISSUE_TEMPLATE/good_first_issue.md
@@ -7,6 +7,9 @@ assignees: ''
---
+<!-- A good first issue is an uncontroversial issue, that has a relatively unique and obvious solution -->
+
+<!-- Motivate the issue and explain the solution briefly -->
#### Useful skills:
@@ -14,8 +17,4 @@ assignees: ''
#### Want to work on this issue?
-The purpose of the `good first issue` label is to highlight which issues are suitable for a new contributor without a deep understanding of the codebase.
-
-You do not need to request permission to start working on this. You are encouraged to comment on the issue if you are planning to work on it. This will help other contributors monitor which issues are actively being addressed and is also an effective way to request assistance if and when you need it.
-
For guidance on contributing, please read [CONTRIBUTING.md](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md) before opening your pull request.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7216db0500..f34b1e1e15 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -14,15 +14,49 @@ purposes. As such there are repository "maintainers" who are responsible for
merging pull requests as well as a "lead maintainer" who is responsible for the
release cycle, overall merging, moderation and appointment of maintainers.
+Getting Started
+---------------
+
+New contributors are very welcome and needed.
+
+Reviewing and testing is the most effective way you can contribute as a new
+contributor, and it also will teach you much more about the code and process
+than opening PRs. Please refer to the section [peer review](#peer-review) later
+in this document.
+
+Before you start contributing, familiarize yourself with the Bitcoin Core build
+system and tests. Refer to the documentation in the repository on how to build
+Bitcoin Core and how to run the unit and functional tests.
+
+There are many open issues of varying difficulty waiting to be fixed.
If you're looking for somewhere to start contributing, check out the
[good first issue](https://github.com/bitcoin/bitcoin/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
-list or participate in a weekly [Bitcoin Core PR Review Club](https://bitcoincore.reviews/) meeting.
+list or changes that are
+[up for grabs](https://github.com/bitcoin/bitcoin/issues?utf8=%E2%9C%93&q=label%3A%22Up+for+grabs%22).
+Some of them might no longer be applicable. So if you are interested, but
+unsure, you might want to leave a comment on the issue first.
+
+You may also participate in the weekly
+[Bitcoin Core PR Review Club](https://bitcoincore.reviews/) meeting.
+
+### Good First Issue Label
+
+The purpose of the `good first issue` label is to highlight which issues are
+suitable for a new contributor without a deep understanding of the codebase.
+
+However, good first issues can be solved by anyone. If they remain unsolved
+for a longer time, a frequent contributor might address them.
+
+You do not need to request permission to start working on an issue. However,
+you are encouraged to leave a comment if you are planning to work on it. This
+will help other contributors monitor which issues are actively being addressed
+and is also an effective way to request assistance if and when you need it.
Communication Channels
----------------------
Most communication about Bitcoin Core development happens on IRC, in the
-#bitcoin-core-dev channel on Freenode. The easiest way to participate on IRC is
+`#bitcoin-core-dev` channel on Freenode. The easiest way to participate on IRC is
with the web client, [webchat.freenode.net](https://webchat.freenode.net/). Chat
history logs can be found
on [http://www.erisian.com.au/bitcoin-core-dev/](http://www.erisian.com.au/bitcoin-core-dev/)
@@ -33,7 +67,7 @@ requests.
The developer
[mailing list](https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev)
-should be used to discuss complicated or controversial changes before working on
+should be used to discuss complicated or controversial consensus or P2P protocol changes before working on
a patch set.
@@ -53,6 +87,8 @@ To contribute a patch, the workflow is as follows:
The project coding conventions in the [developer notes](doc/developer-notes.md)
must be followed.
+### Committing Patches
+
In general, [commits should be atomic](https://en.wikipedia.org/wiki/Atomic_commit#Atomic_commit_convention)
and diffs should be easy to read. For this reason, do not mix any formatting
fixes or code moves with actual code changes.
@@ -76,6 +112,8 @@ about Git.
- Push changes to your fork
- Create pull request
+### Creating the Pull Request
+
The title of the pull request should be prefixed by the component or area that
the pull request affects. Valid areas as:
@@ -100,18 +138,24 @@ Examples:
qt: Add feed bump button
log: Fix typo in log message
+The body of the pull request should contain enough description about what the
+patch does together with any justification/reasoning. You should include
+references to any discussions (for example other tickets or mailing list
+discussions).
+
+### Translation changes
+
Note that translations should not be submitted as pull requests. Please see
[Translation Process](https://github.com/bitcoin/bitcoin/blob/master/doc/translation_process.md)
for more information on helping with translations.
+### Work in Progress Changes and Requests for Comments
+
If a pull request is not to be considered for merging (yet), please
prefix the title with [WIP] or use [Tasks Lists](https://help.github.com/articles/basic-writing-and-formatting-syntax/#task-lists)
in the body of the pull request to indicate tasks are pending.
-The body of the pull request should contain enough description about what the
-patch does together with any justification/reasoning. You should include
-references to any discussions (for example other tickets or mailing list
-discussions).
+### Address Feedback
At this stage, one should expect comments and review from other contributors. You
can add more commits to your pull request by committing them locally and pushing
diff --git a/configure.ac b/configure.ac
index 34b8354cda..3d8291bf58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -811,7 +811,7 @@ if test x$use_hardening != xno; then
fi
dnl These flags are specific to ld64, and may cause issues with other linkers.
-dnl For example: GNU ld will intepret -dead_strip as -de and then try and use
+dnl For example: GNU ld will interpret -dead_strip as -de and then try and use
dnl "ad_strip" as the symbol for the entry point.
if test x$TARGET_OS = xdarwin; then
AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]])
diff --git a/doc/release-notes-16528.md b/doc/release-notes-16528.md
index 0a7a31cc9d..e69de29bb2 100644
--- a/doc/release-notes-16528.md
+++ b/doc/release-notes-16528.md
@@ -1,120 +0,0 @@
-Wallet
-------
-
-### Experimental Descriptor Wallets
-
-Please note that Descriptor Wallets are still experimental and not all expected functionality
-is available. Additionally there may be some bugs and current functions may change in the future.
-Bugs and missing functionality can be reported to the [issue tracker](https://github.com/bitcoin/bitcoin/issues).
-
-0.21 introduces a new type of wallet - Descriptor Wallets. Descriptor Wallets store
-scriptPubKey information using descriptors. This is in contrast to the Legacy Wallet
-structure where keys are used to generate scriptPubKeys and addresses. Because of this
-shift to being script based instead of key based, many of the confusing things that Legacy
-Wallets do are not possible with Descriptor Wallets. Descriptor Wallets use a definition
-of "mine" for scripts which is simpler and more intuitive than that used by Legacy Wallets.
-Descriptor Wallets also uses different semantics for watch-only things and imports.
-
-As Descriptor Wallets are a new type of wallet, their introduction does not affect existing wallets.
-Users who already have a Bitcoin Core wallet can continue to use it as they did before without
-any change in behavior. Newly created Legacy Wallets (which is the default type of wallet) will
-behave as they did in previous versions of Bitcoin Core.
-
-The differences between Descriptor Wallets and Legacy Wallets are largely limited to non user facing
-things. They are intended to behave similarly except for the import/export and watchonly functionality
-as described below.
-
-#### Creating Descriptor Wallets
-
-Descriptor Wallets are not created by default. They must be explicitly created using the
-`createwallet` RPC or via the GUI. A `descriptors` option has been added to `createwallet`.
-Setting `descriptors` to `true` will create a Descriptor Wallet instead of a Legacy Wallet.
-
-In the GUI, a checkbox has been added to the Create Wallet Dialog to indicate that a
-Descriptor Wallet should be created.
-
-Without those options being set, a Legacy Wallet will be created instead. Additionally the
-Default Wallet created upon first startup of Bitcoin Core will be a Legacy Wallet.
-
-#### `IsMine` Semantics
-
-`IsMine` refers to the function used to determine whether a script belongs to the wallet.
-This is used to determine whether an output belongs to the wallet. `IsMine` in Legacy Wallets
-returns true if the wallet would be able to sign an input that spends an output with that script.
-Since keys can be involved in a variety of different scripts, this definition for `IsMine` can
-lead to many unexpected scripts being considered part of the wallet.
-
-With Descriptor Wallets, descriptors explicitly specify the set of scripts that are owned by
-the wallet. Since descriptors are deterministic and easily enumerable, users will know exactly
-what scripts the wallet will consider to belong to it. Additionally the implementation of `IsMine`
-in Descriptor Wallets is far simpler than for Legacy Wallets. Notably, in Legacy Wallets, `IsMine`
-allowed for users to take one type of address (e.g. P2PKH), mutate it into another address type
-(e.g. P2WPKH), and the wallet would still detect outputs sending to the new address type
-even without that address being requested from the wallet. Descriptor Wallets does not
-allow for this and will only watch for the addresses that were explicitly requested from the wallet.
-
-These changes to `IsMine` will make it easier to reason about what scripts the wallet will
-actually be watching for in outputs. However for the vast majority of users, this change is
-largely transparent and will not have noticeable effect.
-
-#### Imports and Exports
-
-In Legacy Wallets, raw scripts and keys could be imported to the wallet. Those imported scripts
-and keys are treated separately from the keys generated by the wallet. This complicates the `IsMine`
-logic as it has to distinguish between spendable and watchonly.
-
-Descriptor Wallets handle importing scripts and keys differently. Only complete descriptors can be
-imported. These descriptors are then added to the wallet as if it were a descriptor generated by
-the wallet itself. This simplifies the `IsMine` logic so that it no longer has to distinguish
-between spendable and watchonly. As such, the watchonly model for Descriptor Wallets is also
-different and described in more detail in the next section.
-
-To import into a Descriptor Wallet, a new `importdescriptors` RPC has been added that uses a syntax
-similar to that of `importmulti`.
-
-As Legacy Wallets and Descriptor Wallets use different mechanisms for storing and importing scripts and keys
-the existing import RPCs have been disabled for descriptor wallets.
-New export RPCs for Descriptor Wallets have not yet been added.
-
-The following RPCs are disabled for Descriptor Wallets:
-
-* importprivkey
-* importpubkey
-* importaddress
-* importwallet
-* dumpprivkey
-* dumpwallet
-* importmulti
-* addmultisigaddress
-* sethdseed
-
-#### Watchonly Wallets
-
-A Legacy Wallet contains both private keys and scripts that were being watched.
-Those watched scripts would not contribute to your normal balance. In order to see the watchonly
-balance and to use watchonly things in transactions, an `include_watchonly` option was added
-to many RPCs that would allow users to do that. However it is easy to forget to include this option.
-
-Descriptor Wallets move to a per-wallet watchonly model. Instead an entire wallet is considered to be
-watchonly depending on whether it was created with private keys disabled. This eliminates the need
-to distinguish between things that are watchonly and things that are not within a wallet itself.
-
-This change does have a caveat. If a Descriptor Wallet with private keys *enabled* has
-a multiple key descriptor without all of the private keys (e.g. `multi(...)` with only one private key),
-then the wallet will fail to sign and broadcast transactions. Such wallets would need to use the PSBT
-workflow but the typical GUI Send, `sendtoaddress`, etc. workflows would still be available, just
-non-functional.
-
-This issue is worsened if the wallet contains both single key (e.g. `wpkh(...)`) descriptors and such
-multiple key descriptors as some transactions could be signed and broadast and others not. This is
-due to some transactions containing only single key inputs, while others would contain both single
-key and multiple key inputs, depending on which are available and how the coin selection algorithm
-selects inputs. However this is not considered to be a supported use case; multisigs
-should be in their own wallets which do not already have descriptors. Although users cannot export
-descriptors with private keys for now as explained earlier.
-
-#### BIP 44/49/84 Support
-
-The change to using descriptors changes the default derivation paths used by Bitcoin Core
-to adhere to BIP 44/49/84. Descriptors with different derivation paths can be imported without
-issue.
diff --git a/doc/release-notes-18918.md b/doc/release-notes-18918.md
index f57a62eeb7..e69de29bb2 100644
--- a/doc/release-notes-18918.md
+++ b/doc/release-notes-18918.md
@@ -1,3 +0,0 @@
-# Wallet
-
-The `-salvagewallet` startup option has been removed. A new `salvage` command has been added to the `bitcoin-wallet` tool which performs the salvage operations that `-salvagewallet` did.
diff --git a/doc/release-notes.md b/doc/release-notes.md
index 0d668a6302..80c385a471 100644
--- a/doc/release-notes.md
+++ b/doc/release-notes.md
@@ -34,40 +34,55 @@ How to Upgrade
==============
If you are running an older version, shut it down. Wait until it has completely
-shut down (which might take a few minutes for older versions), then run the
+shut down (which might take a few minutes in some cases), then run the
installer (on Windows) or just copy over `/Applications/Bitcoin-Qt` (on Mac)
or `bitcoind`/`bitcoin-qt` (on Linux).
Upgrading directly from a version of Bitcoin Core that has reached its EOL is
-possible, but it might take some time if the datadir needs to be migrated. Old
+possible, but it might take some time if the data directory needs to be migrated. Old
wallet versions of Bitcoin Core are generally supported.
Compatibility
==============
-Bitcoin Core is supported and extensively tested on operating systems using
-the Linux kernel, macOS 10.12+, and Windows 7 and newer. It is not recommended
-to use Bitcoin Core on unsupported systems.
-
-Bitcoin Core should also work on most other Unix-like systems but is not
-as frequently tested on them.
+Bitcoin Core is supported and extensively tested on operating systems
+using the Linux kernel, macOS 10.12+, and Windows 7 and newer. Bitcoin
+Core should also work on most other Unix-like systems but is not as
+frequently tested on them. It is not recommended to use Bitcoin Core on
+unsupported systems.
From Bitcoin Core 0.20.0 onwards, macOS versions earlier than 10.12 are no
longer supported. Additionally, Bitcoin Core does not yet change appearance
when macOS "dark mode" is activated.
-In addition to previously supported CPU platforms, this release's pre-compiled
-distribution provides binaries for the RISC-V platform.
-
Notable changes
===============
P2P and network changes
-----------------------
+- The mempool now tracks whether transactions submitted via the wallet or RPCs
+ have been successfully broadcast. Every 10-15 minutes, the node will try to
+ announce unbroadcast transactions until a peer requests it via a `getdata`
+ message or the transaction is removed from the mempool for other reasons.
+ The node will not track the broadcast status of transactions submitted to the
+ node using P2P relay. This version reduces the initial broadcast guarantees
+ for wallet transactions submitted via P2P to a node running the wallet. (#18038)
+
Updated RPCs
------------
+- `getmempoolinfo` now returns an additional `unbroadcastcount` field. The
+ mempool tracks locally submitted transactions until their initial broadcast
+ is acknowledged by a peer. This field returns the count of transactions
+ waiting for acknowledgement.
+
+- Mempool RPCs such as `getmempoolentry` and `getrawmempool` with
+ `verbose=true` now return an additional `unbroadcast` field. This indicates
+ whether initial broadcast of the transaction has been acknowledged by a
+ peer. `getmempoolancestors` and `getmempooldescendants` are also updated.
+
+
Changes to Wallet or GUI related RPCs can be found in the GUI or Wallet section below.
New RPCs
@@ -87,7 +102,139 @@ New settings
Wallet
------
-#### Wallet RPC changes
+- To improve wallet privacy, the frequency of wallet rebroadcast attempts is
+ reduced from approximately once every 15 minutes to once every 12-36 hours.
+ To maintain a similar level of guarantee for initial broadcast of wallet
+ transactions, the mempool tracks these transactions as a part of the newly
+ introduced unbroadcast set. See the "P2P and network changes" section for
+ more information on the unbroadcast set. (#18038)
+
+- The wallet can create a transaction without change even when the keypool is
+ empty. Previously it failed. (#17219)
+
+- The `-salvagewallet` startup option has been removed. A new `salvage` command
+ has been added to the `bitcoin-wallet` tool which performs the salvage
+ operations that `-salvagewallet` did. (#18918)
+
+### Experimental Descriptor Wallets
+
+Please note that Descriptor Wallets are still experimental and not all expected functionality
+is available. Additionally there may be some bugs and current functions may change in the future.
+Bugs and missing functionality can be reported to the [issue tracker](https://github.com/bitcoin/bitcoin/issues).
+
+0.21 introduces a new type of wallet - Descriptor Wallets. Descriptor Wallets store
+scriptPubKey information using descriptors. This is in contrast to the Legacy Wallet
+structure where keys are used to generate scriptPubKeys and addresses. Because of this
+shift to being script based instead of key based, many of the confusing things that Legacy
+Wallets do are not possible with Descriptor Wallets. Descriptor Wallets use a definition
+of "mine" for scripts which is simpler and more intuitive than that used by Legacy Wallets.
+Descriptor Wallets also uses different semantics for watch-only things and imports.
+
+As Descriptor Wallets are a new type of wallet, their introduction does not affect existing wallets.
+Users who already have a Bitcoin Core wallet can continue to use it as they did before without
+any change in behavior. Newly created Legacy Wallets (which is the default type of wallet) will
+behave as they did in previous versions of Bitcoin Core.
+
+The differences between Descriptor Wallets and Legacy Wallets are largely limited to non user facing
+things. They are intended to behave similarly except for the import/export and watchonly functionality
+as described below.
+
+#### Creating Descriptor Wallets
+
+Descriptor Wallets are not created by default. They must be explicitly created using the
+`createwallet` RPC or via the GUI. A `descriptors` option has been added to `createwallet`.
+Setting `descriptors` to `true` will create a Descriptor Wallet instead of a Legacy Wallet.
+
+In the GUI, a checkbox has been added to the Create Wallet Dialog to indicate that a
+Descriptor Wallet should be created.
+
+Without those options being set, a Legacy Wallet will be created instead. Additionally the
+Default Wallet created upon first startup of Bitcoin Core will be a Legacy Wallet.
+
+#### `IsMine` Semantics
+
+`IsMine` refers to the function used to determine whether a script belongs to the wallet.
+This is used to determine whether an output belongs to the wallet. `IsMine` in Legacy Wallets
+returns true if the wallet would be able to sign an input that spends an output with that script.
+Since keys can be involved in a variety of different scripts, this definition for `IsMine` can
+lead to many unexpected scripts being considered part of the wallet.
+
+With Descriptor Wallets, descriptors explicitly specify the set of scripts that are owned by
+the wallet. Since descriptors are deterministic and easily enumerable, users will know exactly
+what scripts the wallet will consider to belong to it. Additionally the implementation of `IsMine`
+in Descriptor Wallets is far simpler than for Legacy Wallets. Notably, in Legacy Wallets, `IsMine`
+allowed for users to take one type of address (e.g. P2PKH), mutate it into another address type
+(e.g. P2WPKH), and the wallet would still detect outputs sending to the new address type
+even without that address being requested from the wallet. Descriptor Wallets does not
+allow for this and will only watch for the addresses that were explicitly requested from the wallet.
+
+These changes to `IsMine` will make it easier to reason about what scripts the wallet will
+actually be watching for in outputs. However for the vast majority of users, this change is
+largely transparent and will not have noticeable effect.
+
+#### Imports and Exports
+
+In Legacy Wallets, raw scripts and keys could be imported to the wallet. Those imported scripts
+and keys are treated separately from the keys generated by the wallet. This complicates the `IsMine`
+logic as it has to distinguish between spendable and watchonly.
+
+Descriptor Wallets handle importing scripts and keys differently. Only complete descriptors can be
+imported. These descriptors are then added to the wallet as if it were a descriptor generated by
+the wallet itself. This simplifies the `IsMine` logic so that it no longer has to distinguish
+between spendable and watchonly. As such, the watchonly model for Descriptor Wallets is also
+different and described in more detail in the next section.
+
+To import into a Descriptor Wallet, a new `importdescriptors` RPC has been added that uses a syntax
+similar to that of `importmulti`.
+
+As Legacy Wallets and Descriptor Wallets use different mechanisms for storing and importing scripts and keys
+the existing import RPCs have been disabled for descriptor wallets.
+New export RPCs for Descriptor Wallets have not yet been added.
+
+The following RPCs are disabled for Descriptor Wallets:
+
+* importprivkey
+* importpubkey
+* importaddress
+* importwallet
+* dumpprivkey
+* dumpwallet
+* importmulti
+* addmultisigaddress
+* sethdseed
+
+#### Watchonly Wallets
+
+A Legacy Wallet contains both private keys and scripts that were being watched.
+Those watched scripts would not contribute to your normal balance. In order to see the watchonly
+balance and to use watchonly things in transactions, an `include_watchonly` option was added
+to many RPCs that would allow users to do that. However it is easy to forget to include this option.
+
+Descriptor Wallets move to a per-wallet watchonly model. Instead an entire wallet is considered to be
+watchonly depending on whether it was created with private keys disabled. This eliminates the need
+to distinguish between things that are watchonly and things that are not within a wallet itself.
+
+This change does have a caveat. If a Descriptor Wallet with private keys *enabled* has
+a multiple key descriptor without all of the private keys (e.g. `multi(...)` with only one private key),
+then the wallet will fail to sign and broadcast transactions. Such wallets would need to use the PSBT
+workflow but the typical GUI Send, `sendtoaddress`, etc. workflows would still be available, just
+non-functional.
+
+This issue is worsened if the wallet contains both single key (e.g. `wpkh(...)`) descriptors and such
+multiple key descriptors as some transactions could be signed and broadast and others not. This is
+due to some transactions containing only single key inputs, while others would contain both single
+key and multiple key inputs, depending on which are available and how the coin selection algorithm
+selects inputs. However this is not considered to be a supported use case; multisigs
+should be in their own wallets which do not already have descriptors. Although users cannot export
+descriptors with private keys for now as explained earlier.
+
+#### BIP 44/49/84 Support
+
+The change to using descriptors changes the default derivation paths used by Bitcoin Core
+to adhere to BIP 44/49/84. Descriptors with different derivation paths can be imported without
+issue.
+
+### Wallet RPC changes
- The `upgradewallet` RPC replaces the `-upgradewallet` command line option.
(#15761)
diff --git a/doc/release-notes/release-notes-0.20.0.md b/doc/release-notes/release-notes-0.20.0.md
new file mode 100644
index 0000000000..6fc1606b37
--- /dev/null
+++ b/doc/release-notes/release-notes-0.20.0.md
@@ -0,0 +1,987 @@
+0.20.0 Release Notes
+====================
+
+Bitcoin Core version 0.20.0 is now available from:
+
+ <https://bitcoincore.org/bin/bitcoin-core-0.20.0/>
+
+This release includes new features, various bug fixes and performance
+improvements, as well as updated translations.
+
+Please report bugs using the issue tracker at GitHub:
+
+ <https://github.com/bitcoin/bitcoin/issues>
+
+To receive security and update notifications, please subscribe to:
+
+ <https://bitcoincore.org/en/list/announcements/join/>
+
+How to Upgrade
+==============
+
+If you are running an older version, shut it down. Wait until it has completely
+shut down (which might take a few minutes in some cases), then run the
+installer (on Windows) or just copy over `/Applications/Bitcoin-Qt` (on Mac)
+or `bitcoind`/`bitcoin-qt` (on Linux).
+
+Upgrading directly from a version of Bitcoin Core that has reached its EOL is
+possible, but it might take some time if the data directory needs to be migrated. Old
+wallet versions of Bitcoin Core are generally supported.
+
+Compatibility
+==============
+
+Bitcoin Core is supported and extensively tested on operating systems
+using the Linux kernel, macOS 10.12+, and Windows 7 and newer. Bitcoin
+Core should also work on most other Unix-like systems but is not as
+frequently tested on them. It is not recommended to use Bitcoin Core on
+unsupported systems.
+
+From Bitcoin Core 0.20.0 onwards, macOS versions earlier than 10.12 are no
+longer supported. Additionally, Bitcoin Core does not yet change appearance
+when macOS "dark mode" is activated.
+
+Known Bugs
+==========
+
+The process for generating the source code release ("tarball") has changed in an
+effort to make it more complete, however, there are a few regressions in
+this release:
+
+- The generated `configure` script is currently missing, and you will need to
+ install autotools and run `./autogen.sh` before you can run
+ `./configure`. This is the same as when checking out from git.
+
+- Instead of running `make` simply, you should instead run
+ `BITCOIN_GENBUILD_NO_GIT=1 make`.
+
+Notable changes
+===============
+
+P2P and network changes
+-----------------------
+
+#### Removal of BIP61 reject network messages from Bitcoin Core
+
+The `-enablebip61` command line option to enable BIP61 has been removed.
+(#17004)
+
+This feature has been disabled by default since Bitcoin Core version 0.18.0.
+Nodes on the network can not generally be trusted to send valid messages
+(including reject messages), so this should only ever be used when
+connected to a trusted node. Please use the alternatives recommended
+below if you rely on this removed feature:
+
+- Testing or debugging of implementations of the Bitcoin P2P network protocol
+ should be done by inspecting the log messages that are produced by a recent
+ version of Bitcoin Core. Bitcoin Core logs debug messages
+ (`-debug=<category>`) to a stream (`-printtoconsole`) or to a file
+ (`-debuglogfile=<debug.log>`).
+
+- Testing the validity of a block can be achieved by specific RPCs:
+
+ - `submitblock`
+
+ - `getblocktemplate` with `'mode'` set to `'proposal'` for blocks with
+ potentially invalid POW
+
+- Testing the validity of a transaction can be achieved by specific RPCs:
+
+ - `sendrawtransaction`
+
+ - `testmempoolaccept`
+
+- Wallets should not assume a transaction has propagated to the network
+ just because there are no reject messages. Instead, listen for the
+ transaction to be announced by other peers on the network. Wallets
+ should not assume a lack of reject messages means a transaction pays
+ an appropriate fee. Instead, set fees using fee estimation and use
+ replace-by-fee to increase a transaction's fee if it hasn't confirmed
+ within the desired amount of time.
+
+The removal of BIP61 reject message support also has the following minor RPC
+and logging implications:
+
+- `testmempoolaccept` and `sendrawtransaction` no longer return the P2P reject
+ code when a transaction is not accepted to the mempool. They still return the
+ verbal reject reason.
+
+- Log messages that previously reported the reject code when a transaction was
+ not accepted to the mempool now no longer report the reject code. The reason
+ for rejection is still reported.
+
+Updated RPCs
+------------
+
+- The RPCs which accept descriptors now accept the new `sortedmulti(...)` descriptor
+ type which supports multisig scripts where the public keys are sorted
+ lexicographically in the resulting script. (#17056)
+
+- The `walletprocesspsbt` and `walletcreatefundedpsbt` RPCs now include
+ BIP32 derivation paths by default for public keys if we know them.
+ This can be disabled by setting the `bip32derivs` parameter to
+ `false`. (#17264)
+
+- The `bumpfee` RPC's parameter `totalFee`, which was deprecated in
+ 0.19, has been removed. (#18312)
+
+- The `bumpfee` RPC will return a PSBT when used with wallets that have
+ private keys disabled. (#16373)
+
+- The `getpeerinfo` RPC now includes a `mapped_as` field to indicate the
+ mapped Autonomous System used for diversifying peer selection. See the
+ `-asmap` configuration option described below in _New Settings_. (#16702)
+
+- The `createmultisig` and `addmultisigaddress` RPCs now return an
+ output script descriptor for the newly created address. (#18032)
+
+Build System
+------------
+
+- OpenSSL is no longer used by Bitcoin Core. (#17265)
+
+- BIP70 support has been fully removed from Bitcoin Core. The
+ `--enable-bip70` option remains, but it will throw an error during configure.
+ (#17165)
+
+- glibc 2.17 or greater is now required to run the release binaries. This
+ retains compatibility with RHEL 7, CentOS 7, Debian 8 and Ubuntu 14.04 LTS. (#17538)
+
+- The source code archives that are provided with gitian builds no longer contain
+ any autotools artifacts. Therefore, to build from such source, a user
+ should run the `./autogen.sh` script from the root of the unpacked archive.
+ This implies that `autotools` and other required packages are installed on the
+ user's system. (#18331)
+
+New settings
+------------
+
+- New `rpcwhitelist` and `rpcwhitelistdefault` configuration parameters
+ allow giving certain RPC users permissions to only some RPC calls.
+ (#12763)
+
+- A new `-asmap` configuration option has been added to diversify the
+ node's network connections by mapping IP addresses Autonomous System
+ Numbers (ASNs) and then limiting the number of connections made to any
+ single ASN. See [issue #16599](https://github.com/bitcoin/bitcoin/issues/16599),
+ [PR #16702](https://github.com/bitcoin/bitcoin/pull/16702), and the
+ `bitcoind help` for more information. This option is experimental and
+ subject to removal or breaking changes in future releases, so the
+ legacy /16 prefix mapping of IP addresses remains the default. (#16702)
+
+Updated settings
+----------------
+
+- All custom settings configured when Bitcoin Core starts are now
+ written to the `debug.log` file to assist troubleshooting. (#16115)
+
+- Importing blocks upon startup via the `bootstrap.dat` file no longer
+ occurs by default. The file must now be specified with
+ `-loadblock=<file>`. (#17044)
+
+- The `-debug=db` logging category has been renamed to
+ `-debug=walletdb` to distinguish it from `coindb`. The `-debug=db`
+ option has been deprecated and will be removed in the next major
+ release. (#17410)
+
+- The `-walletnotify` configuration parameter will now replace any `%w`
+ in its argument with the name of the wallet generating the
+ notification. This is not supported on Windows. (#13339)
+
+Removed settings
+----------------
+
+- The `-whitelistforcerelay` configuration parameter has been removed after
+ it was discovered that it was rendered ineffective in version 0.13 and
+ hasn't actually been supported for almost four years. (#17985)
+
+GUI changes
+-----------
+
+- The "Start Bitcoin Core on system login" option has been removed on macOS.
+ (#17567)
+
+- In the Peers window, the details for a peer now displays a `Mapped AS`
+ field to indicate the mapped Autonomous System used for diversifying
+ peer selection. See the `-asmap` configuration option in _New
+ Settings_, above. (#18402)
+
+- A "known bug" [announced](https://bitcoincore.org/en/releases/0.18.0/#wallet-gui)
+ in the release notes of version 0.18 has been fixed. The issue
+ affected anyone who simultaneously used multiple Bitcoin Core wallets
+ and the GUI coin control feature. (#18894)
+
+- For watch-only wallets, creating a new transaction in the Send screen
+ or fee bumping an existing transaction in the Transactions screen will
+ automatically copy a Partially-Signed Bitcoin Transaction (PSBT) to
+ the system clipboard. This can then be pasted into an external
+ program such as [HWI](https://github.com/bitcoin-core/HWI) for
+ signing. Future versions of Bitcoin Core should support a GUI option
+ for finalizing and broadcasting PSBTs, but for now the debug console
+ may be used with the `finalizepsbt` and `sendrawtransaction` RPCs.
+ (#16944, #17492)
+
+Wallet
+------
+
+- The wallet now by default uses bech32 addresses when using RPC, and
+ creates native segwit change outputs. (#16884)
+
+- The way that output trust was computed has been fixed, which affects
+ confirmed/unconfirmed balance status and coin selection. (#16766)
+
+- The `gettransaction`, `listtransactions` and `listsinceblock` RPC
+ responses now also include the height of the block that contains the
+ wallet transaction, if any. (#17437)
+
+- The `getaddressinfo` RPC has had its `label` field deprecated
+ (re-enable for this release using the configuration parameter
+ `-deprecatedrpc=label`). The `labels` field is altered from returning
+ JSON objects to returning a JSON array of label names (re-enable
+ previous behavior for this release using the configuration parameter
+ `-deprecatedrpc=labelspurpose`). Backwards compatibility using the
+ deprecated configuration parameters is expected to be dropped in the
+ 0.21 release. (#17585, #17578)
+
+Documentation changes
+---------------------
+
+- Bitcoin Core's automatically-generated source code documentation is
+ now available at https://doxygen.bitcoincore.org. (#17596)
+
+Low-level changes
+=================
+
+Utilities
+---------
+
+- The `bitcoin-cli` utility used with the `-getinfo` parameter now
+ returns a `headers` field with the number of downloaded block headers
+ on the best headers chain (similar to the `blocks` field that is also
+ returned) and a `verificationprogress` field that estimates how much
+ of the best block chain has been synced by the local node. The
+ information returned no longer includes the `protocolversion`,
+ `walletversion`, and `keypoololdest` fields. (#17302, #17650)
+
+- The `bitcoin-cli` utility now accepts a `-stdinwalletpassphrase`
+ parameter that can be used when calling the `walletpassphrase` and
+ `walletpassphrasechange` RPCs to read the passphrase from standard
+ input without echoing it to the terminal, improving security against
+ anyone who can look at your screen. The existing `-stdinrpcpass`
+ parameter is also updated to not echo the passphrase. (#13716)
+
+Command line
+------------
+
+- Command line options prefixed with main/test/regtest network names like
+ `-main.port=8333` `-test.server=1` previously were allowed but ignored. Now
+ they trigger "Invalid parameter" errors on startup. (#17482)
+
+New RPCs
+--------
+
+- The `dumptxoutset` RPC outputs a serialized snapshot of the current
+ UTXO set. A script is provided in the `contrib/devtools` directory
+ for generating a snapshot of the UTXO set at a particular block
+ height. (#16899)
+
+- The `generatetodescriptor` RPC allows testers using regtest mode to
+ generate blocks that pay an arbitrary output script descriptor.
+ (#16943)
+
+Updated RPCs
+------------
+
+- The `verifychain` RPC default values are now static instead of
+ depending on the command line options or configuration file
+ (`-checklevel`, and `-checkblocks`). Users can pass in the RPC
+ arguments explicitly when they don't want to rely on the default
+ values. (#18541)
+
+- The `getblockchaininfo` RPC's `verificationprogress` field will no
+ longer report values higher than 1. Previously it would occasionally
+ report the chain was more than 100% verified. (#17328)
+
+Tests
+-----
+
+- It is now an error to use an unqualified `walletdir=path` setting in
+ the config file if running on testnet or regtest networks. The setting
+ now needs to be qualified as `chain.walletdir=path` or placed in the
+ appropriate `[chain]` section. (#17447)
+
+- `-fallbackfee` was 0 (disabled) by default for the main chain, but
+ 0.0002 by default for the test chains. Now it is 0 by default for all
+ chains. Testnet and regtest users will have to add
+ `fallbackfee=0.0002` to their configuration if they weren't setting it
+ and they want it to keep working like before. (#16524)
+
+Build system
+------------
+
+- Support is provided for building with the Android Native Development
+ Kit (NDK). (#16110)
+
+0.20.0 change log
+=================
+
+### Mining
+- #18742 miner: Avoid stack-use-after-return in validationinterface (MarcoFalke)
+
+### Block and transaction handling
+- #15283 log: Fix UB with bench on genesis block (instagibbs)
+- #16507 feefilter: Compute the absolute fee rather than stored rate (instagibbs)
+- #16688 log: Add validation interface logging (jkczyz)
+- #16805 log: Add timing information to FlushStateToDisk() (jamesob)
+- #16902 O(1) `OP_IF/NOTIF/ELSE/ENDIF` script implementation (sipa)
+- #16945 introduce CChainState::GetCoinsCacheSizeState (jamesob)
+- #16974 Walk pindexBestHeader back to ChainActive().Tip() if it is invalid (TheBlueMatt)
+- #17004 Remove REJECT code from CValidationState (jnewbery)
+- #17080 Explain why `fCheckDuplicateInputs` can not be skipped and remove it (MarcoFalke)
+- #17328 GuessVerificationProgress: cap the ratio to 1 (darosior)
+- #17399 Templatize ValidationState instead of subclassing (jkczyz)
+- #17407 node: Add reference to mempool in NodeContext (MarcoFalke)
+- #17708 prevector: Avoid misaligned member accesses (ajtowns)
+- #17850,#17896,#17957,#18021,#18021,#18112 Serialization improvements (sipa)
+- #17925 Improve UpdateTransactionsFromBlock with Epochs (JeremyRubin)
+- #18002 Abstract out script execution out of `VerifyWitnessProgram()` (sipa)
+- #18388 Make VerifyWitnessProgram use a Span stack (sipa)
+- #18433 serialization: prevent int overflow for big Coin::nHeight (pierreN)
+- #18500 chainparams: Bump assumed valid hash (MarcoFalke)
+- #18551 Do not clear validationinterface entries being executed (sipa)
+
+### P2P protocol and network code
+- #15437 Remove BIP61 reject messages (MarcoFalke)
+- #16702 Supply and use asmap to improve IP bucketing in addrman (naumenkogs)
+- #16851 Continue relaying transactions after they expire from mapRelay (ajtowns)
+- #17164 Avoid allocating memory for addrKnown where we don't need it (naumenkogs)
+- #17243 tools: add PoissonNextSend method that returns mockable time (amitiuttarwar)
+- #17251 SocketHandler logs peer id for close and disconnect (Sjors)
+- #17573 Seed RNG with precision timestamps on receipt of net messages (TheBlueMatt)
+- #17624 Fix an uninitialized read in ProcessMessage(…, "tx", …) when receiving a transaction we already have (practicalswift)
+- #17754 Don't allow resolving of std::string with embedded NUL characters. Add tests (practicalswift)
+- #17758 Fix CNetAddr::IsRFC2544 comment + tests (tynes)
+- #17812 config, net, test: Asmap feature refinements and functional tests (jonatack)
+- #17951 Use rolling bloom filter of recent block txs for AlreadyHave() check (sdaftuar)
+- #17985 Remove forcerelay of rejected txs (MarcoFalke)
+- #18023 Fix some asmap issues (sipa)
+- #18054 Reference instead of copy in BlockConnected range loop (jonatack)
+- #18376 Fix use-after-free in tests (vasild)
+- #18454 Make addr relay mockable, add test (MarcoFalke)
+- #18458 Add missing `cs_vNodes` lock (MarcoFalke)
+- #18506 Hardcoded seeds update for 0.20 (laanwj)
+- #18808 Drop unknown types in getdata (jnewbery)
+- #18962 Only send a getheaders for one block in an INV (jnewbery)
+
+### Wallet
+- #13339 Replace %w by wallet name in -walletnotify script (promag)
+- #15931 Remove GetDepthInMainChain dependency on locked chain interface (ariard)
+- #16373 bumpfee: Return PSBT when wallet has privkeys disabled (instagibbs)
+- #16524 Disable -fallbackfee by default (jtimon)
+- #16766 Make IsTrusted scan parents recursively (JeremyRubin)
+- #16884 Change default address type to bech32 (instagibbs)
+- #16911 Only check the hash of transactions loaded from disk (achow101)
+- #16923 Handle duplicate fileid exception (promag)
+- #17056 descriptors: Introduce sortedmulti descriptor (achow101)
+- #17070 Avoid showing GUI popups on RPC errors (MarcoFalke)
+- #17138 Remove wallet access to some node arguments (jnewbery)
+- #17237 LearnRelatedScripts only if KeepDestination (promag)
+- #17260 Split some CWallet functions into new LegacyScriptPubKeyMan (achow101)
+- #17261 Make ScriptPubKeyMan an actual interface and the wallet to have multiple (achow101)
+- #17290 Enable BnB coin selection for preset inputs and subtract fee from outputs (achow101)
+- #17373 Various fixes and cleanup to keypool handling in LegacyScriptPubKeyMan and CWallet (achow101)
+- #17410 Rename `db` log category to `walletdb` (like `coindb`) (laanwj)
+- #17444 Avoid showing GUI popups on RPC errors (take 2) (MarcoFalke)
+- #17447 Make -walletdir network only (promag)
+- #17537 Cleanup and move opportunistic and superfluous TopUp()s (achow101)
+- #17553 Remove out of date comments for CalculateMaximumSignedTxSize (instagibbs)
+- #17568 Fix when sufficient preset inputs and subtractFeeFromOutputs (achow101)
+- #17677 Activate watchonly wallet behavior for LegacySPKM only (instagibbs)
+- #17719 Document better -keypool as a look-ahead safety mechanism (ariard)
+- #17843 Reset reused transactions cache (fjahr)
+- #17889 Improve CWallet:MarkDestinationsDirty (promag)
+- #18034 Get the OutputType for a descriptor (achow101)
+- #18067 Improve LegacyScriptPubKeyMan::CanProvide script recognition (ryanofsky)
+- #18115 Pass in transactions and messages for signing instead of exporting the private keys (achow101)
+- #18192,#18546 Bugfix: Wallet: Safely deal with change in the address book (luke-jr)
+- #18204 descriptors: Improve descriptor cache and cache xpubs (achow101)
+- #18274 rpc/wallet: Initialize nFeeRequired to avoid using garbage value on failure (kallewoof)
+- #18312 Remove deprecated fee bumping by totalFee (jonatack)
+- #18338 Fix wallet unload race condition (promag)
+
+### RPC and other APIs
+- #12763 Add RPC Whitelist Feature from #12248 (JeremyRubin)
+- #13716 cli: `-stdinwalletpassphrase` and non-echo stdin passwords (kallewoof)
+- #16689 Add missing fields to wallet rpc help output (ariard)
+- #16821 Fix bug where duplicate PSBT keys are accepted (erasmospunk)
+- #16899 UTXO snapshot creation (dumptxoutset)
+- #17156 psbt: Check that various indexes and amounts are within bounds (achow101)
+- #17264 Set default bip32derivs to true for psbt methods (Sjors)
+- #17283 improve getaddressinfo test coverage, help, code docs (jonatack)
+- #17302 cli: Add "headers" and "verificationprogress" to -getinfo (laanwj)
+- #17318 replace asserts in RPC code with `CHECK_NONFATAL` and add linter (adamjonas)
+- #17437 Expose block height of wallet transactions (promag)
+- #17519 Remove unused `COINBASE_FLAGS` (narula)
+- #17578 Simplify getaddressinfo labels, deprecate previous behavior (jonatack)
+- #17585 deprecate getaddressinfo label (jonatack)
+- #17746 Remove vector copy from listtransactions (promag)
+- #17809 Auto-format RPCResult (MarcoFalke)
+- #18032 Output a descriptor in createmultisig and addmultisigaddress (achow101)
+- #18122 Update validateaddress RPCExamples to bech32 (theStack)
+- #18208 Change RPCExamples to bech32 (yusufsahinhamza)
+- #18268 Remove redundant types from descriptions (docallag)
+- #18346 Document an RPCResult for all calls; Enforce at compile time (MarcoFalke)
+- #18396 Add missing HelpExampleRpc for getblockfilter (theStack)
+- #18398 Fix broken RPCExamples for waitforblock(height) (theStack)
+- #18444 Remove final comma for last entry of fixed-size arrays/objects in RPCResult (luke-jr)
+- #18459 Remove unused getbalances() code (jonatack)
+- #18484 Correctly compute redeemScript from witnessScript for signrawtransaction (achow101)
+- #18487 Fix rpcRunLater race in walletpassphrase (promag)
+- #18499 Make rpc documentation not depend on call-time rpc args (MarcoFalke)
+- #18532 Avoid initialization-order-fiasco on static CRPCCommand tables (MarcoFalke)
+- #18541 Make verifychain default values static, not depend on global args (MarcoFalke)
+- #18809 Do not advertise dumptxoutset as a way to flush the chainstate (MarcoFalke)
+- #18814 Relock wallet only if most recent callback (promag)
+
+### GUI
+- #15023 Restore RPC Console to non-wallet tray icon menu (luke-jr)
+- #15084 Don't disable the sync overlay when wallet is disabled (benthecarman)
+- #15098 Show addresses for "SendToSelf" transactions (hebasto)
+- #15756 Add shortcuts for tab tools (promag)
+- #16944 create PSBT with watch-only wallet (Sjors)
+- #16964 Change sendcoins dialogue Yes to Send (instagibbs)
+- #17068 Always generate `bitcoinstrings.cpp` on `make translate` (D4nte)
+- #17096 Rename debug window (Zero-1729)
+- #17105 Make RPCConsole::TabTypes an enum class (promag)
+- #17125 Add toolTip and placeholderText to sign message fields (dannmat)
+- #17165 Remove BIP70 support (fanquake)
+- #17180 Improved tooltip for send amount field (JeremyCrookshank)
+- #17186 Add placeholder text to the sign message field (Danny-Scott)
+- #17195 Send amount placeholder value (JeremyCrookshank)
+- #17226 Fix payAmount tooltip in SendCoinsEntry (promag)
+- #17360 Cleaning up hide button tool tip (Danny-Scott)
+- #17446 Changed tooltip for 'Label' & 'Message' text fields to be more clear (dannmat)
+- #17453 Fix intro dialog labels when the prune button is toggled (hebasto)
+- #17474 Bugfix: GUI: Recognise `NETWORK_LIMITED` in formatServicesStr (luke-jr)
+- #17492 Bump fee returns PSBT on clipboard for watchonly-only wallets (instagibbs)
+- #17567 Remove macOS start on login code (fanquake)
+- #17587 Show watch-only balance in send screen (Sjors)
+- #17694 Disable 3rd-party tx-urls when wallet disabled (brakmic)
+- #17696 Force set nPruneSize in QSettings after the intro dialog (hebasto)
+- #17702 Move static placeholder texts to forms (laanwj)
+- #17826 Log Qt related info (hebasto)
+- #17886 Restore English translation option (achow101)
+- #17906 Set CConnman byte counters earlier to avoid uninitialized reads (ryanofsky)
+- #17935 Hide HD & encryption icons when no wallet loaded (brakmic)
+- #17998 Shortcut to close ModalOverlay (emilengler)
+- #18007 Bugfix: GUI: Hide the HD/encrypt icons earlier so they get re-shown if another wallet is open (luke-jr)
+- #18060 Drop PeerTableModel dependency to ClientModel (promag)
+- #18062 Fix unintialized WalletView::progressDialog (promag)
+- #18091 Pass clientmodel changes from walletframe to walletviews (jonasschnelli)
+- #18101 Fix deprecated QCharRef usage (hebasto)
+- #18121 Throttle GUI update pace when -reindex (hebasto)
+- #18123 Fix race in WalletModel::pollBalanceChanged (ryanofsky)
+- #18160 Avoid Wallet::GetBalance in WalletModel::pollBalanceChanged (promag)
+- #18360 Bump transifex slug and update English translations for 0.20 (laanwj)
+- #18402 Display mapped AS in peers info window (jonatack)
+- #18492 Translations update pre-branch (laanwj)
+- #18549 Fix Window -> Minimize menu item (hebasto)
+- #18578 Fix leak in CoinControlDialog::updateView (promag)
+- #18894 Fix manual coin control with multiple wallets loaded (promag)
+
+### Build system
+- #16667 Remove mingw linker workaround from win gitian descriptor (fanquake)
+- #16669 Use new fork of osslsigncode for windows gitian signing (fanquake)
+- #16949 Only pass --disable-dependency-tracking to packages that understand it (fanquake)
+- #17008 Bump libevent to 2.1.11 in depends (stefanwouldgo)
+- #17029 gitian: Various improvements for windows descriptor (dongcarl)
+- #17033 Disable _FORTIFY_SOURCE when enable-debug (achow101)
+- #17057 Switch to upstream libdmg-hfsplus (fanquake)
+- #17066 Remove workaround for ancient libtool (hebasto)
+- #17074 Added double quotes (mztriz)
+- #17087 Add variable printing target to Makefiles (dongcarl)
+- #17118 depends macOS: point --sysroot to SDK (Sjors)
+- #17231 Fix boost mac cross build with clang 9+ (theuni)
+- #17265 Remove OpenSSL (fanquake)
+- #17284 Update retry to current version (RandyMcMillan)
+- #17308 nsis: Write to correct filename in first place (dongcarl)
+- #17324,#18099 Update univalue subtree (MarcoFalke)
+- #17398 Update leveldb to 1.22+ (laanwj)
+- #17409 Avoid hardcoded libfaketime dir in gitian (MarcoFalke)
+- #17466 Fix C{,XX} pickup (dongcarl)
+- #17483 Set gitian arch back to amd64 (MarcoFalke)
+- #17486 Make Travis catch unused variables (Sjors)
+- #17538 Bump minimum libc to 2.17 for release binaries (fanquake)
+- #17542 Create test utility library from src/test/util/ (brakmic)
+- #17545 Remove libanl.so.1 from ALLOWED_LIBRARIES (fanquake)
+- #17547 Fix configure report about qr (hebasto)
+- #17569 Allow export of environ symbols and work around rv64 toolchain issue (laanwj)
+- #17647 lcov: filter depends from coverage reports (nijynot)
+- #17658 Add ability to skip building qrencode (fanquake)
+- #17678 Support for S390X and POWER targets (MarcoFalke)
+- #17682 util: Update tinyformat to upstream (laanwj)
+- #17698 Don't configure `xcb_proto` (fanquake)
+- #17730 Remove Qt networking features (fanquake)
+- #17738 Remove linking librt for backwards compatibility (fanquake)
+- #17740 Remove configure checks for win libraries we don't link against (fanquake)
+- #17741 Included `test_bitcoin-qt` in msvc build (sipsorcery)
+- #17756 Remove `WINDOWS_BITS` from build system (fanquake)
+- #17769 Set `AC_PREREQ` to 2.69 (fanquake)
+- #17880 Add -Wdate-time to Werror flags (fanquake)
+- #17910 Remove double `LIBBITCOIN_SERVER` linking (fanquake)
+- #17928 Consistent use of package variable (Bushstar)
+- #17933 guix: Pin Guix using `guix time-machine` (dongcarl)
+- #17948 pass -fno-ident in Windows gitian descriptor (fanquake)
+- #18003 Remove --large-address-aware linker flag (fanquake)
+- #18004 Don't embed a build-id when building libdmg-hfsplus (fanquake)
+- #18051 Fix behavior when `ALLOW_HOST_PACKAGES` unset (hebasto)
+- #18059 Add missing attributes to Win installer (fanquake)
+- #18104 Skip i686 build by default in guix and gitian (MarcoFalke)
+- #18107 Add `cov_fuzz` target (MarcoFalke)
+- #18135 Add --enable-determinism configure flag (fanquake)
+- #18145 Add Wreturn-type to Werror flags, check on more Travis machines (Sjors)
+- #18264 Remove Boost Chrono (fanquake)
+- #18290 Set minimum Automake version to 1.13 (hebasto)
+- #18320 guix: Remove now-unnecessary gcc make flag (dongcarl)
+- #18331 Use git archive as source tarball (hebasto)
+- #18397 Fix libevent linking for `bench_bitcoin` binary (hebasto)
+- #18426 scripts: `Previous_release`: improve behaviour on failed download (theStack)
+- #18429 Remove double `LIBBITCOIN_SERVER` from bench-Makefile (brakmic)
+- #18528 Create `test_fuzz` library from src/test/fuzz/fuzz.cpp (brakmic)
+- #18558 Fix boost detection for arch armv7l (hebasto)
+- #18598 gitian: Add missing automake package to gitian-win-signer.yml (achow101)
+- #18676 Check libevent minimum version in configure script (hebasto)
+- #18945 Ensure source tarball has leading directory name (laanwj)
+
+### Platform support
+- #16110 Add Android NDK support (icota)
+- #16392 macOS toolchain update (fanquake)
+- #16569 Increase init file stop timeout (setpill)
+- #17151 Remove OpenSSL PRNG seeding (Windows, Qt only) (fanquake)
+- #17365 Update README.md with working Android targets and API levels (icota)
+- #17521 Only use D-Bus with Qt on linux (fanquake)
+- #17550 Set minimum supported macOS to 10.12 (fanquake)
+- #17592 Appveyor install libevent[thread] vcpkg (sipsorcery)
+- #17660 Remove deprecated key from macOS Info.plist (fanquake)
+- #17663 Pass `-dead_strip_dylibs` to ld on macOS (fanquake)
+- #17676 Don't use OpenGL in Qt on macOS (fanquake)
+- #17686 Add `-bind_at_load` to macOS hardened LDFLAGS (fanquake)
+- #17787 scripts: Add macho pie check to security-check.py (fanquake)
+- #17800 random: don't special case clock usage on macOS (fanquake)
+- #17863 scripts: Add macho dylib checks to symbol-check.py (fanquake)
+- #17899 msvc: Ignore msvc linker warning and update to msvc build instructions (sipsorcery)
+- #17916 windows: Enable heap terminate-on-corruption (fanquake)
+- #18082 logging: Enable `thread_local` usage on macos (fanquake)
+- #18108 Fix `.gitignore` policy in `build_msvc` directory (hebasto)
+- #18295 scripts: Add macho lazy bindings check to security-check.py (fanquake)
+- #18358 util: Fix compilation with mingw-w64 7.0.0 (fanquake)
+- #18359 Fix sysctl() detection on macOS (fanquake)
+- #18364 random: remove getentropy() fallback for macOS < 10.12 (fanquake)
+- #18395 scripts: Add pe dylib checking to symbol-check.py (fanquake)
+- #18415 scripts: Add macho tests to test-security-check.py (fanquake)
+- #18425 releases: Update with new Windows code signing certificate (achow101)
+- #18702 Fix ASLR for bitcoin-cli on Windows (fanquake)
+
+### Tests and QA
+- #12134 Build previous releases and run functional tests (Sjors)
+- #13693 Add coverage to estimaterawfee and estimatesmartfee (Empact)
+- #13728 lint: Run the ci lint stage on mac (Empact)
+- #15443 Add getdescriptorinfo functional test (promag)
+- #15888 Add `wallet_implicitsegwit` to test the ability to transform keys between address types (luke-jr)
+- #16540 Add `ASSERT_DEBUG_LOG` to unit test framework (MarcoFalke)
+- #16597 travis: Run full test suite on native macos (Sjors)
+- #16681 Use self.chain instead of 'regtest' in all current tests (jtimon)
+- #16786 add unit test for wallet watch-only methods involving PubKeys (theStack)
+- #16943 Add generatetodescriptor RPC (MarcoFalke)
+- #16973 Fix `combine_logs.py` for AppVeyor build (mzumsande)
+- #16975 Show debug log on unit test failure (MarcoFalke)
+- #16978 Seed test RNG context for each test case, print seed (MarcoFalke)
+- #17009, #17018, #17050, #17051, #17071, #17076, #17083, #17093, #17109, #17113, #17136, #17229, #17291, #17357, #17771, #17777, #17917, #17926, #17972, #17989, #17996, #18009, #18029, #18047, #18126, #18176, #18206, #18353, #18363, #18407, #18417, #18423, #18445, #18455, #18565 Add fuzzing harnesses (practicalswift)
+- #17011 ci: Use busybox utils for one build (MarcoFalke)
+- #17030 Fix Python Docstring to include all Args (jbampton)
+- #17041 ci: Run tests on arm (MarcoFalke)
+- #17069 Pass fuzzing inputs as constant references (practicalswift)
+- #17091 Add test for loadblock option and linearize scripts (fjahr)
+- #17108 fix "tx-size-small" errors after default address change (theStack)
+- #17121 Speed up `wallet_backup` by whitelisting peers (immediate tx relay) (theStack)
+- #17124 Speed up `wallet_address_types` by whitelisting peers (immediate tx relay) (theStack)
+- #17140 Fix bug in `blockfilter_index_tests` (jimpo)
+- #17199 use default address type (bech32) for `wallet_bumpfee` tests (theStack)
+- #17205 ci: Enable address sanitizer (asan) stack-use-after-return checking (practicalswift)
+- #17206 Add testcase to simulate bitcoin schema in leveldb (adamjonas)
+- #17209 Remove no longer needed UBSan suppressions (issues fixed). Add documentation (practicalswift)
+- #17220 Add unit testing for the CompressScript function (adamjonas)
+- #17225 Test serialisation as part of deserialisation fuzzing. Test round-trip equality where possible (practicalswift)
+- #17228 Add RegTestingSetup to `setup_common` (MarcoFalke)
+- #17233 travis: Run unit and functional tests on native arm (MarcoFalke)
+- #17235 Skip unnecessary fuzzer initialisation. Hold ECCVerifyHandle only when needed (practicalswift)
+- #17240 ci: Disable functional tests on mac host (MarcoFalke)
+- #17254 Fix `script_p2sh_tests` `OP_PUSHBACK2/4` missing (adamjonas)
+- #17267 bench: Fix negative values and zero for -evals flag (nijynot)
+- #17275 pubkey: Assert CPubKey's ECCVerifyHandle precondition (practicalswift)
+- #17288 Added TestWrapper class for interactive Python environments (jachiang)
+- #17292 Add new mempool benchmarks for a complex pool (JeremyRubin)
+- #17299 add reason checks for non-standard txs in `test_IsStandard` (theStack)
+- #17322 Fix input size assertion in `wallet_bumpfee.py` (instagibbs)
+- #17327 Add `rpc_fundrawtransaction` logging (jonatack)
+- #17330 Add `shrinkdebugfile=0` to regtest bitcoin.conf (sdaftuar)
+- #17340 Speed up fundrawtransaction test (jnewbery)
+- #17345 Do not instantiate CAddrDB for static call CAddrDB::Read() (hebasto)
+- #17362 Speed up `wallet_avoidreuse`, add logging (jonatack)
+- #17363 add "diamond" unit test to MempoolAncestryTests (theStack)
+- #17366 Reset global args between test suites (MarcoFalke)
+- #17367 ci: Run non-cross-compile builds natively (MarcoFalke)
+- #17378 TestShell: Fix typos & implement cleanups (jachiang)
+- #17384 Create new test library (MarcoFalke)
+- #17387 `wallet_importmulti`: use addresses of the same type as being imported (achow101)
+- #17388 Add missing newline in `util_ChainMerge` test (ryanofsky)
+- #17390 Add `util_ArgParsing` test (ryanofsky)
+- #17420 travis: Rework `cache_err_msg` (MarcoFalke)
+- #17423 ci: Make ci system read-only on the git work tree (MarcoFalke)
+- #17435 check custom ancestor limit in `mempool_packages.py` (theStack)
+- #17455 Update valgrind suppressions (practicalswift)
+- #17461 Check custom descendant limit in `mempool_packages.py` (theStack)
+- #17469 Remove fragile `assert_memory_usage_stable` (MarcoFalke)
+- #17470 ci: Use clang-8 for fuzzing to run on aarch64 ci systems (MarcoFalke)
+- #17480 Add unit test for non-standard txs with too large scriptSig (theStack)
+- #17497 Skip tests when utils haven't been compiled (fanquake)
+- #17502 Add unit test for non-standard bare multisig txs (theStack)
+- #17511 Add bounds checks before base58 decoding (sipa)
+- #17517 ci: Bump to clang-8 for asan build to avoid segfaults on ppc64le (MarcoFalke)
+- #17522 Wait until mempool is loaded in `wallet_abandonconflict` (MarcoFalke)
+- #17532 Add functional test for non-standard txs with too large scriptSig (theStack)
+- #17541 Add functional test for non-standard bare multisig txs (theStack)
+- #17555 Add unit test for non-standard txs with wrong nVersion (dspicher)
+- #17571 Add `libtest_util` library to msvc build configuration (sipsorcery)
+- #17591 ci: Add big endian platform - s390x (elichai)
+- #17593 Move more utility functions into test utility library (mzumsande)
+- #17633 Add option --valgrind to run the functional tests under Valgrind (practicalswift)
+- #17635 ci: Add centos 7 build (hebasto)
+- #17641 Add unit test for leveldb creation with unicode path (sipsorcery)
+- #17674 Add initialization order fiasco detection in Travis (practicalswift)
+- #17675 Enable tests which are incorrectly skipped when running `test_runner.py --usecli` (practicalswift)
+- #17685 Fix bug in the descriptor parsing fuzzing harness (`descriptor_parse`) (practicalswift)
+- #17705 re-enable CLI test support by using EncodeDecimal in json.dumps() (fanquake)
+- #17720 add unit test for non-standard "scriptsig-not-pushonly" txs (theStack)
+- #17767 ci: Fix qemu issues (MarcoFalke)
+- #17793 ci: Update github actions ci vcpkg cache on msbuild update (hebasto)
+- #17806 Change filemode of `rpc_whitelist.py` (emilengler)
+- #17849 ci: Fix brew python link (hebasto)
+- #17851 Add `std::to_string` to list of locale dependent functions (practicalswift)
+- #17893 Fix double-negative arg test (hebasto)
+- #17900 ci: Combine 32-bit build with centos 7 build (theStack)
+- #17921 Test `OP_CSV` empty stack fail in `feature_csv_activation.py` (theStack)
+- #17931 Fix `p2p_invalid_messages` failing in Python 3.8 because of warning (elichai)
+- #17947 add unit test for non-standard txs with too large tx size (theStack)
+- #17959 Check specific reject reasons in `feature_csv_activation.py` (theStack)
+- #17984 Add p2p test for forcerelay permission (MarcoFalke)
+- #18001 Updated appveyor job to checkout a specific vcpkg commit ID (sipsorcery)
+- #18008 fix fuzzing using libFuzzer on macOS (fanquake)
+- #18013 bench: Fix benchmarks filters (elichai)
+- #18018 reset fIsBareMultisigStd after bare-multisig tests (fanquake)
+- #18022 Fix appveyor `test_bitcoin` build of `*.raw` (MarcoFalke)
+- #18037 util: Allow scheduler to be mocked (amitiuttarwar)
+- #18056 ci: Check for submodules (emilengler)
+- #18069 Replace 'regtest' leftovers by self.chain (theStack)
+- #18081 Set a name for CI Docker containers (fanquake)
+- #18109 Avoid hitting some known minor tinyformat issues when fuzzing strprintf(…) (practicalswift)
+- #18155 Add harness which fuzzes EvalScript and VerifyScript using a fuzzed signature checker (practicalswift)
+- #18159 Add --valgrind option to `test/fuzz/test_runner.py` for running fuzzing test cases under valgrind (practicalswift)
+- #18166 ci: Run fuzz testing test cases (bitcoin-core/qa-assets) under valgrind to catch memory errors (practicalswift)
+- #18172 Transaction expiry from mempool (0xB10C)
+- #18181 Remove incorrect assumptions in `validation_flush_tests` (MarcoFalke)
+- #18183 Set `catch_system_errors=no` on boost unit tests (MarcoFalke)
+- #18195 Add `cost_of_change` parameter assertions to `bnb_search_test` (yancyribbens)
+- #18209 Reduce unneeded whitelist permissions in tests (MarcoFalke)
+- #18211 Disable mockforward scheduler unit test for now (MarcoFalke)
+- #18213 Fix race in `p2p_segwit` (MarcoFalke)
+- #18224 Make AnalyzePSBT next role calculation simple, correct (instagibbs)
+- #18228 Add missing syncwithvalidationinterfacequeue (MarcoFalke)
+- #18247 Wait for both veracks in `add_p2p_connection` (MarcoFalke)
+- #18249 Bump timeouts to accomodate really slow disks (MarcoFalke)
+- #18255 Add `bad-txns-*-toolarge` test cases to `invalid_txs` (MarcoFalke)
+- #18263 rpc: change setmocktime check to use IsMockableChain (gzhao408)
+- #18285 Check that `wait_until` returns if time point is in the past (MarcoFalke)
+- #18286 Add locale fuzzer to `FUZZERS_MISSING_CORPORA` (practicalswift)
+- #18292 fuzz: Add `assert(script == decompressed_script)` (MarcoFalke)
+- #18299 Update `FUZZERS_MISSING_CORPORA` to enable regression fuzzing for all harnesses in master (practicalswift)
+- #18300 fuzz: Add option to merge input dir to test runner (MarcoFalke)
+- #18305 Explain why test logging should be used (MarcoFalke)
+- #18306 Add logging to `wallet_listsinceblock.py` (jonatack)
+- #18311 Bumpfee test fix (instagibbs)
+- #18314 Add deserialization fuzzing of SnapshotMetadata (`utxo_snapshot`) (practicalswift)
+- #18319 fuzz: Add missing `ECC_Start` to `key_io` test (MarcoFalke)
+- #18334 Add basic test for BIP 37 (MarcoFalke)
+- #18350 Fix mining to an invalid target + ensure that a new block has the correct hash internally (TheQuantumPhysicist)
+- #18378 Bugfix & simplify bn2vch using `int.to_bytes` (sipa)
+- #18393 Don't assume presence of `__builtin_mul_overflow(…)` in `MultiplicationOverflow(…)` fuzzing harness (practicalswift)
+- #18406 add executable flag for `rpc_estimatefee.py` (theStack)
+- #18420 listsinceblock block height checks (jonatack)
+- #18430 ci: Only clone bitcoin-core/qa-assets when fuzzing (MarcoFalke)
+- #18438 ci: Use homebrew addon on native macos (hebasto)
+- #18447 Add coverage for script parse error in ParseScript (pierreN)
+- #18472 Remove unsafe `BOOST_TEST_MESSAGE` (MarcoFalke)
+- #18474 check that peer is connected when calling sync_* (MarcoFalke)
+- #18477 ci: Use focal for fuzzers (MarcoFalke)
+- #18481 add BIP37 'filterclear' test to p2p_filter.py (theStack)
+- #18496 Remove redundant `sync_with_ping` after `add_p2p_connection` (jonatack)
+- #18509 fuzz: Avoid running over all inputs after merging them (MarcoFalke)
+- #18510 fuzz: Add CScriptNum::getint coverage (MarcoFalke)
+- #18514 remove rapidcheck integration and tests (fanquake)
+- #18515 Add BIP37 remote crash bug [CVE-2013-5700] test to `p2p_filter.py` (theStack)
+- #18516 relax bumpfee `dust_to_fee` txsize an extra vbyte (jonatack)
+- #18518 fuzz: Extend descriptor fuzz test (MarcoFalke)
+- #18519 fuzz: Extend script fuzz test (MarcoFalke)
+- #18521 fuzz: Add `process_messages` harness (MarcoFalke)
+- #18529 Add fuzzer version of randomized prevector test (sipa)
+- #18534 skip backwards compat tests if not compiled with wallet (fanquake)
+- #18540 `wallet_bumpfee` assertion fixup (jonatack)
+- #18543 Use one node to avoid a race due to missing sync in `rpc_signrawtransaction` (MarcoFalke)
+- #18561 Properly raise FailedToStartError when rpc shutdown before warmup finished (MarcoFalke)
+- #18562 ci: Run unit tests sequential once (MarcoFalke)
+- #18563 Fix `unregister_all_during_call` cleanup (ryanofsky)
+- #18566 Set `-use_value_profile=1` when merging fuzz inputs (MarcoFalke)
+- #18757 Remove enumeration of expected deserialization exceptions in ProcessMessage(…) fuzzer (practicalswift)
+- #18878 Add test for conflicted wallet tx notifications (ryanofsky)
+- #18975 Remove const to work around compiler error on xenial (laanwj)
+
+### Documentation
+- #16947 Doxygen-friendly script/descriptor.h comments (ch4ot1c)
+- #16983 Add detailed info about Bitcoin Core files (hebasto)
+- #16986 Doxygen-friendly CuckooCache comments (ch4ot1c)
+- #17022 move-only: Steps for "before major release branch-off" (MarcoFalke)
+- #17026 Update bips.md for default bech32 addresses in 0.20.0 (MarcoFalke)
+- #17081 Fix Makefile target in benchmarking.md (theStack)
+- #17102 Add missing indexes/blockfilter/basic to doc/files.md (MarcoFalke)
+- #17119 Fix broken bitcoin-cli examples (andrewtoth)
+- #17134 Add switch on enum example to developer notes (hebasto)
+- #17142 Update macdeploy README to include all files produced by `make deploy` (za-kk)
+- #17146 github: Add warning for bug reports (laanwj)
+- #17157 Added instructions for how to add an upsteam to forked repo (dannmat)
+- #17159 Add a note about backporting (carnhofdaki)
+- #17169 Correct function name in ReportHardwareRand() (fanquake)
+- #17177 Describe log files + consistent paths in test READMEs (fjahr)
+- #17239 Changed miniupnp links to https (sandakersmann)
+- #17281 Add developer note on `c_str()` (laanwj)
+- #17285 Bip70 removal follow-up (fjahr)
+- #17286 Fix help-debug -checkpoints (ariard)
+- #17309 update MSVC instructions to remove Qt OpenSSL linking (fanquake)
+- #17339 Add template for good first issues (michaelfolkson)
+- #17351 Fix some misspellings (RandyMcMillan)
+- #17353 Add ShellCheck to lint tests dependencies (hebasto)
+- #17370 Update doc/bips.md with recent changes in master (MarcoFalke)
+- #17393 Added regtest config for linearize script (gr0kchain)
+- #17411 Add some better examples for scripted diff (laanwj)
+- #17503 Remove bitness from bitcoin-qt help message and manpage (laanwj)
+- #17539 Update and improve Developer Notes (hebasto)
+- #17561 Changed MiniUPnPc link to https in dependencies.md (sandakersmann)
+- #17596 Change doxygen URL to doxygen.bitcoincore.org (laanwj)
+- #17598 Update release process with latest changes (MarcoFalke)
+- #17617 Unify unix epoch time descriptions (jonatack)
+- #17637 script: Add keyserver to verify-commits readme (emilengler)
+- #17648 Rename wallet-tool references to bitcoin-wallet (hel-o)
+- #17688 Add "ci" prefix to CONTRIBUTING.md (hebasto)
+- #17751 Use recommended shebang approach in documentation code block (hackerrdave)
+- #17752 Fix directory path for secp256k1 subtree in developer-notes (hackerrdave)
+- #17772 Mention PR Club in CONTRIBUTING.md (emilengler)
+- #17804 Misc RPC help fixes (MarcoFalke)
+- #17819 Developer notes guideline on RPCExamples addresses (jonatack)
+- #17825 Update dependencies.md (hebasto)
+- #17873 Add to Doxygen documentation guidelines (jonatack)
+- #17907 Fix improper Doxygen inline comments (Empact)
+- #17942 Improve fuzzing docs for macOS users (fjahr)
+- #17945 Fix doxygen errors (Empact)
+- #18025 Add missing supported rpcs to doc/descriptors.md (andrewtoth)
+- #18070 Add note about `brew doctor` (givanse)
+- #18125 Remove PPA note from release-process.md (fanquake)
+- #18170 Minor grammatical changes and flow improvements (travinkeith)
+- #18212 Add missing step in win deployment instructions (dangershony)
+- #18219 Add warning against wallet.dat re-use (corollari)
+- #18253 Correct spelling errors in comments (Empact)
+- #18278 interfaces: Describe and follow some code conventions (ryanofsky)
+- #18283 Explain rebase policy in CONTRIBUTING.md (MarcoFalke)
+- #18340 Mention MAKE=gmake workaround when building on a BSD (fanquake)
+- #18341 Replace remaining literal BTC with `CURRENCY_UNIT` (domob1812)
+- #18342 Add fuzzing quickstart guides for libFuzzer and afl-fuzz (practicalswift)
+- #18344 Fix nit in getblockchaininfo (stevenroose)
+- #18379 Comment fix merkle.cpp (4d55397500)
+- #18382 note the costs of fetching all pull requests (vasild)
+- #18391 Update init and reduce-traffic docs for -blocksonly (glowang)
+- #18464 Block-relay-only vs blocksonly (MarcoFalke)
+- #18486 Explain new test logging (MarcoFalke)
+- #18505 Update webchat URLs in README.md (SuriyaaKudoIsc)
+- #18513 Fix git add argument (HashUnlimited)
+- #18577 Correct scripted-diff example link (yahiheb)
+- #18589 Fix naming of macOS SDK and clarify version (achow101)
+
+### Miscellaneous
+- #15600 lockedpool: When possible, use madvise to avoid including sensitive information in core dumps (luke-jr)
+- #15934 Merge settings one place instead of five places (ryanofsky)
+- #16115 On bitcoind startup, write config args to debug.log (LarryRuane)
+- #16117 util: Replace boost sleep with std sleep (MarcoFalke)
+- #16161 util: Fix compilation errors in support/lockedpool.cpp (jkczyz)
+- #16802 scripts: In linearize, search for next position of magic bytes rather than fail (takinbo)
+- #16889 Add some general std::vector utility functions (sipa)
+- #17049 contrib: Bump gitian descriptors for 0.20 (MarcoFalke)
+- #17052 scripts: Update `copyright_header` script to include additional files (GChuf)
+- #17059 util: Simplify path argument for cblocktreedb ctor (hebasto)
+- #17191 random: Remove call to `RAND_screen()` (Windows only) (fanquake)
+- #17192 util: Add `check_nonfatal` and use it in src/rpc (MarcoFalke)
+- #17218 Replace the LogPrint function with a macro (jkczyz)
+- #17266 util: Rename decodedumptime to parseiso8601datetime (elichai)
+- #17270 Feed environment data into RNG initializers (sipa)
+- #17282 contrib: Remove accounts from bash completion (fanquake)
+- #17293 Add assertion to randrange that input is not 0 (JeremyRubin)
+- #17325 log: Fix log message for -par=1 (hebasto)
+- #17329 linter: Strip trailing / in path for git-subtree-check (jnewbery)
+- #17336 scripts: Search for first block file for linearize-data with some block files pruned (Rjected)
+- #17361 scripts: Lint gitian descriptors with shellcheck (hebasto)
+- #17482 util: Disallow network-qualified command line options (ryanofsky)
+- #17507 random: mark RandAddPeriodic and SeedPeriodic as noexcept (fanquake)
+- #17527 Fix CPUID subleaf iteration (sipa)
+- #17604 util: Make schedulebatchpriority advisory only (fanquake)
+- #17650 util: Remove unwanted fields from bitcoin-cli -getinfo (malevolent)
+- #17671 script: Fixed wget call in gitian-build.py (willyko)
+- #17699 Make env data logging optional (sipa)
+- #17721 util: Don't allow base58 decoding of non-base58 strings. add base58 tests (practicalswift)
+- #17750 util: Change getwarnings parameter to bool (jnewbery)
+- #17753 util: Don't allow base32/64-decoding or parsemoney(…) on strings with embedded nul characters. add tests (practicalswift)
+- #17823 scripts: Read suspicious hosts from a file instead of hardcoding (sanjaykdragon)
+- #18162 util: Avoid potential uninitialized read in `formatiso8601datetime(int64_t)` by checking `gmtime_s`/`gmtime_r` return value (practicalswift)
+- #18167 Fix a violation of C++ standard rules where unions are used for type-punning (TheQuantumPhysicist)
+- #18225 util: Fail to parse empty string in parsemoney (MarcoFalke)
+- #18270 util: Fail to parse whitespace-only strings in parsemoney(…) (instead of parsing as zero) (practicalswift)
+- #18316 util: Helpexamplerpc formatting (jonatack)
+- #18357 Fix missing header in sync.h (promag)
+- #18412 script: Fix `script_err_sig_pushonly` error string (theStack)
+- #18416 util: Limit decimal range of numbers parsescript accepts (pierreN)
+- #18503 init: Replace `URL_WEBSITE` with `PACKAGE_URL` (MarcoFalke)
+- #18526 Remove PID file at the very end (hebasto)
+- #18553 Avoid non-trivial global constants in SHA-NI code (sipa)
+- #18665 Do not expose and consider `-logthreadnames` when it does not work (hebasto)
+
+Credits
+=======
+
+Thanks to everyone who directly contributed to this release:
+
+- 0xb10c
+- 251
+- 4d55397500
+- Aaron Clauson
+- Adam Jonas
+- Albert
+- Amiti Uttarwar
+- Andrew Chow
+- Andrew Toth
+- Anthony Towns
+- Antoine Riard
+- Ava Barron
+- Ben Carman
+- Ben Woosley
+- Block Mechanic
+- Brian Solon
+- Bushstar
+- Carl Dong
+- Carnhof Daki
+- Cory Fields
+- Daki Carnhof
+- Dan Gershony
+- Daniel Kraft
+- dannmat
+- Danny-Scott
+- darosior
+- David O'Callaghan
+- Dominik Spicher
+- Elichai Turkel
+- Emil Engler
+- emu
+- Fabian Jahr
+- fanquake
+- Filip Gospodinov
+- Franck Royer
+- Gastón I. Silva
+- gchuf
+- Gleb Naumenko
+- Gloria Zhao
+- glowang
+- Gr0kchain
+- Gregory Sanders
+- hackerrdave
+- Harris
+- hel0
+- Hennadii Stepanov
+- ianliu
+- Igor Cota
+- James Chiang
+- James O'Beirne
+- Jan Beich
+- Jan Sarenik
+- Jeffrey Czyz
+- Jeremy Rubin
+- JeremyCrookshank
+- Jim Posen
+- John Bampton
+- John L. Jegutanis
+- John Newbery
+- Jon Atack
+- Jon Layton
+- Jonas Schnelli
+- João Barbosa
+- Jorge Timón
+- Karl-Johan Alm
+- kodslav
+- Larry Ruane
+- Luke Dashjr
+- malevolent
+- MapleLaker
+- marcaiaf
+- MarcoFalke
+- Marius Kjærstad
+- Mark Erhardt
+- Mark Tyneway
+- Martin Erlandsson
+- Martin Zumsande
+- Matt Corallo
+- Matt Ward
+- Michael Folkson
+- Michael Polzer
+- Micky Yun Chan
+- Neha Narula
+- nijynot
+- naumenkogs
+- NullFunctor
+- Peter Bushnell
+- pierrenn
+- Pieter Wuille
+- practicalswift
+- randymcmillan
+- Rjected
+- Russell Yanofsky
+- Samer Afach
+- Samuel Dobson
+- Sanjay K
+- Sebastian Falbesoner
+- setpill
+- Sjors Provoost
+- Stefan Richter
+- stefanwouldgo
+- Steven Roose
+- Suhas Daftuar
+- Suriyaa Sundararuban
+- TheCharlatan
+- Tim Akinbo
+- Travin Keith
+- tryphe
+- Vasil Dimov
+- Willy Ko
+- Wilson Ccasihue S
+- Wladimir J. van der Laan
+- Yahia Chiheb
+- Yancy Ribbens
+- Yusuf Sahin HAMZA
+- Zakk
+- Zero
+
+As well as to everyone that helped with translations on
+[Transifex](https://www.transifex.com/bitcoin/bitcoin/).
diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include
index 766c0fca54..93b5156af3 100644
--- a/src/Makefile.bench.include
+++ b/src/Makefile.bench.include
@@ -29,6 +29,7 @@ bench_bench_bitcoin_SOURCES = \
bench/crypto_hash.cpp \
bench/ccoins_caching.cpp \
bench/gcs_filter.cpp \
+ bench/hashpadding.cpp \
bench/merkle_root.cpp \
bench/mempool_eviction.cpp \
bench/mempool_stress.cpp \
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index 2480cdadbb..7909cb4a0f 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -110,9 +110,14 @@ FUZZ_TARGETS = \
test/fuzz/rbf \
test/fuzz/rolling_bloom_filter \
test/fuzz/script \
+ test/fuzz/script_bitcoin_consensus \
+ test/fuzz/script_descriptor_cache \
test/fuzz/script_deserialize \
test/fuzz/script_flags \
+ test/fuzz/script_interpreter \
test/fuzz/script_ops \
+ test/fuzz/script_sigcache \
+ test/fuzz/script_sign \
test/fuzz/scriptnum_ops \
test/fuzz/service_deserialize \
test/fuzz/signature_checker \
@@ -941,6 +946,18 @@ test_fuzz_script_LDADD = $(FUZZ_SUITE_LD_COMMON)
test_fuzz_script_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
test_fuzz_script_SOURCES = test/fuzz/script.cpp
+test_fuzz_script_bitcoin_consensus_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+test_fuzz_script_bitcoin_consensus_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+test_fuzz_script_bitcoin_consensus_LDADD = $(FUZZ_SUITE_LD_COMMON)
+test_fuzz_script_bitcoin_consensus_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+test_fuzz_script_bitcoin_consensus_SOURCES = test/fuzz/script_bitcoin_consensus.cpp
+
+test_fuzz_script_descriptor_cache_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+test_fuzz_script_descriptor_cache_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+test_fuzz_script_descriptor_cache_LDADD = $(FUZZ_SUITE_LD_COMMON)
+test_fuzz_script_descriptor_cache_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+test_fuzz_script_descriptor_cache_SOURCES = test/fuzz/script_descriptor_cache.cpp
+
test_fuzz_script_deserialize_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -DSCRIPT_DESERIALIZE=1
test_fuzz_script_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_script_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
@@ -953,12 +970,30 @@ test_fuzz_script_flags_LDADD = $(FUZZ_SUITE_LD_COMMON)
test_fuzz_script_flags_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
test_fuzz_script_flags_SOURCES = test/fuzz/script_flags.cpp
+test_fuzz_script_interpreter_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+test_fuzz_script_interpreter_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+test_fuzz_script_interpreter_LDADD = $(FUZZ_SUITE_LD_COMMON)
+test_fuzz_script_interpreter_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+test_fuzz_script_interpreter_SOURCES = test/fuzz/script_interpreter.cpp
+
test_fuzz_script_ops_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
test_fuzz_script_ops_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_script_ops_LDADD = $(FUZZ_SUITE_LD_COMMON)
test_fuzz_script_ops_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
test_fuzz_script_ops_SOURCES = test/fuzz/script_ops.cpp
+test_fuzz_script_sigcache_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+test_fuzz_script_sigcache_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+test_fuzz_script_sigcache_LDADD = $(FUZZ_SUITE_LD_COMMON)
+test_fuzz_script_sigcache_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+test_fuzz_script_sigcache_SOURCES = test/fuzz/script_sigcache.cpp
+
+test_fuzz_script_sign_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
+test_fuzz_script_sign_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
+test_fuzz_script_sign_LDADD = $(FUZZ_SUITE_LD_COMMON)
+test_fuzz_script_sign_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
+test_fuzz_script_sign_SOURCES = test/fuzz/script_sign.cpp
+
test_fuzz_scriptnum_ops_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
test_fuzz_scriptnum_ops_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_scriptnum_ops_LDADD = $(FUZZ_SUITE_LD_COMMON)
diff --git a/src/bench/hashpadding.cpp b/src/bench/hashpadding.cpp
new file mode 100644
index 0000000000..985be8bdba
--- /dev/null
+++ b/src/bench/hashpadding.cpp
@@ -0,0 +1,47 @@
+// Copyright (c) 2015-2018 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 <bench/bench.h>
+#include <hash.h>
+#include <random.h>
+#include <uint256.h>
+
+
+static void PrePadded(benchmark::State& state)
+{
+
+ CSHA256 hasher;
+
+ // Setup the salted hasher
+ uint256 nonce = GetRandHash();
+ hasher.Write(nonce.begin(), 32);
+ hasher.Write(nonce.begin(), 32);
+ uint256 data = GetRandHash();
+ while (state.KeepRunning()) {
+ unsigned char out[32];
+ CSHA256 h = hasher;
+ h.Write(data.begin(), 32);
+ h.Finalize(out);
+ }
+}
+
+BENCHMARK(PrePadded, 10000);
+
+static void RegularPadded(benchmark::State& state)
+{
+ CSHA256 hasher;
+
+ // Setup the salted hasher
+ uint256 nonce = GetRandHash();
+ uint256 data = GetRandHash();
+ while (state.KeepRunning()) {
+ unsigned char out[32];
+ CSHA256 h = hasher;
+ h.Write(nonce.begin(), 32);
+ h.Write(data.begin(), 32);
+ h.Finalize(out);
+ }
+}
+
+BENCHMARK(RegularPadded, 10000);
diff --git a/src/blockfilter.h b/src/blockfilter.h
index ff8744b217..96cefbf3b2 100644
--- a/src/blockfilter.h
+++ b/src/blockfilter.h
@@ -144,8 +144,8 @@ public:
template <typename Stream>
void Serialize(Stream& s) const {
- s << m_block_hash
- << static_cast<uint8_t>(m_filter_type)
+ s << static_cast<uint8_t>(m_filter_type)
+ << m_block_hash
<< m_filter.GetEncoded();
}
@@ -154,8 +154,8 @@ public:
std::vector<unsigned char> encoded_filter;
uint8_t filter_type;
- s >> m_block_hash
- >> filter_type
+ s >> filter_type
+ >> m_block_hash
>> encoded_filter;
m_filter_type = static_cast<BlockFilterType>(filter_type);
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
index d8e459a8e8..d1e04b114d 100644
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -63,9 +63,9 @@ public:
{
m_notifications->transactionAddedToMempool(tx);
}
- void TransactionRemovedFromMempool(const CTransactionRef& tx) override
+ void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) override
{
- m_notifications->transactionRemovedFromMempool(tx);
+ m_notifications->transactionRemovedFromMempool(tx, reason);
}
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
{
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index 7dfc77db7b..61d7ddb934 100644
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -20,6 +20,7 @@ class CRPCCommand;
class CScheduler;
class Coin;
class uint256;
+enum class MemPoolRemovalReason;
enum class RBFTransactionState;
struct bilingual_str;
struct CBlockLocator;
@@ -239,7 +240,7 @@ public:
public:
virtual ~Notifications() {}
virtual void transactionAddedToMempool(const CTransactionRef& tx) {}
- virtual void transactionRemovedFromMempool(const CTransactionRef& ptx) {}
+ virtual void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {}
virtual void blockConnected(const CBlock& block, int height) {}
virtual void blockDisconnected(const CBlock& block, int height) {}
virtual void updatedBlockTip() {}
diff --git a/src/net.cpp b/src/net.cpp
index 707412bb32..2ccb89248f 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -53,10 +53,17 @@ static constexpr std::chrono::minutes DUMP_PEERS_INTERVAL{15};
static constexpr int DNSSEEDS_TO_QUERY_AT_ONCE = 3;
/** How long to delay before querying DNS seeds
+ *
+ * If we have more than THRESHOLD entries in addrman, then it's likely
+ * that we got those addresses from having previously connected to the P2P
+ * network, and that we'll be able to successfully reconnect to the P2P
+ * network via contacting one of them. So if that's the case, spend a
+ * little longer trying to connect to known peers before querying the
+ * DNS seeds.
*/
-static constexpr std::chrono::seconds DNSSEEDS_DELAY_FEW_PEERS{11}; // 11sec
-static constexpr std::chrono::seconds DNSSEEDS_DELAY_MANY_PEERS{300}; // 5min
-static constexpr int DNSSEEDS_DELAY_PEER_THRESHOLD = 1000; // "many" vs "few" peers -- you should only get this many if you've been on the live network
+static constexpr std::chrono::seconds DNSSEEDS_DELAY_FEW_PEERS{11};
+static constexpr std::chrono::minutes DNSSEEDS_DELAY_MANY_PEERS{5};
+static constexpr int DNSSEEDS_DELAY_PEER_THRESHOLD = 1000; // "many" vs "few" peers
// We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization.
#define FEELER_SLEEP_WINDOW 1
@@ -1595,6 +1602,8 @@ void CConnman::ThreadDNSAddressSeed()
seeds_right_now = seeds.size();
} else if (addrman.size() == 0) {
// If we have no known peers, query all.
+ // This will occur on the first run, or if peers.dat has been
+ // deleted.
seeds_right_now = seeds.size();
}
@@ -1620,6 +1629,9 @@ void CConnman::ThreadDNSAddressSeed()
LogPrintf("Waiting %d seconds before querying DNS seeds.\n", seeds_wait_time.count());
std::chrono::seconds to_wait = seeds_wait_time;
while (to_wait.count() > 0) {
+ // if sleeping for the MANY_PEERS interval, wake up
+ // early to see if we have enough peers and can stop
+ // this thread entirely freeing up its resources
std::chrono::seconds w = std::min(DNSSEEDS_DELAY_FEW_PEERS, to_wait);
if (!interruptNet.sleep_for(w)) return;
to_wait -= w;
@@ -1646,7 +1658,7 @@ void CConnman::ThreadDNSAddressSeed()
if (interruptNet) return;
- // hold off on querying seeds if p2p network deactivated
+ // hold off on querying seeds if P2P network deactivated
if (!fNetworkActive) {
LogPrintf("Waiting for network to be reactivated before querying DNS seeds.\n");
do {
@@ -1797,6 +1809,9 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
return;
// Add seed nodes if DNS seeds are all down (an infrastructure attack?).
+ // Note that we only do this if we started with an empty peers.dat,
+ // (in which case we will query DNS seeds immediately) *and* the DNS
+ // seeds have not returned any results.
if (addrman.size() == 0 && (GetTime() - nStart > 60)) {
static bool done = false;
if (!done) {
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 159036a237..404b33a977 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -129,6 +129,8 @@ static constexpr unsigned int INVENTORY_BROADCAST_MAX = 7 * INVENTORY_BROADCAST_
static constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60;
/** Maximum feefilter broadcast delay after significant change. */
static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60;
+/** Maximum number of compact filters that may be requested with one getcfilters. See BIP 157. */
+static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000;
/** Maximum number of cf hashes that may be requested with one getcfheaders. See BIP 157. */
static constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000;
@@ -827,7 +829,8 @@ void PeerLogicValidation::ReattemptInitialBroadcast(CScheduler& scheduler) const
}
}
- // schedule next run for 10-15 minutes in the future
+ // Schedule next run for 10-15 minutes in the future.
+ // We add randomness on every cycle to avoid the possibility of P2P fingerprinting.
const std::chrono::milliseconds delta = std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5});
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, delta);
}
@@ -1998,7 +2001,7 @@ void static ProcessOrphanTx(CConnman* connman, CTxMemPool& mempool, std::set<uin
* @param[out] filter_index The filter index, if the request can be serviced.
* @return True if the request can be serviced.
*/
-static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_params,
+static bool PrepareBlockFilterRequest(CNode& pfrom, const CChainParams& chain_params,
BlockFilterType filter_type, uint32_t start_height,
const uint256& stop_hash, uint32_t max_height_diff,
const CBlockIndex*& stop_index,
@@ -2009,8 +2012,8 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS));
if (!supported_filter_type) {
LogPrint(BCLog::NET, "peer %d requested unsupported block filter type: %d\n",
- pfrom->GetId(), static_cast<uint8_t>(filter_type));
- pfrom->fDisconnect = true;
+ pfrom.GetId(), static_cast<uint8_t>(filter_type));
+ pfrom.fDisconnect = true;
return false;
}
@@ -2021,8 +2024,8 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
// Check that the stop block exists and the peer would be allowed to fetch it.
if (!stop_index || !BlockRequestAllowed(stop_index, chain_params.GetConsensus())) {
LogPrint(BCLog::NET, "peer %d requested invalid block hash: %s\n",
- pfrom->GetId(), stop_hash.ToString());
- pfrom->fDisconnect = true;
+ pfrom.GetId(), stop_hash.ToString());
+ pfrom.fDisconnect = true;
return false;
}
}
@@ -2031,14 +2034,14 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
if (start_height > stop_height) {
LogPrint(BCLog::NET, "peer %d sent invalid getcfilters/getcfheaders with " /* Continued */
"start height %d and stop height %d\n",
- pfrom->GetId(), start_height, stop_height);
- pfrom->fDisconnect = true;
+ pfrom.GetId(), start_height, stop_height);
+ pfrom.fDisconnect = true;
return false;
}
if (stop_height - start_height >= max_height_diff) {
LogPrint(BCLog::NET, "peer %d requested too many cfilters/cfheaders: %d / %d\n",
- pfrom->GetId(), stop_height - start_height + 1, max_height_diff);
- pfrom->fDisconnect = true;
+ pfrom.GetId(), stop_height - start_height + 1, max_height_diff);
+ pfrom.fDisconnect = true;
return false;
}
@@ -2052,6 +2055,49 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
}
/**
+ * Handle a cfilters request.
+ *
+ * May disconnect from the peer in the case of a bad request.
+ *
+ * @param[in] pfrom The peer that we received the request from
+ * @param[in] vRecv The raw message received
+ * @param[in] chain_params Chain parameters
+ * @param[in] connman Pointer to the connection manager
+ */
+static void ProcessGetCFilters(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
+ CConnman& connman)
+{
+ uint8_t filter_type_ser;
+ uint32_t start_height;
+ uint256 stop_hash;
+
+ vRecv >> filter_type_ser >> start_height >> stop_hash;
+
+ const BlockFilterType filter_type = static_cast<BlockFilterType>(filter_type_ser);
+
+ const CBlockIndex* stop_index;
+ BlockFilterIndex* filter_index;
+ if (!PrepareBlockFilterRequest(pfrom, chain_params, filter_type, start_height, stop_hash,
+ MAX_GETCFILTERS_SIZE, stop_index, filter_index)) {
+ return;
+ }
+
+ std::vector<BlockFilter> filters;
+
+ if (!filter_index->LookupFilterRange(start_height, stop_index, filters)) {
+ LogPrint(BCLog::NET, "Failed to find block filter in index: filter_type=%s, start_height=%d, stop_hash=%s\n",
+ BlockFilterTypeName(filter_type), start_height, stop_hash.ToString());
+ return;
+ }
+
+ for (const auto& filter : filters) {
+ CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
+ .Make(NetMsgType::CFILTER, filter);
+ connman.PushMessage(&pfrom, std::move(msg));
+ }
+}
+
+/**
* Handle a cfheaders request.
*
* May disconnect from the peer in the case of a bad request.
@@ -2061,8 +2107,8 @@ static bool PrepareBlockFilterRequest(CNode* pfrom, const CChainParams& chain_pa
* @param[in] chain_params Chain parameters
* @param[in] connman Pointer to the connection manager
*/
-static void ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainParams& chain_params,
- CConnman* connman)
+static void ProcessGetCFHeaders(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
+ CConnman& connman)
{
uint8_t filter_type_ser;
uint32_t start_height;
@@ -2097,13 +2143,13 @@ static void ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainPa
return;
}
- CSerializedNetMsg msg = CNetMsgMaker(pfrom->GetSendVersion())
+ CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
.Make(NetMsgType::CFHEADERS,
filter_type_ser,
stop_index->GetBlockHash(),
prev_header,
filter_hashes);
- connman->PushMessage(pfrom, std::move(msg));
+ connman.PushMessage(&pfrom, std::move(msg));
}
/**
@@ -2116,8 +2162,8 @@ static void ProcessGetCFHeaders(CNode* pfrom, CDataStream& vRecv, const CChainPa
* @param[in] chain_params Chain parameters
* @param[in] connman Pointer to the connection manager
*/
-static void ProcessGetCFCheckPt(CNode* pfrom, CDataStream& vRecv, const CChainParams& chain_params,
- CConnman* connman)
+static void ProcessGetCFCheckPt(CNode& pfrom, CDataStream& vRecv, const CChainParams& chain_params,
+ CConnman& connman)
{
uint8_t filter_type_ser;
uint256 stop_hash;
@@ -2149,12 +2195,12 @@ static void ProcessGetCFCheckPt(CNode* pfrom, CDataStream& vRecv, const CChainPa
}
}
- CSerializedNetMsg msg = CNetMsgMaker(pfrom->GetSendVersion())
+ CSerializedNetMsg msg = CNetMsgMaker(pfrom.GetSendVersion())
.Make(NetMsgType::CFCHECKPT,
filter_type_ser,
stop_index->GetBlockHash(),
headers);
- connman->PushMessage(pfrom, std::move(msg));
+ connman.PushMessage(&pfrom, std::move(msg));
}
bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, ChainstateManager& chainman, CTxMemPool& mempool, CConnman* connman, BanMan* banman, const std::atomic<bool>& interruptMsgProc)
@@ -3466,13 +3512,18 @@ bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRec
return true;
}
+ if (msg_type == NetMsgType::GETCFILTERS) {
+ ProcessGetCFilters(*pfrom, vRecv, chainparams, *connman);
+ return true;
+ }
+
if (msg_type == NetMsgType::GETCFHEADERS) {
- ProcessGetCFHeaders(pfrom, vRecv, chainparams, connman);
+ ProcessGetCFHeaders(*pfrom, vRecv, chainparams, *connman);
return true;
}
if (msg_type == NetMsgType::GETCFCHECKPT) {
- ProcessGetCFCheckPt(pfrom, vRecv, chainparams, connman);
+ ProcessGetCFCheckPt(*pfrom, vRecv, chainparams, *connman);
return true;
}
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 93e76f1f13..83a24b9d95 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -40,6 +40,8 @@ const char *SENDCMPCT="sendcmpct";
const char *CMPCTBLOCK="cmpctblock";
const char *GETBLOCKTXN="getblocktxn";
const char *BLOCKTXN="blocktxn";
+const char *GETCFILTERS="getcfilters";
+const char *CFILTER="cfilter";
const char *GETCFHEADERS="getcfheaders";
const char *CFHEADERS="cfheaders";
const char *GETCFCHECKPT="getcfcheckpt";
@@ -75,6 +77,8 @@ const static std::string allNetMessageTypes[] = {
NetMsgType::CMPCTBLOCK,
NetMsgType::GETBLOCKTXN,
NetMsgType::BLOCKTXN,
+ NetMsgType::GETCFILTERS,
+ NetMsgType::CFILTER,
NetMsgType::GETCFHEADERS,
NetMsgType::CFHEADERS,
NetMsgType::GETCFCHECKPT,
diff --git a/src/protocol.h b/src/protocol.h
index b720a6ce91..985f44640b 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -226,6 +226,17 @@ extern const char* GETBLOCKTXN;
*/
extern const char* BLOCKTXN;
/**
+ * getcfilters requests compact filters for a range of blocks.
+ * Only available with service bit NODE_COMPACT_FILTERS as described by
+ * BIP 157 & 158.
+ */
+extern const char* GETCFILTERS;
+/**
+ * cfilter is a response to a getcfilters request containing a single compact
+ * filter.
+ */
+extern const char* CFILTER;
+/**
* getcfheaders requests a compact filter header and the filter hashes for a
* range of blocks, which can then be used to reconstruct the filter headers
* for those blocks.
diff --git a/src/psbt.h b/src/psbt.h
index af57994f3a..888e0fd119 100644
--- a/src/psbt.h
+++ b/src/psbt.h
@@ -41,7 +41,7 @@ static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02;
static constexpr uint8_t PSBT_SEPARATOR = 0x00;
// BIP 174 does not specify a maximum file size, but we set a limit anyway
-// to prevent reading a stream indefinately and running out of memory.
+// to prevent reading a stream indefinitely and running out of memory.
const std::streamsize MAX_FILE_SIZE_PSBT = 100000000; // 100 MiB
/** A structure for PSBTs which contain per-input information */
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index ad74ca3a02..f8cdb5df23 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -65,6 +65,23 @@ Q_DECLARE_METATYPE(CAmount)
Q_DECLARE_METATYPE(SynchronizationState)
Q_DECLARE_METATYPE(uint256)
+static void RegisterMetaTypes()
+{
+ // Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection
+ qRegisterMetaType<bool*>();
+ qRegisterMetaType<SynchronizationState>();
+ #ifdef ENABLE_WALLET
+ qRegisterMetaType<WalletModel*>();
+ #endif
+ // Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
+ // IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1)
+ qRegisterMetaType<CAmount>("CAmount");
+ qRegisterMetaType<size_t>("size_t");
+
+ qRegisterMetaType<std::function<void()>>("std::function<void()>");
+ qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
+}
+
static QString GetLangTerritory()
{
QSettings settings;
@@ -184,6 +201,7 @@ BitcoinApplication::BitcoinApplication(interfaces::Node& node):
returnValue(0),
platformStyle(nullptr)
{
+ RegisterMetaTypes();
setQuitOnLastWindowClosed(false);
}
@@ -433,20 +451,6 @@ int GuiMain(int argc, char* argv[])
BitcoinApplication app(*node);
- // Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection
- qRegisterMetaType<bool*>();
- qRegisterMetaType<SynchronizationState>();
-#ifdef ENABLE_WALLET
- qRegisterMetaType<WalletModel*>();
-#endif
- // Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
- // IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1)
- qRegisterMetaType<CAmount>("CAmount");
- qRegisterMetaType<size_t>("size_t");
-
- qRegisterMetaType<std::function<void()>>("std::function<void()>");
- qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon");
-
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
// Command-line options take precedence:
node->setupServerArgs();
diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp
index 66fbf978be..861d1c5f4a 100644
--- a/src/qt/walletview.cpp
+++ b/src/qt/walletview.cpp
@@ -258,7 +258,7 @@ void WalletView::gotoLoadPSBT()
TransactionError result = BroadcastTransaction(*clientModel->node().context(), tx, err_string, DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK(), /* relay */ true, /* wait_callback */ false);
if (result == TransactionError::OK) {
- Q_EMIT message(tr("Success"), tr("Broadcasted transaction sucessfully."), CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL);
+ Q_EMIT message(tr("Success"), tr("Broadcasted transaction successfully."), CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL);
} else {
Q_EMIT message(tr("Error"), QString::fromStdString(err_string), CClientUIInterface::MSG_ERROR);
}
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 4eb47d7b15..b0936cef5a 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -414,7 +414,7 @@ static std::vector<RPCResult> MempoolEntryDescription() { return {
RPCResult{RPCResult::Type::ARR, "spentby", "unconfirmed transactions spending outputs from this transaction",
{RPCResult{RPCResult::Type::STR_HEX, "transactionid", "child transaction id"}}},
RPCResult{RPCResult::Type::BOOL, "bip125-replaceable", "Whether this transaction could be replaced due to BIP125 (replace-by-fee)"},
- RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet confirmed)"},
+ RPCResult{RPCResult::Type::BOOL, "unbroadcast", "Whether this transaction is currently unbroadcast (initial broadcast not yet acknowledged by any peers)"},
};}
static void entryToJSON(const CTxMemPool& pool, UniValue& info, const CTxMemPoolEntry& e) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 3612f14bbf..3db0cb04ed 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -179,7 +179,7 @@ static bool getScriptFromDescriptor(const std::string& descriptor, CScript& scri
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys"));
}
- // Combo desriptors can have 2 or 4 scripts, so we can't just check scripts.size() == 1
+ // Combo descriptors can have 2 or 4 scripts, so we can't just check scripts.size() == 1
CHECK_NONFATAL(scripts.size() > 0 && scripts.size() <= 4);
if (scripts.size() == 1) {
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
index 2a0079ac39..844f62cbc6 100644
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -22,8 +22,6 @@
static RecursiveMutex cs_rpcWarmup;
static std::atomic<bool> g_rpc_running{false};
-static std::once_flag g_rpc_interrupt_flag;
-static std::once_flag g_rpc_stop_flag;
static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
/* Timer-creating functions */
@@ -295,6 +293,7 @@ void StartRPC()
void InterruptRPC()
{
+ static std::once_flag g_rpc_interrupt_flag;
// This function could be called twice if the GUI has been started with -server=1.
std::call_once(g_rpc_interrupt_flag, []() {
LogPrint(BCLog::RPC, "Interrupting RPC\n");
@@ -305,6 +304,7 @@ void InterruptRPC()
void StopRPC()
{
+ static std::once_flag g_rpc_stop_flag;
// This function could be called twice if the GUI has been started with -server=1.
assert(!g_rpc_running);
std::call_once(g_rpc_stop_flag, []() {
diff --git a/src/script/sigcache.cpp b/src/script/sigcache.cpp
index e7b6df3ce8..3c54d5bee4 100644
--- a/src/script/sigcache.cpp
+++ b/src/script/sigcache.cpp
@@ -23,7 +23,7 @@ class CSignatureCache
{
private:
//! Entries are SHA256(nonce || signature hash || public key || signature):
- uint256 nonce;
+ CSHA256 m_salted_hasher;
typedef CuckooCache::cache<uint256, SignatureCacheHasher> map_type;
map_type setValid;
boost::shared_mutex cs_sigcache;
@@ -31,13 +31,19 @@ private:
public:
CSignatureCache()
{
- GetRandBytes(nonce.begin(), 32);
+ uint256 nonce = GetRandHash();
+ // We want the nonce to be 64 bytes long to force the hasher to process
+ // this chunk, which makes later hash computations more efficient. We
+ // just write our 32-byte entropy twice to fill the 64 bytes.
+ m_salted_hasher.Write(nonce.begin(), 32);
+ m_salted_hasher.Write(nonce.begin(), 32);
}
void
ComputeEntry(uint256& entry, const uint256 &hash, const std::vector<unsigned char>& vchSig, const CPubKey& pubkey)
{
- CSHA256().Write(nonce.begin(), 32).Write(hash.begin(), 32).Write(&pubkey[0], pubkey.size()).Write(&vchSig[0], vchSig.size()).Finalize(entry.begin());
+ CSHA256 hasher = m_salted_hasher;
+ hasher.Write(hash.begin(), 32).Write(&pubkey[0], pubkey.size()).Write(&vchSig[0], vchSig.size()).Finalize(entry.begin());
}
bool
diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp
index f17b539e09..b4f392116c 100644
--- a/src/support/lockedpool.cpp
+++ b/src/support/lockedpool.cpp
@@ -29,7 +29,6 @@
#endif
LockedPoolManager* LockedPoolManager::_instance = nullptr;
-std::once_flag LockedPoolManager::init_flag;
/*******************************************************************************/
// Utilities
diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h
index de668f0773..b9e2e99d1a 100644
--- a/src/support/lockedpool.h
+++ b/src/support/lockedpool.h
@@ -221,7 +221,8 @@ public:
/** Return the current instance, or create it once */
static LockedPoolManager& Instance()
{
- std::call_once(LockedPoolManager::init_flag, LockedPoolManager::CreateInstance);
+ static std::once_flag init_flag;
+ std::call_once(init_flag, LockedPoolManager::CreateInstance);
return *LockedPoolManager::_instance;
}
@@ -234,7 +235,6 @@ private:
static bool LockingFailed();
static LockedPoolManager* _instance;
- static std::once_flag init_flag;
};
#endif // BITCOIN_SUPPORT_LOCKEDPOOL_H
diff --git a/src/test/fuzz/process_message.cpp b/src/test/fuzz/process_message.cpp
index 665a6224b4..c51ee3cf29 100644
--- a/src/test/fuzz/process_message.cpp
+++ b/src/test/fuzz/process_message.cpp
@@ -14,6 +14,7 @@
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/util/mining.h>
+#include <test/util/net.h>
#include <test/util/setup_common.h>
#include <util/memory.h>
#include <validationinterface.h>
@@ -63,19 +64,23 @@ void initialize()
void test_one_input(const std::vector<uint8_t>& buffer)
{
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+ ConnmanTestMsg& connman = *(ConnmanTestMsg*)g_setup->m_node.connman.get();
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
return;
}
CDataStream random_bytes_data_stream{fuzzed_data_provider.ConsumeRemainingBytes<unsigned char>(), SER_NETWORK, PROTOCOL_VERSION};
- CNode p2p_node{0, ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BLOOM), 0, INVALID_SOCKET, CAddress{CService{in_addr{0x0100007f}, 7777}, NODE_NETWORK}, 0, 0, CAddress{}, std::string{}, false};
+ CNode& p2p_node = *MakeUnique<CNode>(0, ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BLOOM), 0, INVALID_SOCKET, CAddress{CService{in_addr{0x0100007f}, 7777}, NODE_NETWORK}, 0, 0, CAddress{}, std::string{}, false).release();
p2p_node.fSuccessfullyConnected = true;
p2p_node.nVersion = PROTOCOL_VERSION;
p2p_node.SetSendVersion(PROTOCOL_VERSION);
+ connman.AddTestNode(p2p_node);
g_setup->m_node.peer_logic->InitializeNode(&p2p_node);
try {
(void)ProcessMessage(&p2p_node, random_message_type, random_bytes_data_stream, GetTimeMillis(), Params(), *g_setup->m_node.chainman, *g_setup->m_node.mempool, g_setup->m_node.connman.get(), g_setup->m_node.banman.get(), std::atomic<bool>{false});
} catch (const std::ios_base::failure&) {
}
SyncWithValidationInterfaceQueue();
+ LOCK2(::cs_main, g_cs_orphans); // See init.cpp for rationale for implicit locking order requirement
+ g_setup->m_node.connman->StopNodes();
}
diff --git a/src/test/fuzz/process_messages.cpp b/src/test/fuzz/process_messages.cpp
index bcbf65bdca..ad6c115a49 100644
--- a/src/test/fuzz/process_messages.cpp
+++ b/src/test/fuzz/process_messages.cpp
@@ -75,6 +75,7 @@ void test_one_input(const std::vector<uint8_t>& buffer)
} catch (const std::ios_base::failure&) {
}
}
- connman.ClearTestNodes();
SyncWithValidationInterfaceQueue();
+ LOCK2(::cs_main, g_cs_orphans); // See init.cpp for rationale for implicit locking order requirement
+ g_setup->m_node.connman->StopNodes();
}
diff --git a/src/test/fuzz/script.cpp b/src/test/fuzz/script.cpp
index e0c4ad7eb7..933cf9049d 100644
--- a/src/test/fuzz/script.cpp
+++ b/src/test/fuzz/script.cpp
@@ -11,6 +11,7 @@
#include <script/descriptor.h>
#include <script/interpreter.h>
#include <script/script.h>
+#include <script/script_error.h>
#include <script/sign.h>
#include <script/signingprovider.h>
#include <script/standard.h>
@@ -21,6 +22,8 @@
#include <univalue.h>
#include <util/memory.h>
+#include <algorithm>
+#include <cassert>
#include <cstdint>
#include <optional>
#include <string>
@@ -124,4 +127,40 @@ void test_one_input(const std::vector<uint8_t>& buffer)
wit.SetNull();
}
}
+
+ (void)GetOpName(ConsumeOpcodeType(fuzzed_data_provider));
+ (void)ScriptErrorString(static_cast<ScriptError>(fuzzed_data_provider.ConsumeIntegralInRange<int>(0, SCRIPT_ERR_ERROR_COUNT)));
+
+ {
+ const std::vector<uint8_t> bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);
+ CScript append_script{bytes.begin(), bytes.end()};
+ append_script << fuzzed_data_provider.ConsumeIntegral<int64_t>();
+ append_script << ConsumeOpcodeType(fuzzed_data_provider);
+ append_script << CScriptNum{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
+ append_script << ConsumeRandomLengthByteVector(fuzzed_data_provider);
+ }
+
+ {
+ WitnessUnknown witness_unknown_1{};
+ witness_unknown_1.version = fuzzed_data_provider.ConsumeIntegral<int>();
+ const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
+ witness_unknown_1.length = witness_unknown_program_1.size();
+ std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown_1.program);
+
+ WitnessUnknown witness_unknown_2{};
+ witness_unknown_2.version = fuzzed_data_provider.ConsumeIntegral<int>();
+ const std::vector<uint8_t> witness_unknown_program_2 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
+ witness_unknown_2.length = witness_unknown_program_2.size();
+ std::copy(witness_unknown_program_2.begin(), witness_unknown_program_2.end(), witness_unknown_2.program);
+
+ (void)(witness_unknown_1 == witness_unknown_2);
+ (void)(witness_unknown_1 < witness_unknown_2);
+ }
+
+ {
+ const CTxDestination tx_destination_1 = ConsumeTxDestination(fuzzed_data_provider);
+ const CTxDestination tx_destination_2 = ConsumeTxDestination(fuzzed_data_provider);
+ (void)(tx_destination_1 == tx_destination_2);
+ (void)(tx_destination_1 < tx_destination_2);
+ }
}
diff --git a/src/test/fuzz/script_bitcoin_consensus.cpp b/src/test/fuzz/script_bitcoin_consensus.cpp
new file mode 100644
index 0000000000..22f4b4f44a
--- /dev/null
+++ b/src/test/fuzz/script_bitcoin_consensus.cpp
@@ -0,0 +1,31 @@
+// Copyright (c) 2020 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 <script/bitcoinconsensus.h>
+#include <script/interpreter.h>
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+ const std::vector<uint8_t> random_bytes_1 = ConsumeRandomLengthByteVector(fuzzed_data_provider);
+ const std::vector<uint8_t> random_bytes_2 = ConsumeRandomLengthByteVector(fuzzed_data_provider);
+ const CAmount money = ConsumeMoney(fuzzed_data_provider);
+ bitcoinconsensus_error err;
+ bitcoinconsensus_error* err_p = fuzzed_data_provider.ConsumeBool() ? &err : nullptr;
+ const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
+ const unsigned int flags = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
+ assert(bitcoinconsensus_version() == BITCOINCONSENSUS_API_VER);
+ if ((flags & SCRIPT_VERIFY_WITNESS) != 0 && (flags & SCRIPT_VERIFY_P2SH) == 0) {
+ return;
+ }
+ (void)bitcoinconsensus_verify_script(random_bytes_1.data(), random_bytes_1.size(), random_bytes_2.data(), random_bytes_2.size(), n_in, flags, err_p);
+ (void)bitcoinconsensus_verify_script_with_amount(random_bytes_1.data(), random_bytes_1.size(), money, random_bytes_2.data(), random_bytes_2.size(), n_in, flags, err_p);
+}
diff --git a/src/test/fuzz/script_descriptor_cache.cpp b/src/test/fuzz/script_descriptor_cache.cpp
new file mode 100644
index 0000000000..4bfe61cec7
--- /dev/null
+++ b/src/test/fuzz/script_descriptor_cache.cpp
@@ -0,0 +1,42 @@
+// Copyright (c) 2020 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 <optional.h>
+#include <pubkey.h>
+#include <script/descriptor.h>
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+ DescriptorCache descriptor_cache;
+ while (fuzzed_data_provider.ConsumeBool()) {
+ const std::vector<uint8_t> code = fuzzed_data_provider.ConsumeBytes<uint8_t>(BIP32_EXTKEY_SIZE);
+ if (code.size() == BIP32_EXTKEY_SIZE) {
+ CExtPubKey xpub;
+ xpub.Decode(code.data());
+ const uint32_t key_exp_pos = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
+ CExtPubKey xpub_fetched;
+ if (fuzzed_data_provider.ConsumeBool()) {
+ (void)descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched);
+ descriptor_cache.CacheParentExtPubKey(key_exp_pos, xpub);
+ assert(descriptor_cache.GetCachedParentExtPubKey(key_exp_pos, xpub_fetched));
+ } else {
+ const uint32_t der_index = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
+ (void)descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched);
+ descriptor_cache.CacheDerivedExtPubKey(key_exp_pos, der_index, xpub);
+ assert(descriptor_cache.GetCachedDerivedExtPubKey(key_exp_pos, der_index, xpub_fetched));
+ }
+ assert(xpub == xpub_fetched);
+ }
+ (void)descriptor_cache.GetCachedParentExtPubKeys();
+ (void)descriptor_cache.GetCachedDerivedExtPubKeys();
+ }
+}
diff --git a/src/test/fuzz/script_interpreter.cpp b/src/test/fuzz/script_interpreter.cpp
new file mode 100644
index 0000000000..26d5732f24
--- /dev/null
+++ b/src/test/fuzz/script_interpreter.cpp
@@ -0,0 +1,41 @@
+// Copyright (c) 2020 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 <primitives/transaction.h>
+#include <script/interpreter.h>
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
+
+#include <cstdint>
+#include <optional>
+#include <string>
+#include <vector>
+
+bool CastToBool(const std::vector<unsigned char>& vch);
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+ {
+ const CScript script_code = ConsumeScript(fuzzed_data_provider);
+ const std::optional<CMutableTransaction> mtx = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
+ if (mtx) {
+ const CTransaction tx_to{*mtx};
+ const unsigned int in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
+ if (in < tx_to.vin.size()) {
+ (void)SignatureHash(script_code, tx_to, in, fuzzed_data_provider.ConsumeIntegral<int>(), ConsumeMoney(fuzzed_data_provider), fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0}), nullptr);
+ const std::optional<CMutableTransaction> mtx_precomputed = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
+ if (mtx_precomputed) {
+ const CTransaction tx_precomputed{*mtx_precomputed};
+ const PrecomputedTransactionData precomputed_transaction_data{tx_precomputed};
+ (void)SignatureHash(script_code, tx_to, in, fuzzed_data_provider.ConsumeIntegral<int>(), ConsumeMoney(fuzzed_data_provider), fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0}), &precomputed_transaction_data);
+ }
+ }
+ }
+ }
+ {
+ (void)CastToBool(ConsumeRandomLengthByteVector(fuzzed_data_provider));
+ }
+}
diff --git a/src/test/fuzz/script_sigcache.cpp b/src/test/fuzz/script_sigcache.cpp
new file mode 100644
index 0000000000..434a47b702
--- /dev/null
+++ b/src/test/fuzz/script_sigcache.cpp
@@ -0,0 +1,45 @@
+// Copyright (c) 2020 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 <chainparams.h>
+#include <chainparamsbase.h>
+#include <key.h>
+#include <pubkey.h>
+#include <script/sigcache.h>
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
+
+#include <cstdint>
+#include <optional>
+#include <string>
+#include <vector>
+
+void initialize()
+{
+ static const ECCVerifyHandle ecc_verify_handle;
+ ECC_Start();
+ SelectParams(CBaseChainParams::REGTEST);
+ InitSignatureCache();
+}
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+
+ const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
+ const CTransaction tx = mutable_transaction ? CTransaction{*mutable_transaction} : CTransaction{};
+ const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
+ const CAmount amount = ConsumeMoney(fuzzed_data_provider);
+ const bool store = fuzzed_data_provider.ConsumeBool();
+ PrecomputedTransactionData tx_data;
+ CachingTransactionSignatureChecker caching_transaction_signature_checker{mutable_transaction ? &tx : nullptr, n_in, amount, store, tx_data};
+ const std::optional<CPubKey> pub_key = ConsumeDeserializable<CPubKey>(fuzzed_data_provider);
+ if (pub_key) {
+ const std::vector<uint8_t> random_bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);
+ if (!random_bytes.empty()) {
+ (void)caching_transaction_signature_checker.VerifySignature(random_bytes, *pub_key, ConsumeUInt256(fuzzed_data_provider));
+ }
+ }
+}
diff --git a/src/test/fuzz/script_sign.cpp b/src/test/fuzz/script_sign.cpp
new file mode 100644
index 0000000000..c626f950e7
--- /dev/null
+++ b/src/test/fuzz/script_sign.cpp
@@ -0,0 +1,149 @@
+// Copyright (c) 2020 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 <chainparams.h>
+#include <chainparamsbase.h>
+#include <key.h>
+#include <pubkey.h>
+#include <script/keyorigin.h>
+#include <script/sign.h>
+#include <script/signingprovider.h>
+#include <streams.h>
+#include <test/fuzz/FuzzedDataProvider.h>
+#include <test/fuzz/fuzz.h>
+#include <test/fuzz/util.h>
+
+#include <cassert>
+#include <cstdint>
+#include <iostream>
+#include <map>
+#include <optional>
+#include <string>
+#include <vector>
+
+void initialize()
+{
+ static const ECCVerifyHandle ecc_verify_handle;
+ ECC_Start();
+ SelectParams(CBaseChainParams::REGTEST);
+}
+
+void test_one_input(const std::vector<uint8_t>& buffer)
+{
+ FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
+ const std::vector<uint8_t> key = ConsumeRandomLengthByteVector(fuzzed_data_provider, 128);
+
+ {
+ CDataStream random_data_stream = ConsumeDataStream(fuzzed_data_provider);
+ std::map<CPubKey, KeyOriginInfo> hd_keypaths;
+ try {
+ DeserializeHDKeypaths(random_data_stream, key, hd_keypaths);
+ } catch (const std::ios_base::failure&) {
+ }
+ CDataStream serialized{SER_NETWORK, PROTOCOL_VERSION};
+ SerializeHDKeypaths(serialized, hd_keypaths, fuzzed_data_provider.ConsumeIntegral<uint8_t>());
+ }
+
+ {
+ std::map<CPubKey, KeyOriginInfo> hd_keypaths;
+ while (fuzzed_data_provider.ConsumeBool()) {
+ const std::optional<CPubKey> pub_key = ConsumeDeserializable<CPubKey>(fuzzed_data_provider);
+ if (!pub_key) {
+ break;
+ }
+ const std::optional<KeyOriginInfo> key_origin_info = ConsumeDeserializable<KeyOriginInfo>(fuzzed_data_provider);
+ if (!key_origin_info) {
+ break;
+ }
+ hd_keypaths[*pub_key] = *key_origin_info;
+ }
+ CDataStream serialized{SER_NETWORK, PROTOCOL_VERSION};
+ try {
+ SerializeHDKeypaths(serialized, hd_keypaths, fuzzed_data_provider.ConsumeIntegral<uint8_t>());
+ } catch (const std::ios_base::failure&) {
+ }
+ std::map<CPubKey, KeyOriginInfo> deserialized_hd_keypaths;
+ try {
+ DeserializeHDKeypaths(serialized, key, hd_keypaths);
+ } catch (const std::ios_base::failure&) {
+ }
+ assert(hd_keypaths.size() >= deserialized_hd_keypaths.size());
+ }
+
+ {
+ SignatureData signature_data_1{ConsumeScript(fuzzed_data_provider)};
+ SignatureData signature_data_2{ConsumeScript(fuzzed_data_provider)};
+ signature_data_1.MergeSignatureData(signature_data_2);
+ }
+
+ FillableSigningProvider provider;
+ CKey k;
+ const std::vector<uint8_t> key_data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
+ k.Set(key_data.begin(), key_data.end(), fuzzed_data_provider.ConsumeBool());
+ if (k.IsValid()) {
+ provider.AddKey(k);
+ }
+
+ {
+ const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
+ const std::optional<CTxOut> tx_out = ConsumeDeserializable<CTxOut>(fuzzed_data_provider);
+ const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
+ if (mutable_transaction && tx_out && mutable_transaction->vin.size() > n_in) {
+ SignatureData signature_data_1 = DataFromTransaction(*mutable_transaction, n_in, *tx_out);
+ CTxIn input;
+ UpdateInput(input, signature_data_1);
+ const CScript script = ConsumeScript(fuzzed_data_provider);
+ SignatureData signature_data_2{script};
+ signature_data_1.MergeSignatureData(signature_data_2);
+ }
+ if (mutable_transaction) {
+ CTransaction tx_from{*mutable_transaction};
+ CMutableTransaction tx_to;
+ const std::optional<CMutableTransaction> opt_tx_to = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
+ if (opt_tx_to) {
+ tx_to = *opt_tx_to;
+ }
+ CMutableTransaction script_tx_to = tx_to;
+ CMutableTransaction sign_transaction_tx_to = tx_to;
+ if (n_in < tx_to.vin.size() && tx_to.vin[n_in].prevout.n < tx_from.vout.size()) {
+ (void)SignSignature(provider, tx_from, tx_to, n_in, fuzzed_data_provider.ConsumeIntegral<int>());
+ }
+ if (n_in < script_tx_to.vin.size()) {
+ (void)SignSignature(provider, ConsumeScript(fuzzed_data_provider), script_tx_to, n_in, ConsumeMoney(fuzzed_data_provider), fuzzed_data_provider.ConsumeIntegral<int>());
+ MutableTransactionSignatureCreator signature_creator{&tx_to, n_in, ConsumeMoney(fuzzed_data_provider), fuzzed_data_provider.ConsumeIntegral<int>()};
+ std::vector<unsigned char> vch_sig;
+ CKeyID address;
+ if (fuzzed_data_provider.ConsumeBool()) {
+ if (k.IsValid()) {
+ address = k.GetPubKey().GetID();
+ }
+ } else {
+ address = CKeyID{ConsumeUInt160(fuzzed_data_provider)};
+ }
+ (void)signature_creator.CreateSig(provider, vch_sig, address, ConsumeScript(fuzzed_data_provider), fuzzed_data_provider.PickValueInArray({SigVersion::BASE, SigVersion::WITNESS_V0}));
+ }
+ std::map<COutPoint, Coin> coins;
+ while (fuzzed_data_provider.ConsumeBool()) {
+ const std::optional<COutPoint> outpoint = ConsumeDeserializable<COutPoint>(fuzzed_data_provider);
+ if (!outpoint) {
+ break;
+ }
+ const std::optional<Coin> coin = ConsumeDeserializable<Coin>(fuzzed_data_provider);
+ if (!coin) {
+ break;
+ }
+ coins[*outpoint] = *coin;
+ }
+ std::map<int, std::string> input_errors;
+ (void)SignTransaction(sign_transaction_tx_to, &provider, coins, fuzzed_data_provider.ConsumeIntegral<int>(), input_errors);
+ }
+ }
+
+ {
+ SignatureData signature_data_1;
+ (void)ProduceSignature(provider, DUMMY_SIGNATURE_CREATOR, ConsumeScript(fuzzed_data_provider), signature_data_1);
+ SignatureData signature_data_2;
+ (void)ProduceSignature(provider, DUMMY_MAXIMUM_SIGNATURE_CREATOR, ConsumeScript(fuzzed_data_provider), signature_data_2);
+ }
+}
diff --git a/src/test/fuzz/string.cpp b/src/test/fuzz/string.cpp
index 50984b1aef..271062dc95 100644
--- a/src/test/fuzz/string.cpp
+++ b/src/test/fuzz/string.cpp
@@ -12,6 +12,7 @@
#include <rpc/server.h>
#include <rpc/util.h>
#include <script/descriptor.h>
+#include <script/script.h>
#include <serialize.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
@@ -89,6 +90,10 @@ void test_one_input(const std::vector<uint8_t>& buffer)
(void)urlDecode(random_string_1);
(void)ValidAsCString(random_string_1);
(void)_(random_string_1.c_str());
+ try {
+ throw scriptnum_error{random_string_1};
+ } catch (const std::runtime_error&) {
+ }
{
CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION};
diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h
index 9d0fb02128..f26878a704 100644
--- a/src/test/fuzz/util.h
+++ b/src/test/fuzz/util.h
@@ -12,6 +12,7 @@
#include <consensus/consensus.h>
#include <primitives/transaction.h>
#include <script/script.h>
+#include <script/standard.h>
#include <serialize.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
@@ -20,6 +21,7 @@
#include <uint256.h>
#include <version.h>
+#include <algorithm>
#include <cstdint>
#include <optional>
#include <string>
@@ -31,6 +33,11 @@ NODISCARD inline std::vector<uint8_t> ConsumeRandomLengthByteVector(FuzzedDataPr
return {s.begin(), s.end()};
}
+NODISCARD inline CDataStream ConsumeDataStream(FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096) noexcept
+{
+ return {ConsumeRandomLengthByteVector(fuzzed_data_provider, max_length), SER_NETWORK, INIT_PROTO_VERSION};
+}
+
NODISCARD inline std::vector<std::string> ConsumeRandomLengthStringVector(FuzzedDataProvider& fuzzed_data_provider, const size_t max_vector_size = 16, const size_t max_string_length = 16) noexcept
{
const size_t n_elements = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, max_vector_size);
@@ -87,10 +94,19 @@ NODISCARD inline CScriptNum ConsumeScriptNum(FuzzedDataProvider& fuzzed_data_pro
return CScriptNum{fuzzed_data_provider.ConsumeIntegral<int64_t>()};
}
+NODISCARD inline uint160 ConsumeUInt160(FuzzedDataProvider& fuzzed_data_provider) noexcept
+{
+ const std::vector<uint8_t> v160 = fuzzed_data_provider.ConsumeBytes<uint8_t>(160 / 8);
+ if (v160.size() != 160 / 8) {
+ return {};
+ }
+ return uint160{v160};
+}
+
NODISCARD inline uint256 ConsumeUInt256(FuzzedDataProvider& fuzzed_data_provider) noexcept
{
- const std::vector<unsigned char> v256 = fuzzed_data_provider.ConsumeBytes<unsigned char>(sizeof(uint256));
- if (v256.size() != sizeof(uint256)) {
+ const std::vector<uint8_t> v256 = fuzzed_data_provider.ConsumeBytes<uint8_t>(256 / 8);
+ if (v256.size() != 256 / 8) {
return {};
}
return uint256{v256};
@@ -116,6 +132,43 @@ NODISCARD inline CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider& fuzze
return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, spends_coinbase, sig_op_cost, {}};
}
+NODISCARD inline CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept
+{
+ CTxDestination tx_destination;
+ switch (fuzzed_data_provider.ConsumeIntegralInRange<int>(0, 5)) {
+ case 0: {
+ tx_destination = CNoDestination{};
+ break;
+ }
+ case 1: {
+ tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
+ break;
+ }
+ case 2: {
+ tx_destination = ScriptHash{ConsumeUInt160(fuzzed_data_provider)};
+ break;
+ }
+ case 3: {
+ tx_destination = WitnessV0ScriptHash{ConsumeUInt256(fuzzed_data_provider)};
+ break;
+ }
+ case 4: {
+ tx_destination = WitnessV0KeyHash{ConsumeUInt160(fuzzed_data_provider)};
+ break;
+ }
+ case 5: {
+ WitnessUnknown witness_unknown{};
+ witness_unknown.version = fuzzed_data_provider.ConsumeIntegral<int>();
+ const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
+ witness_unknown.length = witness_unknown_program_1.size();
+ std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown.program);
+ tx_destination = witness_unknown;
+ break;
+ }
+ }
+ return tx_destination;
+}
+
template <typename T>
NODISCARD bool MultiplicationOverflow(const T i, const T j) noexcept
{
diff --git a/src/test/raii_event_tests.cpp b/src/test/raii_event_tests.cpp
index 04bf7c20c1..8c2712f764 100644
--- a/src/test/raii_event_tests.cpp
+++ b/src/test/raii_event_tests.cpp
@@ -4,9 +4,6 @@
#include <event2/event.h>
-#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
-// It would probably be ideal to define dummy test(s) that report skipped, but boost::test doesn't seem to make that practical (at least not in versions available with common distros)
-
#include <map>
#include <stdlib.h>
@@ -16,6 +13,10 @@
#include <boost/test/unit_test.hpp>
+BOOST_FIXTURE_TEST_SUITE(raii_event_tests, BasicTestingSetup)
+
+#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
+
static std::map<void*, short> tags;
static std::map<void*, uint16_t> orders;
static uint16_t tagSequence = 0;
@@ -34,8 +35,6 @@ static void tag_free(void* mem) {
free(mem);
}
-BOOST_FIXTURE_TEST_SUITE(raii_event_tests, BasicTestingSetup)
-
BOOST_AUTO_TEST_CASE(raii_event_creation)
{
event_set_mem_functions(tag_malloc, realloc, tag_free);
@@ -87,6 +86,14 @@ BOOST_AUTO_TEST_CASE(raii_event_order)
event_set_mem_functions(malloc, realloc, free);
}
-BOOST_AUTO_TEST_SUITE_END()
+#else
+
+BOOST_AUTO_TEST_CASE(raii_event_tests_SKIPPED)
+{
+ // It would probably be ideal to report skipped, but boost::test doesn't seem to make that practical (at least not in versions available with common distros)
+ BOOST_TEST_MESSAGE("Skipping raii_event_tess: libevent doesn't support event_set_mem_functions");
+}
#endif // EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
+
+BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index c5c0208d8f..7d8eb8a323 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -410,7 +410,7 @@ void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
// for any reason except being included in a block. Clients interested
// in transactions included in blocks can subscribe to the BlockConnected
// notification.
- GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx());
+ GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx(), reason);
}
const uint256 hash = it->GetTx().GetHash();
diff --git a/src/txmempool.h b/src/txmempool.h
index 4568eb928d..583f7614b7 100644
--- a/src/txmempool.h
+++ b/src/txmempool.h
@@ -704,7 +704,7 @@ public:
/** Adds a transaction to the unbroadcast set */
void AddUnbroadcastTx(const uint256& txid) {
LOCK(cs);
- /** Sanity Check: the transaction should also be in the mempool */
+ // Sanity Check: the transaction should also be in the mempool
if (exists(txid)) {
m_unbroadcast_txids.insert(txid);
}
@@ -714,12 +714,12 @@ public:
void RemoveUnbroadcastTx(const uint256& txid, const bool unchecked = false);
/** Returns transactions in unbroadcast set */
- const std::set<uint256> GetUnbroadcastTxs() const {
+ std::set<uint256> GetUnbroadcastTxs() const {
LOCK(cs);
return m_unbroadcast_txids;
}
- // Returns if a txid is in the unbroadcast set
+ /** Returns whether a txid is in the unbroadcast set */
bool IsUnbroadcastTx(const uint256& txid) const {
LOCK(cs);
return (m_unbroadcast_txids.count(txid) != 0);
diff --git a/src/validation.cpp b/src/validation.cpp
index dbdf5028fd..0d57900670 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1481,14 +1481,21 @@ int GetSpendHeight(const CCoinsViewCache& inputs)
}
-static CuckooCache::cache<uint256, SignatureCacheHasher> scriptExecutionCache;
-static uint256 scriptExecutionCacheNonce(GetRandHash());
+static CuckooCache::cache<uint256, SignatureCacheHasher> g_scriptExecutionCache;
+static CSHA256 g_scriptExecutionCacheHasher;
void InitScriptExecutionCache() {
+ // Setup the salted hasher
+ uint256 nonce = GetRandHash();
+ // We want the nonce to be 64 bytes long to force the hasher to process
+ // this chunk, which makes later hash computations more efficient. We
+ // just write our 32-byte entropy twice to fill the 64 bytes.
+ g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
+ g_scriptExecutionCacheHasher.Write(nonce.begin(), 32);
// nMaxCacheSize is unsigned. If -maxsigcachesize is set to zero,
// setup_bytes creates the minimum possible cache (2 elements).
size_t nMaxCacheSize = std::min(std::max((int64_t)0, gArgs.GetArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_SIZE) / 2), MAX_MAX_SIG_CACHE_SIZE) * ((size_t) 1 << 20);
- size_t nElems = scriptExecutionCache.setup_bytes(nMaxCacheSize);
+ size_t nElems = g_scriptExecutionCache.setup_bytes(nMaxCacheSize);
LogPrintf("Using %zu MiB out of %zu/2 requested for script execution cache, able to store %zu elements\n",
(nElems*sizeof(uint256)) >>20, (nMaxCacheSize*2)>>20, nElems);
}
@@ -1526,12 +1533,10 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState &state, const C
// properly commits to the scriptPubKey in the inputs view of that
// transaction).
uint256 hashCacheEntry;
- // We only use the first 19 bytes of nonce to avoid a second SHA
- // round - giving us 19 + 32 + 4 = 55 bytes (+ 8 + 1 = 64)
- static_assert(55 - sizeof(flags) - 32 >= 128/8, "Want at least 128 bits of nonce for script execution cache");
- CSHA256().Write(scriptExecutionCacheNonce.begin(), 55 - sizeof(flags) - 32).Write(tx.GetWitnessHash().begin(), 32).Write((unsigned char*)&flags, sizeof(flags)).Finalize(hashCacheEntry.begin());
+ CSHA256 hasher = g_scriptExecutionCacheHasher;
+ hasher.Write(tx.GetWitnessHash().begin(), 32).Write((unsigned char*)&flags, sizeof(flags)).Finalize(hashCacheEntry.begin());
AssertLockHeld(cs_main); //TODO: Remove this requirement by making CuckooCache not require external locks
- if (scriptExecutionCache.contains(hashCacheEntry, !cacheFullScriptStore)) {
+ if (g_scriptExecutionCache.contains(hashCacheEntry, !cacheFullScriptStore)) {
return true;
}
@@ -1586,7 +1591,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState &state, const C
if (cacheFullScriptStore && !pvChecks) {
// We executed all of the provided scripts, and were told to
// cache the result. Do so now.
- scriptExecutionCache.insert(hashCacheEntry);
+ g_scriptExecutionCache.insert(hashCacheEntry);
}
return true;
@@ -5067,12 +5072,18 @@ bool LoadMempool(CTxMemPool& pool)
pool.PrioritiseTransaction(i.first, i.second);
}
- std::set<uint256> unbroadcast_txids;
- file >> unbroadcast_txids;
- unbroadcast = unbroadcast_txids.size();
+ // TODO: remove this try except in v0.22
+ try {
+ std::set<uint256> unbroadcast_txids;
+ file >> unbroadcast_txids;
+ unbroadcast = unbroadcast_txids.size();
- for (const auto& txid : unbroadcast_txids) {
+ for (const auto& txid : unbroadcast_txids) {
pool.AddUnbroadcastTx(txid);
+ }
+ } catch (const std::exception&) {
+ // mempool.dat files created prior to v0.21 will not have an
+ // unbroadcast set. No need to log a failure if parsing fails here.
}
} catch (const std::exception& e) {
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
index 9437f9c817..3dfbcc581c 100644
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -199,22 +199,22 @@ void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInd
fInitialDownload);
}
-void CMainSignals::TransactionAddedToMempool(const CTransactionRef &ptx) {
- auto event = [ptx, this] {
- m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionAddedToMempool(ptx); });
+void CMainSignals::TransactionAddedToMempool(const CTransactionRef& tx) {
+ auto event = [tx, this] {
+ m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionAddedToMempool(tx); });
};
ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s wtxid=%s", __func__,
- ptx->GetHash().ToString(),
- ptx->GetWitnessHash().ToString());
+ tx->GetHash().ToString(),
+ tx->GetWitnessHash().ToString());
}
-void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef &ptx) {
- auto event = [ptx, this] {
- m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionRemovedFromMempool(ptx); });
+void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {
+ auto event = [tx, reason, this] {
+ m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionRemovedFromMempool(tx, reason); });
};
ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s wtxid=%s", __func__,
- ptx->GetHash().ToString(),
- ptx->GetWitnessHash().ToString());
+ tx->GetHash().ToString(),
+ tx->GetWitnessHash().ToString());
}
void CMainSignals::BlockConnected(const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
diff --git a/src/validationinterface.h b/src/validationinterface.h
index 9c23965bc1..e96f2883fc 100644
--- a/src/validationinterface.h
+++ b/src/validationinterface.h
@@ -21,6 +21,7 @@ class CConnman;
class CValidationInterface;
class uint256;
class CScheduler;
+enum class MemPoolRemovalReason;
/** Register subscriber */
void RegisterValidationInterface(CValidationInterface* callbacks);
@@ -96,7 +97,7 @@ protected:
*
* Called on a background thread.
*/
- virtual void TransactionAddedToMempool(const CTransactionRef &ptxn) {}
+ virtual void TransactionAddedToMempool(const CTransactionRef& tx) {}
/**
* Notifies listeners of a transaction leaving mempool.
*
@@ -129,7 +130,7 @@ protected:
*
* Called on a background thread.
*/
- virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx) {}
+ virtual void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {}
/**
* Notifies listeners of a block being connected.
* Provides a vector of transactions evicted from the mempool as a result.
@@ -196,8 +197,8 @@ public:
void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
- void TransactionAddedToMempool(const CTransactionRef &);
- void TransactionRemovedFromMempool(const CTransactionRef &);
+ void TransactionAddedToMempool(const CTransactionRef&);
+ void TransactionRemovedFromMempool(const CTransactionRef&, MemPoolRemovalReason);
void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex);
void BlockDisconnected(const std::shared_ptr<const CBlock> &, const CBlockIndex* pindex);
void ChainStateFlushed(const CBlockLocator &);
diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp
index 4ed28b0623..d90e8e6433 100644
--- a/src/wallet/db.cpp
+++ b/src/wallet/db.cpp
@@ -14,8 +14,6 @@
#include <sys/stat.h>
#endif
-#include <boost/thread.hpp>
-
namespace {
//! Make sure database has a unique fileid within the environment. If it
@@ -671,7 +669,6 @@ bool BerkeleyBatch::PeriodicFlush(BerkeleyDatabase& database)
if (nRefCount == 0)
{
- boost::this_thread::interruption_point();
std::map<std::string, int>::iterator mi = env->mapFileUseCount.find(strFile);
if (mi != env->mapFileUseCount.end())
{
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 7824563254..89737ca7b5 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -21,6 +21,7 @@
#include <script/descriptor.h>
#include <script/script.h>
#include <script/signingprovider.h>
+#include <txmempool.h>
#include <util/bip32.h>
#include <util/check.h>
#include <util/error.h>
@@ -1100,23 +1101,52 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, CWalletTx::Confirmatio
MarkInputsDirty(ptx);
}
-void CWallet::transactionAddedToMempool(const CTransactionRef& ptx) {
+void CWallet::transactionAddedToMempool(const CTransactionRef& tx) {
LOCK(cs_wallet);
- CWalletTx::Confirmation confirm(CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, {}, /* nIndex */ 0);
- SyncTransaction(ptx, confirm);
+ SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0});
- auto it = mapWallet.find(ptx->GetHash());
+ auto it = mapWallet.find(tx->GetHash());
if (it != mapWallet.end()) {
it->second.fInMempool = true;
}
}
-void CWallet::transactionRemovedFromMempool(const CTransactionRef &ptx) {
+void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) {
LOCK(cs_wallet);
- auto it = mapWallet.find(ptx->GetHash());
+ auto it = mapWallet.find(tx->GetHash());
if (it != mapWallet.end()) {
it->second.fInMempool = false;
}
+ // Handle transactions that were removed from the mempool because they
+ // conflict with transactions in a newly connected block.
+ if (reason == MemPoolRemovalReason::CONFLICT) {
+ // Call SyncNotifications, so external -walletnotify notifications will
+ // be triggered for these transactions. Set Status::UNCONFIRMED instead
+ // of Status::CONFLICTED for a few reasons:
+ //
+ // 1. The transactionRemovedFromMempool callback does not currently
+ // provide the conflicting block's hash and height, and for backwards
+ // compatibility reasons it may not be not safe to store conflicted
+ // wallet transactions with a null block hash. See
+ // https://github.com/bitcoin/bitcoin/pull/18600#discussion_r420195993.
+ // 2. For most of these transactions, the wallet's internal conflict
+ // detection in the blockConnected handler will subsequently call
+ // MarkConflicted and update them with CONFLICTED status anyway. This
+ // applies to any wallet transaction that has inputs spent in the
+ // block, or that has ancestors in the wallet with inputs spent by
+ // the block.
+ // 3. Longstanding behavior since the sync implementation in
+ // https://github.com/bitcoin/bitcoin/pull/9371 and the prior sync
+ // implementation before that was to mark these transactions
+ // unconfirmed rather than conflicted.
+ //
+ // Nothing described above should be seen as an unchangeable requirement
+ // when improving this code in the future. The wallet's heuristics for
+ // distinguishing between conflicted and unconfirmed transactions are
+ // imperfect, and could be improved in general, see
+ // https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking
+ SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0});
+ }
}
void CWallet::blockConnected(const CBlock& block, int height)
@@ -1127,9 +1157,8 @@ void CWallet::blockConnected(const CBlock& block, int height)
m_last_block_processed_height = height;
m_last_block_processed = block_hash;
for (size_t index = 0; index < block.vtx.size(); index++) {
- CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, block_hash, index);
- SyncTransaction(block.vtx[index], confirm);
- transactionRemovedFromMempool(block.vtx[index]);
+ SyncTransaction(block.vtx[index], {CWalletTx::Status::CONFIRMED, height, block_hash, (int)index});
+ transactionRemovedFromMempool(block.vtx[index], MemPoolRemovalReason::BLOCK);
}
}
@@ -1144,8 +1173,7 @@ void CWallet::blockDisconnected(const CBlock& block, int height)
m_last_block_processed_height = height - 1;
m_last_block_processed = block.hashPrevBlock;
for (const CTransactionRef& ptx : block.vtx) {
- CWalletTx::Confirmation confirm(CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, {}, /* nIndex */ 0);
- SyncTransaction(ptx, confirm);
+ SyncTransaction(ptx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, /* block hash */ {}, /* index */ 0});
}
}
@@ -1685,8 +1713,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
break;
}
for (size_t posInBlock = 0; posInBlock < block.vtx.size(); ++posInBlock) {
- CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, block_height, block_hash, posInBlock);
- SyncTransaction(block.vtx[posInBlock], confirm, fUpdate);
+ SyncTransaction(block.vtx[posInBlock], {CWalletTx::Status::CONFIRMED, block_height, block_hash, (int)posInBlock}, fUpdate);
}
// scan succeeded, record block as most recent successfully scanned
result.last_scanned_block = block_hash;
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index e3141baef0..67331dc3be 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -921,7 +921,7 @@ public:
uint256 last_failed_block;
};
ScanResult ScanForWalletTransactions(const uint256& start_block, int start_height, Optional<int> max_height, const WalletRescanReserver& reserver, bool fUpdate);
- void transactionRemovedFromMempool(const CTransactionRef &ptx) override;
+ void transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) override;
void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
void ResendWalletTransactions();
struct Balance {
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index e7adbfea77..cb516f70f0 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -18,8 +18,6 @@
#include <atomic>
#include <string>
-#include <boost/thread.hpp>
-
namespace DBKeys {
const std::string ACENTRY{"acentry"};
const std::string ACTIVEEXTERNALSPK{"activeexternalspk"};
@@ -745,11 +743,7 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
pwallet->WalletLogPrintf("%s\n", strErr);
}
pcursor->close();
- }
- catch (const boost::thread_interrupted&) {
- throw;
- }
- catch (...) {
+ } catch (...) {
result = DBErrors::CORRUPT;
}
@@ -887,11 +881,7 @@ DBErrors WalletBatch::FindWalletTx(std::vector<uint256>& vTxHash, std::list<CWal
}
}
pcursor->close();
- }
- catch (const boost::thread_interrupted&) {
- throw;
- }
- catch (...) {
+ } catch (...) {
result = DBErrors::CORRUPT;
}
diff --git a/test/config.ini.in b/test/config.ini.in
index 9687206ee1..be1bfe8752 100644
--- a/test/config.ini.in
+++ b/test/config.ini.in
@@ -7,6 +7,7 @@
[environment]
PACKAGE_NAME=@PACKAGE_NAME@
+PACKAGE_BUGREPORT=@PACKAGE_BUGREPORT@
SRCDIR=@abs_top_srcdir@
BUILDDIR=@abs_top_builddir@
EXEEXT=@EXEEXT@
diff --git a/test/functional/feature_notifications.py b/test/functional/feature_notifications.py
index 47200b6cc6..fb0c7ceed4 100755
--- a/test/functional/feature_notifications.py
+++ b/test/functional/feature_notifications.py
@@ -125,12 +125,7 @@ class NotificationsTest(BitcoinTestFramework):
# Bump tx2 as bump2 and generate a block on node 0 while
# disconnected, then reconnect and check for notifications on node 1
- # about newly confirmed bump2 and newly conflicted tx2. Currently
- # only the bump2 notification is sent. Ideally, notifications would
- # be sent both for bump2 and tx2, which was the previous behavior
- # before being broken by an accidental change in PR
- # https://github.com/bitcoin/bitcoin/pull/16624. The bug is reported
- # in issue https://github.com/bitcoin/bitcoin/issues/18325.
+ # about newly confirmed bump2 and newly conflicted tx2.
disconnect_nodes(self.nodes[0], 1)
bump2 = self.nodes[0].bumpfee(tx2)["txid"]
self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)
@@ -138,7 +133,7 @@ class NotificationsTest(BitcoinTestFramework):
assert_equal(tx2 in self.nodes[1].getrawmempool(), True)
connect_nodes(self.nodes[0], 1)
self.sync_blocks()
- self.expect_wallet_notify([bump2])
+ self.expect_wallet_notify([bump2, tx2])
assert_equal(self.nodes[1].gettransaction(bump2)["confirmations"], 1)
# TODO: add test for `-alertnotify` large fork notifications
diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py
index 3969da2eb0..5d00648aed 100755
--- a/test/functional/mempool_persist.py
+++ b/test/functional/mempool_persist.py
@@ -84,7 +84,9 @@ class MempoolPersistTest(BitcoinTestFramework):
assert_greater_than_or_equal(tx_creation_time_higher, tx_creation_time)
# disconnect nodes & make a txn that remains in the unbroadcast set.
- disconnect_nodes(self.nodes[0], 2)
+ disconnect_nodes(self.nodes[0], 1)
+ assert(len(self.nodes[0].getpeerinfo()) == 0)
+ assert(len(self.nodes[0].p2ps) == 0)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), Decimal("12"))
connect_nodes(self.nodes[0], 2)
@@ -157,8 +159,10 @@ class MempoolPersistTest(BitcoinTestFramework):
# clear out mempool
node0.generate(1)
- # disconnect nodes to make a txn that remains in the unbroadcast set.
- disconnect_nodes(node0, 1)
+ # ensure node0 doesn't have any connections
+ # make a transaction that will remain in the unbroadcast set
+ assert(len(node0.getpeerinfo()) == 0)
+ assert(len(node0.p2ps) == 0)
node0.sendtoaddress(self.nodes[1].getnewaddress(), Decimal("12"))
# shutdown, then startup with wallet disabled
diff --git a/test/functional/mempool_unbroadcast.py b/test/functional/mempool_unbroadcast.py
index dedf5b8a47..365d011157 100755
--- a/test/functional/mempool_unbroadcast.py
+++ b/test/functional/mempool_unbroadcast.py
@@ -16,6 +16,7 @@ from test_framework.util import (
disconnect_nodes,
)
+MAX_INITIAL_BROADCAST_DELAY = 15 * 60 # 15 minutes in seconds
class MempoolUnbroadcastTest(BitcoinTestFramework):
def set_test_params(self):
@@ -72,7 +73,7 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
connect_nodes(node, 1)
# fast forward into the future & ensure that the second node has the txns
- node.mockscheduler(15 * 60) # 15 min in seconds
+ node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
self.sync_mempools(timeout=30)
mempool = self.nodes[1].getrawmempool()
assert rpc_tx_hsh in mempool
@@ -86,15 +87,16 @@ class MempoolUnbroadcastTest(BitcoinTestFramework):
self.log.info("Add another connection & ensure transactions aren't broadcast again")
conn = node.add_p2p_connection(P2PTxInvStore())
- node.mockscheduler(15 * 60)
- time.sleep(5)
+ node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY)
+ time.sleep(2) # allow sufficient time for possibility of broadcast
assert_equal(len(conn.get_invs()), 0)
+ disconnect_nodes(node, 1)
+ node.disconnect_p2ps()
+
def test_txn_removal(self):
self.log.info("Test that transactions removed from mempool are removed from unbroadcast set")
node = self.nodes[0]
- disconnect_nodes(node, 1)
- node.disconnect_p2ps
# since the node doesn't have any connections, it will not receive
# any GETDATAs & thus the transaction will remain in the unbroadcast set.
diff --git a/test/functional/p2p_blockfilters.py b/test/functional/p2p_blockfilters.py
index 9ff76b4b3d..6d947ac660 100755
--- a/test/functional/p2p_blockfilters.py
+++ b/test/functional/p2p_blockfilters.py
@@ -13,6 +13,7 @@ from test_framework.messages import (
hash256,
msg_getcfcheckpt,
msg_getcfheaders,
+ msg_getcfilters,
ser_uint256,
uint256_from_str,
)
@@ -25,6 +26,21 @@ from test_framework.util import (
wait_until,
)
+class CFiltersClient(P2PInterface):
+ def __init__(self):
+ super().__init__()
+ # Store the cfilters received.
+ self.cfilters = []
+
+ def pop_cfilters(self):
+ cfilters = self.cfilters
+ self.cfilters = []
+ return cfilters
+
+ def on_cfilter(self, message):
+ """Store cfilters received in a list."""
+ self.cfilters.append(message)
+
class CompactFiltersTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
@@ -37,8 +53,8 @@ class CompactFiltersTest(BitcoinTestFramework):
def run_test(self):
# Node 0 supports COMPACT_FILTERS, node 1 does not.
- node0 = self.nodes[0].add_p2p_connection(P2PInterface())
- node1 = self.nodes[1].add_p2p_connection(P2PInterface())
+ node0 = self.nodes[0].add_p2p_connection(CFiltersClient())
+ node1 = self.nodes[1].add_p2p_connection(CFiltersClient())
# Nodes 0 & 1 share the same first 999 blocks in the chain.
self.nodes[0].generate(999)
@@ -112,7 +128,8 @@ class CompactFiltersTest(BitcoinTestFramework):
)
node0.send_and_ping(request)
response = node0.last_message['cfheaders']
- assert_equal(len(response.hashes), 1000)
+ main_cfhashes = response.hashes
+ assert_equal(len(main_cfhashes), 1000)
assert_equal(
compute_last_header(response.prev_header, response.hashes),
int(main_cfcheckpt, 16)
@@ -126,12 +143,50 @@ class CompactFiltersTest(BitcoinTestFramework):
)
node0.send_and_ping(request)
response = node0.last_message['cfheaders']
- assert_equal(len(response.hashes), 1000)
+ stale_cfhashes = response.hashes
+ assert_equal(len(stale_cfhashes), 1000)
assert_equal(
compute_last_header(response.prev_header, response.hashes),
int(stale_cfcheckpt, 16)
)
+ self.log.info("Check that peers can fetch cfilters.")
+ stop_hash = self.nodes[0].getblockhash(10)
+ request = msg_getcfilters(
+ filter_type=FILTER_TYPE_BASIC,
+ start_height=1,
+ stop_hash=int(stop_hash, 16)
+ )
+ node0.send_message(request)
+ node0.sync_with_ping()
+ response = node0.pop_cfilters()
+ assert_equal(len(response), 10)
+
+ self.log.info("Check that cfilter responses are correct.")
+ for cfilter, cfhash, height in zip(response, main_cfhashes, range(1, 11)):
+ block_hash = self.nodes[0].getblockhash(height)
+ assert_equal(cfilter.filter_type, FILTER_TYPE_BASIC)
+ assert_equal(cfilter.block_hash, int(block_hash, 16))
+ computed_cfhash = uint256_from_str(hash256(cfilter.filter_data))
+ assert_equal(computed_cfhash, cfhash)
+
+ self.log.info("Check that peers can fetch cfilters for stale blocks.")
+ request = msg_getcfilters(
+ filter_type=FILTER_TYPE_BASIC,
+ start_height=1000,
+ stop_hash=int(stale_block_hash, 16)
+ )
+ node0.send_message(request)
+ node0.sync_with_ping()
+ response = node0.pop_cfilters()
+ assert_equal(len(response), 1)
+
+ cfilter = response[0]
+ assert_equal(cfilter.filter_type, FILTER_TYPE_BASIC)
+ assert_equal(cfilter.block_hash, int(stale_block_hash, 16))
+ computed_cfhash = uint256_from_str(hash256(cfilter.filter_data))
+ assert_equal(computed_cfhash, stale_cfhashes[999])
+
self.log.info("Requests to node 1 without NODE_COMPACT_FILTERS results in disconnection.")
requests = [
msg_getcfcheckpt(
@@ -143,6 +198,11 @@ class CompactFiltersTest(BitcoinTestFramework):
start_height=1000,
stop_hash=int(main_block_hash, 16)
),
+ msg_getcfilters(
+ filter_type=FILTER_TYPE_BASIC,
+ start_height=1000,
+ stop_hash=int(main_block_hash, 16)
+ ),
]
for request in requests:
node1 = self.nodes[1].add_p2p_connection(P2PInterface())
@@ -151,6 +211,12 @@ class CompactFiltersTest(BitcoinTestFramework):
self.log.info("Check that invalid requests result in disconnection.")
requests = [
+ # Requesting too many filters results in disconnection.
+ msg_getcfilters(
+ filter_type=FILTER_TYPE_BASIC,
+ start_height=0,
+ stop_hash=int(main_block_hash, 16)
+ ),
# Requesting too many filter headers results in disconnection.
msg_getcfheaders(
filter_type=FILTER_TYPE_BASIC,
diff --git a/test/functional/rpc_getaddressinfo_label_deprecation.py b/test/functional/rpc_getaddressinfo_label_deprecation.py
index 4c6b2fe5cf..09545ebce7 100755
--- a/test/functional/rpc_getaddressinfo_label_deprecation.py
+++ b/test/functional/rpc_getaddressinfo_label_deprecation.py
@@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""
Test deprecation of the RPC getaddressinfo `label` field. It has been
-superceded by the `labels` field.
+superseded by the `labels` field.
"""
from test_framework.test_framework import BitcoinTestFramework
diff --git a/test/functional/test_framework/address.py b/test/functional/test_framework/address.py
index 8f410f233e..9506b63f82 100644
--- a/test/functional/test_framework/address.py
+++ b/test/functional/test_framework/address.py
@@ -5,12 +5,15 @@
"""Encode and decode BASE58, P2PKH and P2SH addresses."""
import enum
+import unittest
from .script import hash256, hash160, sha256, CScript, OP_0
from .util import hex_str_to_bytes
from . import segwit_addr
+from test_framework.util import assert_equal
+
ADDRESS_BCRT1_UNSPENDABLE = 'bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj'
ADDRESS_BCRT1_UNSPENDABLE_DESCRIPTOR = 'addr(bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj)#juyq9d97'
# Coins sent to this address can be spent with a witness stack of just OP_TRUE
@@ -41,7 +44,32 @@ def byte_to_base58(b, version):
str = str[2:]
return result
-# TODO: def base58_decode
+
+def base58_to_byte(s, verify_checksum=True):
+ if not s:
+ return b''
+ n = 0
+ for c in s:
+ n *= 58
+ assert c in chars
+ digit = chars.index(c)
+ n += digit
+ h = '%x' % n
+ if len(h) % 2:
+ h = '0' + h
+ res = n.to_bytes((n.bit_length() + 7) // 8, 'big')
+ pad = 0
+ for c in s:
+ if c == chars[0]:
+ pad += 1
+ else:
+ break
+ res = b'\x00' * pad + res
+ if verify_checksum:
+ assert_equal(hash256(res[:-4])[:4], res[-4:])
+
+ return res[1:-4], int(res[0])
+
def keyhash_to_p2pkh(hash, main = False):
assert len(hash) == 20
@@ -100,3 +128,22 @@ def check_script(script):
if (type(script) is bytes or type(script) is CScript):
return script
assert False
+
+
+class TestFrameworkScript(unittest.TestCase):
+ def test_base58encodedecode(self):
+ def check_base58(data, version):
+ self.assertEqual(base58_to_byte(byte_to_base58(data, version)), (data, version))
+
+ check_base58(b'\x1f\x8e\xa1p*{\xd4\x94\x1b\xca\tA\xb8R\xc4\xbb\xfe\xdb.\x05', 111)
+ check_base58(b':\x0b\x05\xf4\xd7\xf6l;\xa7\x00\x9fE50)l\x84\\\xc9\xcf', 111)
+ check_base58(b'A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 111)
+ check_base58(b'\0A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 111)
+ check_base58(b'\0\0A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 111)
+ check_base58(b'\0\0\0A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 111)
+ check_base58(b'\x1f\x8e\xa1p*{\xd4\x94\x1b\xca\tA\xb8R\xc4\xbb\xfe\xdb.\x05', 0)
+ check_base58(b':\x0b\x05\xf4\xd7\xf6l;\xa7\x00\x9fE50)l\x84\\\xc9\xcf', 0)
+ check_base58(b'A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 0)
+ check_base58(b'\0A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 0)
+ check_base58(b'\0\0A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 0)
+ check_base58(b'\0\0\0A\xc1\xea\xf1\x11\x80%Y\xba\xd6\x1b`\xd6+\x1f\x89|c\x92\x8a', 0)
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index d178e79541..4d1dd4422e 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -1516,6 +1516,57 @@ class msg_no_witness_blocktxn(msg_blocktxn):
def serialize(self):
return self.block_transactions.serialize(with_witness=False)
+
+class msg_getcfilters:
+ __slots__ = ("filter_type", "start_height", "stop_hash")
+ msgtype = b"getcfilters"
+
+ def __init__(self, filter_type, start_height, stop_hash):
+ self.filter_type = filter_type
+ self.start_height = start_height
+ self.stop_hash = stop_hash
+
+ def deserialize(self, f):
+ self.filter_type = struct.unpack("<B", f.read(1))[0]
+ self.start_height = struct.unpack("<I", f.read(4))[0]
+ self.stop_hash = deser_uint256(f)
+
+ def serialize(self):
+ r = b""
+ r += struct.pack("<B", self.filter_type)
+ r += struct.pack("<I", self.start_height)
+ r += ser_uint256(self.stop_hash)
+ return r
+
+ def __repr__(self):
+ return "msg_getcfilters(filter_type={:#x}, start_height={}, stop_hash={:x})".format(
+ self.filter_type, self.start_height, self.stop_hash)
+
+class msg_cfilter:
+ __slots__ = ("filter_type", "block_hash", "filter_data")
+ msgtype = b"cfilter"
+
+ def __init__(self, filter_type=None, block_hash=None, filter_data=None):
+ self.filter_type = filter_type
+ self.block_hash = block_hash
+ self.filter_data = filter_data
+
+ def deserialize(self, f):
+ self.filter_type = struct.unpack("<B", f.read(1))[0]
+ self.block_hash = deser_uint256(f)
+ self.filter_data = deser_string(f)
+
+ def serialize(self):
+ r = b""
+ r += struct.pack("<B", self.filter_type)
+ r += ser_uint256(self.block_hash)
+ r += ser_string(self.filter_data)
+ return r
+
+ def __repr__(self):
+ return "msg_cfilter(filter_type={:#x}, block_hash={:x})".format(
+ self.filter_type, self.block_hash)
+
class msg_getcfheaders:
__slots__ = ("filter_type", "start_height", "stop_hash")
msgtype = b"getcfheaders"
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py
index d1e982ac3e..45063aaff2 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -31,8 +31,9 @@ from test_framework.messages import (
msg_block,
MSG_BLOCK,
msg_blocktxn,
- msg_cfheaders,
msg_cfcheckpt,
+ msg_cfheaders,
+ msg_cfilter,
msg_cmpctblock,
msg_feefilter,
msg_filteradd,
@@ -69,8 +70,9 @@ MESSAGEMAP = {
b"addr": msg_addr,
b"block": msg_block,
b"blocktxn": msg_blocktxn,
- b"cfheaders": msg_cfheaders,
b"cfcheckpt": msg_cfcheckpt,
+ b"cfheaders": msg_cfheaders,
+ b"cfilter": msg_cfilter,
b"cmpctblock": msg_cmpctblock,
b"feefilter": msg_feefilter,
b"filteradd": msg_filteradd,
@@ -332,8 +334,9 @@ class P2PInterface(P2PConnection):
def on_addr(self, message): pass
def on_block(self, message): pass
def on_blocktxn(self, message): pass
- def on_cfheaders(self, message): pass
def on_cfcheckpt(self, message): pass
+ def on_cfheaders(self, message): pass
+ def on_cfilter(self, message): pass
def on_cmpctblock(self, message): pass
def on_feefilter(self, message): pass
def on_filteradd(self, message): pass
@@ -655,6 +658,8 @@ class P2PTxInvStore(P2PInterface):
# save txid
self.tx_invs_received[i.hash] += 1
+ super().on_inv(message)
+
def get_invs(self):
with mininode_lock:
return list(self.tx_invs_received.keys())
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 716fa1d845..5469f808d1 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -290,7 +290,12 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
exit_code = TEST_EXIT_SKIPPED
else:
self.log.error("Test failed. Test logging available at %s/test_framework.log", self.options.tmpdir)
+ self.log.error("")
self.log.error("Hint: Call {} '{}' to consolidate all logs".format(os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../combine_logs.py"), self.options.tmpdir))
+ self.log.error("")
+ self.log.error("If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.")
+ self.log.error(self.config['environment']['PACKAGE_BUGREPORT'])
+ self.log.error("")
exit_code = TEST_EXIT_FAILED
# Logging.shutdown will not remove stream- and filehandlers, so we must
# do it explicitly. Handlers are removed so the next test run can apply
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 7821355e29..0812470b0c 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -67,6 +67,7 @@ TEST_EXIT_PASSED = 0
TEST_EXIT_SKIPPED = 77
TEST_FRAMEWORK_MODULES = [
+ "address",
"script",
]
diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py
index 5b083a5398..c441b75652 100755
--- a/test/functional/wallet_hd.py
+++ b/test/functional/wallet_hd.py
@@ -11,7 +11,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
connect_nodes,
- assert_raises_rpc_error
+ assert_raises_rpc_error,
)
@@ -32,11 +32,11 @@ class WalletHDTest(BitcoinTestFramework):
# create an internal key
change_addr = self.nodes[1].getrawchangeaddress()
- change_addrV= self.nodes[1].getaddressinfo(change_addr)
+ change_addrV = self.nodes[1].getaddressinfo(change_addr)
if self.options.descriptors:
assert_equal(change_addrV["hdkeypath"], "m/84'/1'/0'/1/0")
else:
- assert_equal(change_addrV["hdkeypath"], "m/0'/1'/0'") #first internal child key
+ assert_equal(change_addrV["hdkeypath"], "m/0'/1'/0'") #first internal child key
# Import a non-HD private key in the HD wallet
non_hd_add = 'bcrt1qmevj8zfx0wdvp05cqwkmr6mxkfx60yezwjksmt'
@@ -58,7 +58,7 @@ class WalletHDTest(BitcoinTestFramework):
if self.options.descriptors:
assert_equal(hd_info["hdkeypath"], "m/84'/1'/0'/0/" + str(i))
else:
- assert_equal(hd_info["hdkeypath"], "m/0'/0'/"+str(i)+"'")
+ assert_equal(hd_info["hdkeypath"], "m/0'/0'/" + str(i) + "'")
assert_equal(hd_info["hdmasterfingerprint"], hd_fingerprint)
self.nodes[0].sendtoaddress(hd_add, 1)
self.nodes[0].generate(1)
@@ -67,11 +67,11 @@ class WalletHDTest(BitcoinTestFramework):
# create an internal key (again)
change_addr = self.nodes[1].getrawchangeaddress()
- change_addrV= self.nodes[1].getaddressinfo(change_addr)
+ change_addrV = self.nodes[1].getaddressinfo(change_addr)
if self.options.descriptors:
assert_equal(change_addrV["hdkeypath"], "m/84'/1'/0'/1/1")
else:
- assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") #second internal child key
+ assert_equal(change_addrV["hdkeypath"], "m/0'/1'/1'") #second internal child key
self.sync_all()
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
@@ -82,7 +82,10 @@ class WalletHDTest(BitcoinTestFramework):
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks"))
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate"))
- shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, 'wallets', "wallet.dat"))
+ shutil.copyfile(
+ os.path.join(self.nodes[1].datadir, "hd.bak"),
+ os.path.join(self.nodes[1].datadir, self.chain, 'wallets', "wallet.dat"),
+ )
self.start_node(1)
# Assert that derivation is deterministic
@@ -93,7 +96,7 @@ class WalletHDTest(BitcoinTestFramework):
if self.options.descriptors:
assert_equal(hd_info_2["hdkeypath"], "m/84'/1'/0'/0/" + str(i))
else:
- assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/"+str(i)+"'")
+ assert_equal(hd_info_2["hdkeypath"], "m/0'/0'/" + str(i) + "'")
assert_equal(hd_info_2["hdmasterfingerprint"], hd_fingerprint)
assert_equal(hd_add, hd_add_2)
connect_nodes(self.nodes[0], 1)
@@ -108,7 +111,10 @@ class WalletHDTest(BitcoinTestFramework):
self.stop_node(1)
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "blocks"))
shutil.rmtree(os.path.join(self.nodes[1].datadir, self.chain, "chainstate"))
- shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat"))
+ shutil.copyfile(
+ os.path.join(self.nodes[1].datadir, "hd.bak"),
+ os.path.join(self.nodes[1].datadir, self.chain, "wallets", "wallet.dat"),
+ )
self.start_node(1, extra_args=self.extra_args[1])
connect_nodes(self.nodes[0], 1)
self.sync_all()
@@ -142,8 +148,9 @@ class WalletHDTest(BitcoinTestFramework):
new_masterkeyid = self.nodes[1].getwalletinfo()['hdseedid']
assert orig_masterkeyid != new_masterkeyid
addr = self.nodes[1].getnewaddress()
- assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/0\'') # Make sure the new address is the first from the keypool
- self.nodes[1].keypoolrefill(1) # Fill keypool with 1 key
+ # Make sure the new address is the first from the keypool
+ assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/0\'')
+ self.nodes[1].keypoolrefill(1) # Fill keypool with 1 key
# Set a new HD seed on node 1 without flushing the keypool
new_seed = self.nodes[0].dumpprivkey(self.nodes[0].getnewaddress())
@@ -153,13 +160,15 @@ class WalletHDTest(BitcoinTestFramework):
assert orig_masterkeyid != new_masterkeyid
addr = self.nodes[1].getnewaddress()
assert_equal(orig_masterkeyid, self.nodes[1].getaddressinfo(addr)['hdseedid'])
- assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/1\'') # Make sure the new address continues previous keypool
+ # Make sure the new address continues previous keypool
+ assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/1\'')
# Check that the next address is from the new seed
self.nodes[1].keypoolrefill(1)
next_addr = self.nodes[1].getnewaddress()
assert_equal(new_masterkeyid, self.nodes[1].getaddressinfo(next_addr)['hdseedid'])
- assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/0\'/0\'/0\'') # Make sure the new address is not from previous keypool
+ # Make sure the new address is not from previous keypool
+ assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/0\'/0\'/0\'')
assert next_addr != addr
# Sethdseed parameter validity
@@ -185,13 +194,13 @@ class WalletHDTest(BitcoinTestFramework):
self.nodes[1].createwallet(wallet_name='restore', blank=True)
restore_rpc = self.nodes[1].get_wallet_rpc('restore')
- restore_rpc.sethdseed(True, seed) # Set to be the same seed as origin_rpc
- restore_rpc.sethdseed(True) # Rotate to a new seed, making original `seed` inactive
+ restore_rpc.sethdseed(True, seed) # Set to be the same seed as origin_rpc
+ restore_rpc.sethdseed(True) # Rotate to a new seed, making original `seed` inactive
self.nodes[1].createwallet(wallet_name='restore2', blank=True)
restore2_rpc = self.nodes[1].get_wallet_rpc('restore2')
- restore2_rpc.sethdseed(True, seed) # Set to be the same seed as origin_rpc
- restore2_rpc.sethdseed(True) # Rotate to a new seed, making original `seed` inactive
+ restore2_rpc.sethdseed(True, seed) # Set to be the same seed as origin_rpc
+ restore2_rpc.sethdseed(True) # Rotate to a new seed, making original `seed` inactive
# Check persistence of inactive seed by reloading restore. restore2 is still loaded to test the case where the wallet is not reloaded
restore_rpc.unloadwallet()
@@ -201,8 +210,8 @@ class WalletHDTest(BitcoinTestFramework):
# Empty origin keypool and get an address that is beyond the initial keypool
origin_rpc.getnewaddress()
origin_rpc.getnewaddress()
- last_addr = origin_rpc.getnewaddress() # Last address of initial keypool
- addr = origin_rpc.getnewaddress() # First address beyond initial keypool
+ last_addr = origin_rpc.getnewaddress() # Last address of initial keypool
+ addr = origin_rpc.getnewaddress() # First address beyond initial keypool
# Check that the restored seed has last_addr but does not have addr
info = restore_rpc.getaddressinfo(last_addr)
@@ -222,6 +231,7 @@ class WalletHDTest(BitcoinTestFramework):
txid = self.nodes[0].sendtoaddress(addr, 1)
origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex'])
self.nodes[0].generate(1)
+ self.sync_blocks()
origin_rpc.gettransaction(txid)
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', restore_rpc.gettransaction, txid)
out_of_kp_txid = txid
@@ -232,6 +242,7 @@ class WalletHDTest(BitcoinTestFramework):
txid = self.nodes[0].sendtoaddress(last_addr, 1)
origin_rpc.sendrawtransaction(self.nodes[0].gettransaction(txid)['hex'])
self.nodes[0].generate(1)
+ self.sync_blocks()
origin_rpc.gettransaction(txid)
restore_rpc.gettransaction(txid)
assert_raises_rpc_error(-5, 'Invalid or non-wallet transaction id', restore_rpc.gettransaction, out_of_kp_txid)
@@ -266,5 +277,6 @@ class WalletHDTest(BitcoinTestFramework):
info = restore2_rpc.getaddressinfo(addr)
assert_equal(info['ismine'], False)
+
if __name__ == '__main__':
- WalletHDTest().main ()
+ WalletHDTest().main()
diff --git a/test/functional/wallet_labels.py b/test/functional/wallet_labels.py
index f8d1720469..fb4a1f9792 100755
--- a/test/functional/wallet_labels.py
+++ b/test/functional/wallet_labels.py
@@ -134,6 +134,33 @@ class WalletLabelsTest(BitcoinTestFramework):
# in the label. This is a no-op.
change_label(node, labels[2].addresses[0], labels[2], labels[2])
+ self.log.info('Check watchonly labels')
+ node.createwallet(wallet_name='watch_only', disable_private_keys=True, descriptors=False)
+ wallet_watch_only = node.get_wallet_rpc('watch_only')
+ BECH32_VALID = {
+ '✔️_VER15_PROG40': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqn2cjv3',
+ '✔️_VER16_PROG03': 'bcrt1sqqqqqjq8pdp',
+ '✔️_VER16_PROB02': 'bcrt1sqqqqqjq8pv',
+ }
+ BECH32_INVALID = {
+ '❌_VER15_PROG41': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzc7xyq',
+ '❌_VER16_PROB01': 'bcrt1sqqpl9r5c',
+ }
+ for l in BECH32_VALID:
+ ad = BECH32_VALID[l]
+ wallet_watch_only.importaddress(label=l, rescan=False, address=ad)
+ node.generatetoaddress(1, ad)
+ assert_equal(wallet_watch_only.getaddressesbylabel(label=l), {ad: {'purpose': 'receive'}})
+ assert_equal(wallet_watch_only.getreceivedbylabel(label=l), 0)
+ for l in BECH32_INVALID:
+ ad = BECH32_INVALID[l]
+ assert_raises_rpc_error(
+ -5,
+ "Invalid Bitcoin address or script",
+ lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad),
+ )
+
+
class Label:
def __init__(self, name):
# Label name
diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py
index b384998d56..3417616d77 100755
--- a/test/functional/wallet_resendwallettransactions.py
+++ b/test/functional/wallet_resendwallettransactions.py
@@ -49,16 +49,21 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
block.solve()
node.submitblock(ToHex(block))
- # Transaction should not be rebroadcast
node.syncwithvalidationinterfacequeue()
- node.p2ps[1].sync_with_ping()
- assert_equal(node.p2ps[1].tx_invs_received[txid], 0)
+ now = int(time.time())
+
+ # Transaction should not be rebroadcast within first 12 hours
+ # Leave 2 mins for buffer
+ twelve_hrs = 12 * 60 * 60
+ two_min = 2 * 60
+ node.setmocktime(now + twelve_hrs - two_min)
+ time.sleep(2) # ensure enough time has passed for rebroadcast attempt to occur
+ assert_equal(txid in node.p2ps[1].get_invs(), False)
self.log.info("Bump time & check that transaction is rebroadcast")
# Transaction should be rebroadcast approximately 24 hours in the future,
# but can range from 12-36. So bump 36 hours to be sure.
- rebroadcast_time = int(time.time()) + 36 * 60 * 60
- node.setmocktime(rebroadcast_time)
+ node.setmocktime(now + 36 * 60 * 60)
wait_until(lambda: node.p2ps[1].tx_invs_received[txid] >= 1, lock=mininode_lock)