6a326cf66f tests: Test that a fully signed tx given to signrawtx is unchanged (Andrew Chow)
2d48d7dcfb Simplify and fix CWallet::SignTransaction (Andrew Chow)
Pull request description:
Backport `CWallet::SignTransaction` from master which is simpler and not broken.
Previously `CWallet::SignTransaction` would return false for a fully signed transaction. This is a regression and obviously incorrect - a fully signed transaction is always complete. This occurs because `CWallet::SignTransaction` would iterate through each input and skip any further checks if the input was already signed. It would then end up falling through to the `return false` catch-all thus erroneously saying a fully signed transaction is incomplete. The change to attempting to use all `ScriptPubKeyMan`s fixes this problem since the `LegacyScriptPubKeyMan` (the only spkm implemented in 0.20) will verify inputs during its signing attempt and correctly return that it is complete when the inputs verify. Thus a fully signed transaction will be correctly identified as complete, `LegacyScriptPubKeyMan::SignTranaction` will return true, and so `CWallet::Transaction` will return true too.
Note that this is not a backport of any specific commit. Rather it is the end result of the changes we have made to this function in master.
Fixes#19737
ACKs for top commit:
fjahr:
Code review ACK 6a326cf66f
MarcoFalke:
re-ACK 6a326cf66f👓
Tree-SHA512: 7b8e04cfc264de01a2de08a99477c1a110fa0965dcbd4305bf4632a165f28b090746789195f5cb584eb6d85e27d4801a09d2dad28e508d7898c7c088e771812b
Tests that a fully signed transaction given to
signrawtransactionwithwallet is both unchanged and marked as complete.
This tests for a regression in 0.20 where the transaction would not be
marked as complete.
Github-Pull: #20562
Rebased-From: 773c42b265
fa074d2c7b Revert "Merge #19606: Backport wtxid relay to v0.20" (MarcoFalke)
Pull request description:
The 0.20 branch has bugfixes that should be released. However, a tag can currently not be created because the latest merge introduced a regression and is not a bugfix (https://github.com/bitcoin/bitcoin/pull/20317#issuecomment-723754509, https://github.com/bitcoin/bitcoin/pull/20317#issuecomment-727624755).
Fix that by reverting the last merge. Can be reviewed by re-doing the revert or calling `git diff HEAD HEAD~2 | wc` and observing an empty diff.
ACKs for top commit:
laanwj:
Code review ACK fa074d2c7b
Tree-SHA512: 1a1314b9bb85f44696dc307845e80292998d6c9c000e7386c48405e74400d9cd22be6996e555f198da917e04024a1c8e609dfd830759a27fe4070168b0d272bb
7566af419f doc: Update data directory path comments (Hennadii Stepanov)
09261de6ed util: Add StripRedundantLastElementsOfPath function (Hennadii Stepanov)
8ef0dace86 macOS deploy: use the new plistlib API (Jonas Schnelli)
314e79581f build: fix mutex detection when building bdb on macOS (fanquake)
1f67a30e83 random: fixes read buffer resizing in RandAddSeedPerfmon (Ethan Heilman)
6113b547f4 net: Send post-verack handshake messages at most once (MarcoFalke)
bdf15d0d5d rpc: Adjust witness-tx deserialize error message (MarcoFalke)
731502a183 rpc: Properly deserialize txs with witness before signing (MarcoFalke)
ee0082b886 Avoid the use of abs64 in timedata (Pieter Wuille)
05bd0c220a docs: Correct description for getblockstats's txs field (Nadav Ivgi)
Pull request description:
Backports the following PRs to the 0.20 branch:
* https://github.com/bitcoin/bitcoin/pull/19777 - docs: Correct description for getblockstats's txs field
* https://github.com/bitcoin/bitcoin/pull/19836 - rpc: Properly deserialize txs with witness before signing
* https://github.com/bitcoin/bitcoin/pull/20080 - Strip any trailing `/` in -datadir and -blocksdir paths
* https://github.com/bitcoin/bitcoin/pull/20082 - [bugfix] random: fixes read buffer to use min rather than max
* https://github.com/bitcoin/bitcoin/pull/20141 - Avoid the use of abs64 in timedata
* https://github.com/bitcoin/bitcoin/pull/20146 - net: Send post-verack handshake messages at most once
* https://github.com/bitcoin/bitcoin/pull/20195 - build: fix mutex detection when building bdb on macOS
* https://github.com/bitcoin/bitcoin/pull/20298 - macOS deploy: use the new plistlib API
Will add additional commits as they become available.
ACKs for top commit:
MarcoFalke:
review ACK 7566af419f 🗡
Tree-SHA512: add6bb978313c12c3e07bc232636ae9d1ab0edd0b816705c5c70eeb1cc04097165fd5e29d60c706886943ceb1f749a422020766b4aa2d23be51e9f839157a4bb
d4a1ee8f1d Further improve comments around recentRejects (Suhas Daftuar)
f082a13ab7 Disconnect peers sending wtxidrelay message after VERACK (Suhas Daftuar)
22effa51a7 test: Use wtxid relay generally in functional tests (Fabian Jahr)
e481681963 test: Add tests for wtxid tx relay in segwit test (Fabian Jahr)
6be398b6fb test: Update test framework p2p protocol version to 70016 (Fabian Jahr)
e364b2a2d8 Rename AddInventoryKnown() to AddKnownTx() (Suhas Daftuar)
879a3cf2c2 Make TX_WITNESS_STRIPPED its own rejection reason (Suhas Daftuar)
c1d6a1003d Delay getdata requests from peers using txid-based relay (Suhas Daftuar)
181ffadd16 Add p2p message "wtxidrelay" (Suhas Daftuar)
93826726e7 ignore non-wtxidrelay compliant invs (Anthony Towns)
2599277e9c Add support for tx-relay via wtxid (Suhas Daftuar)
be1b7a8916 Add wtxids to recentRejects (Suhas Daftuar)
73845211d1 Add wtxids of confirmed transactions to bloom filter (Suhas Daftuar)
606755b840 Add wtxid-index to orphan map (Suhas Daftuar)
3654937674 Add a wtxid-index to mapRelay (Suhas Daftuar)
f7833b5bd8 Just pass a hash to AddInventoryKnown (Suhas Daftuar)
4df3d139b7 Add a wtxid-index to the mempool (Suhas Daftuar)
Pull request description:
We want wtxid relay to be widely deployed before taproot activation, so it should be backported to v0.20.
The main difference from #18044 is removing the changes to the unbroadcast set (which was only added post-v0.20). The rest is mostly minor rebase conflicts (eg connman changed from a pointer to a reference in master, etc).
We'll also want to backport #19569 after that's merged.
ACKs for top commit:
fjahr:
re-ACK d4a1ee8f1d
instagibbs:
reACK d4a1ee8f1d
laanwj:
re-ACK d4a1ee8f1d
hebasto:
re-ACK d4a1ee8f1d, only rebased since my [previous](https://github.com/bitcoin/bitcoin/pull/19606#pullrequestreview-492763028) review:
Tree-SHA512: 1bb8725dd2313a9a03cacf8fb7317986eed3d8d1648fa627528441256c37c793bb0fae6c8c139d05ac45d0c7a86265792834e8e09cbf45286426ca6544c10cd5
Starting with the Clang shipped with Xcode 12, Apple has enabled
-Werror=implicit-function-declaration by default. This causes bdbs mutex
detection to fail when building on macOS (not cross-compiling):
checking for mutexes... UNIX/fcntl
configure: WARNING: NO SHARED LATCH IMPLEMENTATION FOUND FOR THIS PLATFORM.
configure: error: Unable to find a mutex implementation
as previously emitted warnings are being turned into errors. i.e:
error: implicitly declaring library function 'exit' with type 'void (int) __attribute__((noreturn))' [-Werror,-Wimplicit-function-declaration]
Append -Wno-error=implicit-function-declaration to cflags so that
-Wimplicit-function-declaration returns to being a warning, and the
configure checks will succeed.
Fixes#19411.
Github-Pull: #20195
Rebased-From: d0a829e963
+ Replaces std::max with std::min to resize buffer in RandAddSeedPerfmon
+ Documents behavior of RandAddSeedPerfmon
Github-Pull: #20082
Rebased-From: bd5215103e
3562c15be3 build: set minimum required Boost to 1.48.0 (fanquake)
Pull request description:
Due to the use of [`boost::filesystem::canonical()`](80aa83aa40/src/wallet/load.cpp (L21)), the minimum required
version of Boost is actually 1.48.0. Use of canonical was introduced
in #14146.
See also [Boost filesystem 1.48.0 release notes](6b5e38134a/doc/release_history.html (L508)). Also discussed in #20080.
ACKs for top commit:
practicalswift:
ACK 3562c15be3: correct is better than incorrect :)
hebasto:
ACK 3562c15be3, this is the status quo.
Tree-SHA512: 1d2226c60accb8e2276e023120a72f070392a6c1d3db97fb23e7759c174984226f81fed6d94f3203ef663fb4b3648e65960aaf15ed718895b6673e3ebeb082bd
Due to the use of boost::filesystem::canonical(), the minimum required
version of Boost is actually 1.48.0. Use of canonical was introduced
in #14146.
See also Boost filesystem 1.48.0 release notes:
6b5e38134a/doc/release_history.html (L508)
Previously, TX_WITNESS_MUTATED could be returned during transaction validation
for either transactions that had a witness that was non-standard, or for
transactions that had no witness but were invalid due to segwit validation
rules.
However, for txid/wtxid-relay considerations, net_processing distinguishes the
witness stripped case separately, because it affects whether a wtxid should be
able to be added to the reject filter. It is safe to add the wtxid of a
witness-mutated transaction to the filter (as that wtxid shouldn't collide with
the txid, and hence it wouldn't interfere with transaction relay from
txid-relay peers), but it is not safe to add the wtxid (== txid) of a
witness-stripped transaction to the filter, because that would interfere with
relay of another transaction with the same txid (but different wtxid) when
relaying from txid-relay peers.
Also updates the comment explaining this logic, and explaining that we can get
rid of this complexity once there's a sufficient deployment of wtxid-relaying
peers on the network.
Using both txid and wtxid-based relay with peers means that we could sometimes
download the same transaction twice, if announced via two different hashes from
different peers.
Use a heuristic of delaying txid-peer-getdata requests by 2 seconds, if we have
at least one wtxid-based peer.
This adds a field to CNodeState that tracks whether to relay transactions with
that peer via wtxid, instead of txid. As of this commit the field will always
be false, but in a later commit we will add a way to negotiate turning this on
via p2p messages exchanged with the peer.
Previously, we only added txids to recentRejects if we were sure that the
transaction couldn't have had the wrong witness (either because the witness was
malleated or stripped).
In preparation for wtxid-based relay, we can observe that txid == wtxid for
transactions that have no witness, and add the wtxid of rejected transactions,
provided the transaction wasn't a witness-stripped one. This means that we now
add more data to the filter (as prior to this commit, any transaction with a
witness that failed to be accepted was being skipped for inclusion in the
filter) but witness malleation should still not interfere with relay of a valid
segwit transaction, because the txid of a segwit transaction would not be added
to the filter after failing validation.
In the future, having wtxids in the recent rejects filter will allow us to
skip downloading the same wtxid multiple times, once our peers use wtxids for
transaction relay.
Also add the txid to recentRejects if the transaction failed for
TX_INPUTS_NOT_STANDARD.
This is in preparation for wtxid-based invs (we need to be able to tell whether
we AlreadyHave() a transaction based on either txid or wtxid).
This also double the size of the bloom filter, which is overkill, but still
uses a manageable amount of memory.
498b7cb6f3 Update the vcpkg checkout commit ID in appveyor config. (Aaron Clauson)
ad99777b57 Set appveyor vm version to previous Visual Studio 2019 release. (Aaron Clauson)
Pull request description:
Required for appveyor builds to succeed for other v0.20 backports. For example #19606 fails to build on appveyor without these commits, and succeeds with them.
The first commit is actually reversed by the second commit (which also changes `VCPKG_COMMIT_ID`), but I'm backporting them both so that they're clean cherrypicks.
ACKs for top commit:
laanwj:
ACK 498b7cb6f3
Tree-SHA512: 723a834fd86c8b5f58e71b9f1abfa8b3ad67376fab8e7d3699330142a6fde98547209b2b5fa6fdf9b934a447b29bf866e2258d0c303cec1062401e924e83f297
Our policy checks for non-standard inputs depend only on the non-witness
portion of a transaction: we look up the scriptPubKey of the input being
spent from our UTXO set (which is covered by the input txid), and the p2sh
checks only rely on the scriptSig portion of the input.
Consequently it's safe to add txids of transactions that fail these checks to
the reject filter, as the witness is irrelevant to the failure. This is helpful
for any situation where we might request the transaction again via txid (either
from txid-relay peers, or if we might fetch the transaction via txid due to
parent-fetching of orphans).
Further, in preparation for future witness versions being deployed on the
network, ensure that WITNESS_UNKNOWN transactions are rejected in
AreInputsStandard(), so that transactions spending v1 (or greater) witness
outputs will fall into this category of having their txid added to the reject
filter.
Github-Pull: #19620
Rebased-From: 7989901c7e
7c1c15329e doc: Update 0.20.1 release notes with psbt changes (Andrew Chow)
Pull request description:
#19215 was missing from the list. Also felt it was important to mention this change.
Top commit has no ACKs.
Tree-SHA512: b795cf73954ff493747a793039918a5e19c377d9325e6156a8e23ba8f510af12f48b2d63854f57d482640531a865190f1fe1ece0c78a5e45d6926f9533c6d695
7ee4769cd4 [0.20] lint: fix shellcheck URL in CI install (fanquake)
Pull request description:
This is causing the tests to fail for backports i.e #19606. If you look in the Travis logs there, the output is:
```bash
You are downloading ShellCheck from an outdated URL!
Please update to the new URL:
https://github.com/koalaman/shellcheck/releases/download/v0.6.0/shellcheck-v0.6.0.linux.x86_64.tar.xz
For more information, see:
https://github.com/koalaman/shellcheck/issues/1871
PS: Sorry for breaking your build. The hosting costs were getting out of hand :(
```
ACKs for top commit:
MarcoFalke:
review ACK 7ee4769cd4
Tree-SHA512: 62470291e53954ab541a7109e530390410d9b8a4d3ed6f4128ab8807d2225f368b8c984342f92de802a60dd082292cb59557599b4112413a29fc9ad8e8bcd0ee