Commit Graph

3708 Commits

Author SHA1 Message Date
S3RK
bf68ebc1cd wallet: allow to import same descriptor twice 2021-06-28 21:37:37 +02:00
Sebastian Falbesoner
b57b633b94 test: use script_util helpers for creating P2PKH scripts 2021-06-28 20:14:07 +02:00
Sebastian Falbesoner
61b6a017a9 test: wallet util: fix multisig P2SH-P2WSH script creation 2021-06-28 20:14:01 +02:00
MarcoFalke
3f56ef7bef
Merge bitcoin/bitcoin#22146: Reject invalid coin height and output index when loading assumeutxo
fa9ebedec3 Reject invalid coin height and output index when loading assumeutxo (MarcoFalke)

Pull request description:

  It should be impossible to have a coin at a height higher than the height of the snapshot block, so reject those early to avoid integer wraparounds and hash collisions later on.

  Same for the outpoint index.

  Both issues were found by fuzzing:

  * The height issue by OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34793
  * The outpoint issue by my fuzz server: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34793#c2

ACKs for top commit:
  practicalswift:
    cr ACK fa9ebedec3: patch looks correct
  jamesob:
    crACK fa9ebedec3
  theStack:
    Code review ACK fa9ebedec3
  benthecarman:
    crACK fa9ebedec3

Tree-SHA512: dae7caee4b3862b23ebdf2acb7edec4baf75b0dbf1409b370b1a73aa6b632b317ebfac596dcbaf4edfb1301b513f45465ea75328962460f35e2af0d7e547c9ac
2021-06-28 16:11:44 +02:00
Andrew Chow
e6cf0ed92d wallet, rpc: listdescriptors does not need unlocked
With the last hardened xpub cache, we don't neeed to have the wallet be
unlocked for listdescriptors.
2021-06-24 14:08:46 -04:00
W. J. van der Laan
0553d75268
Merge bitcoin/bitcoin#22154: Add OutputType::BECH32M and related wallet support for fetching bech32m addresses
754f134a50 wallet: Add error message to GetReservedDestination (Andrew Chow)
87a0e7a3b7 Disallow bech32m addresses for legacy wallet things (Andrew Chow)
6dbe4d1072 Use BECH32M for tr() desc, WitV1Taproot, and WitUnknown CTxDests (Andrew Chow)
699dfcd8ad Opportunistically use bech32m change addresses if available (Andrew Chow)
0262536c34 Add OutputType::BECH32M (Andrew Chow)
177c15d2f7 Limit LegacyScriptPubKeyMan address types (Andrew Chow)

Pull request description:

  Currently bech32m addresses are classfied as bech32. Because bech32m is incompatible with bech32, we need to define a new `OutputType` for it so that it can be handled correctly. This PR adds `OutputType::BECH32M`, updates all of the relevant `OutputType` classifications, and handle requests for bech32m addresses. There is now a `bech32m` address type string that can be used.

  * `tr()` descriptors now report their output type as `OutputType::BECH32M`. `WtinessV1Taproot` and `WitnessUnknown` are also classified as `OutputType::BECH32M`.
  * Bech32m addresses are completely disabled for legacy wallets. They cannot be imported (explicitly disallowed in `importaddress` and `importmulti`), will not be created when getting all destinations for a pubkey, and will not be added with `addmultisigaddress`. Additional protections have been added to `LegacyScriptPubKeyMan` to disallow attempting to retrieve bech32m addresses.
  * Since Taproot multisigs are not implemented yet, `createmultisig` will also disallow the bech32m address type.
  * As Taproot is not yet active, `DescriptorScriptPubKeyMan` cannot and will not create a `tr()` descriptor. Protections have been added to make sure this cannot occur.
  * The change address type detection algorithm has been updated to return `bech32m` when there is a segwit v1+ output script and the wallet has a bech32m `ScriptPubKeyMan`, falling back to bech32 if one is not available.

ACKs for top commit:
  laanwj:
    re-review ACK 754f134a50
  Sjors:
    re-utACK 754f134: only change is switching to `bech32m` in two `wallet_taproot.py` test cases.
  fjahr:
    re-ACK 754f134a50
  jonatack:
    ACK 754f134a50

Tree-SHA512: 6ea90867d3631d0d438e2b08ce6ed930f37d01323224661e8e38f183ea5ee2ab65b5891394a3612c7382a1aff907b457616c6725665a10c320174017b998ca9f
2021-06-24 14:20:28 +02:00
MarcoFalke
e59ea87954
Merge bitcoin/bitcoin#22311: test: Add missing syncwithvalidationinterfacequeue in p2p_blockfilters
fadddd13ee test: Add missing syncwithvalidationinterfacequeue (MarcoFalke)
faa211fc6e test: Misc cleanup (MarcoFalke)
fa1668bf50 test: Run pep-8 (MarcoFalke)
facd97ae0f scripted-diff: Renames (MarcoFalke)

Pull request description:

  The index on the block filters is running in the background on the validation interface. To avoid intermittent test failures, it needs to be synced.

  Also other cleanups.

ACKs for top commit:
  lsilva01:
    Tested ACK fadddd13ee on Ubuntu 20.04

Tree-SHA512: d858405db426a2f9d5620059dd88bcead4e3fba3ccc6bd8023f624b768fbcfa2203246fb0b2db620490321730d990f0e78063b21a26988c969cb126d4bd697bd
2021-06-24 12:54:00 +02:00
MarcoFalke
d6a59166a1
Merge bitcoin/bitcoin#22257: test: refactor: various (de)serialization helpers cleanups/improvements
bdb8b9a347 test: doc: improve doc for `from_hex` helper (mention `to_hex` alternative) (Sebastian Falbesoner)
1914054208 scripted-diff: test: rename `FromHex` to `from_hex` (Sebastian Falbesoner)
a79396fe5f test: remove `ToHex` helper, use .serialize().hex() instead (Sebastian Falbesoner)
2ce7b47958 test: introduce `tx_from_hex` helper for tx deserialization (Sebastian Falbesoner)

Pull request description:

  There are still many functional tests that perform conversions from a hex-string to a message object (deserialization) manually. This PR identifies all those instances and replaces them with a newly introduced helper `tx_from_hex`.

  Instances were found via
  * `git grep "deserialize.*BytesIO"`

  and some of them manually, when it were not one-liners.

  Further, the helper `ToHex` was removed and simply replaced by `.serialize().hex()`, since now both variants are in use (sometimes even within the same test) and using the helper doesn't really have an advantage in readability. (see discussion https://github.com/bitcoin/bitcoin/pull/22257#discussion_r652404782)

ACKs for top commit:
  MarcoFalke:
    review re-ACK bdb8b9a347 😁

Tree-SHA512: e25d7dc85918de1d6755a5cea65471b07a743204c20ad1c2f71ff07ef48cc1b9ad3fe5f515c1efaba2b2e3d89384e7980380c5d81895f9826e2046808cd3266e
2021-06-24 12:47:13 +02:00
MarcoFalke
bfa885898a
Merge bitcoin/bitcoin#22306: [test] Improvements to p2p_addr_relay.py
6168eb06b2 [test] Prevent intermittent issue (Amiti Uttarwar)
1d8193e2a2 [test] Remove GetAddrStore class (Amiti Uttarwar)
ef2f149bf2 [test] Update GetAddrStore callers to use AddrReceiver (Amiti Uttarwar)
e8c67ea19a [test] Add functionality to AddrReceiver (Amiti Uttarwar)
09dc073cff [test] Allow AddrReceiver to be used more generally (Amiti Uttarwar)

Pull request description:

  A test refactor broken out from #21528 & a fix to #22243.

  This PR:
  1. consolidates the two helper classes into one, with the intent of making the test logic more clear & usable as we add more subtests to the file

  2. hopefully fixes the test flakiness by bumping up the mocktime interval to ensure `m_next_addr_send` timer triggers

ACKs for top commit:
  mzumsande:
    Code-Review ACK 6168eb06b2
  lsilva01:
    Tested ACK 6168eb06b2 on Ubuntu 20.04
  brunoerg:
    tACK 6168eb06b2

Tree-SHA512: 248324f9d37e0e5ffe4acc437cd72ad9a2960abc868a97c6040a36e6ea8b59029127ac4f63fcf67d981a5bb4dbf2334bb2c23c541fae8e910d5523884bcedcba
2021-06-24 12:10:44 +02:00
MarcoFalke
a196c89317
Merge bitcoin/bitcoin#22270: test: Add bitcoin-util tests (+refactors)
fa4017e7a0 refactor: Pass grind args vector as const reference (MarcoFalke)
fa08bc288f Remove gArgs from AppInitUtil (MarcoFalke)
fa751a47ff Remove unused OptionsCategory arg from AddCommand (MarcoFalke)
fa3c1eee7f Remove unused includes from bitcoin-util (MarcoFalke)
fa304929e2 test: Add bitcoin-util tests (MarcoFalke)
fa831e709a build_msvc: Add bitcoin-util.exe (MarcoFalke)

Pull request description:

  bitcoin-util has no tests

  See https://marcofalke.github.io/btc_cov/total.coverage/src/bitcoin-util.cpp.gcov.html (Coverage report showing 0%)

ACKs for top commit:
  klementtan:
    Code review and tested ACK fa4017e7a0
  theStack:
    Tested ACK fa4017e7a0
  jamesob:
    reACK fa4017e7a0 ([`jamesob/ackr/22270.1.MarcoFalke.test_add_bitcoin_util_te`](https://github.com/jamesob/bitcoin/tree/ackr/22270.1.MarcoFalke.test_add_bitcoin_util_te))

Tree-SHA512: 68e2791239bc48d28fbb6394155c39ea0357a96ec7e4896ca579feeef1a803657165a0ef9fa3cf6e2a381e5b0ca0dafa1b594158303a04997db784201d8dd66d
2021-06-24 09:42:07 +02:00
Jon Atack
184d4534f6
script, doc: spelling update 2021-06-23 13:33:18 +02:00
Samuel Dobson
567670bec5
Merge bitcoin/bitcoin#22166: Add support for inferring tr() descriptors
d637a9b397 Taproot descriptor inference (Pieter Wuille)
c7388e5ada Report address as solvable based on inferred descriptor (Pieter Wuille)
29e5dd1a5b consensus refactor: extract ComputeTapleafHash, ComputeTaprootMerkleRoot (Pieter Wuille)

Pull request description:

  Includes:
  * First commit from #21365, adding TaprootSpendData in SigningProvider
  * A refactor to expose ComputeTapleafHash and ComputeTaprootMerkleRoot from script/interpreter
  * A tiny change to make `getaddressinfo` report tr() descriptors as solvable (so that inferred descriptors are shown), despite not having signing code for them.
  * Logic to infer the script tree back from TaprootSpendData, and then use that to infer descriptors.

ACKs for top commit:
  achow101:
    re-ACK d637a9b397
  Sjors:
    re-utACK d637a9b
  meshcollider:
    Code review ACK d637a9b397

Tree-SHA512: 5ab9b95da662382d8549004be4a1297a577d7caca6b068f875c7c9343723931d03fa9cbf133de11f83b74e4851490ce820fb80413c77b9e8495a5f812e505d86
2021-06-23 22:42:30 +12:00
MarcoFalke
d6e0d78c31
Merge bitcoin/bitcoin#20966: banman: save the banlist in a JSON format on disk
bb719a08db style: remove () from assert in rpc_setban.py (Vasil Dimov)
24b10ebda3 doc: fix grammar in doc/files.md (Vasil Dimov)
dd4e957dcd test: ensure banlist can be read from disk after restart (Vasil Dimov)
d197977ae2 banman: save the banlist in a JSON format on disk (Vasil Dimov)

Pull request description:

  Save the banlist in `banlist.json` instead of `banlist.dat`.

  This makes it possible to store Tor v3 entries in the banlist on disk
  (and any other addresses that cannot be serialized in addrv1 format).

  Only read `banlist.dat` if it exists and `banlist.json` does not exist (first start after an upgrade).

  Supersedes https://github.com/bitcoin/bitcoin/pull/20904
  Resolves https://github.com/bitcoin/bitcoin/issues/19748

ACKs for top commit:
  jonatack:
    Code review re-ACK bb719a08db per `git range-diff 6a67366 4b52c72 bb719a0`
  achow101:
    Code Review ACK bb719a08db

Tree-SHA512: fc135c3a1fe20bcf5d008ce6bea251b4135e56c78bf8f750b4bd8144c095b81ffe165133cdc7e4715875eec7e7c4e13ad9f5d2450b21102af063d7c8abf716b6
2021-06-23 10:01:56 +02:00
MarcoFalke
03aa59a4e5
Merge bitcoin/bitcoin#22313: test: Add missing sync_all to feature_coinstatsindex
fafd9165e9 test: Add missing sync_all to feature_coinstatsindex (MarcoFalke)

Pull request description:

  Sync the blocks before invalidating them to ensure all nodes are on the right tip. Otherwise nodes[0] might stay on the "stale" block and the test fails (intermittently)

ACKs for top commit:
  jamesob:
    crACK fafd9165e9

Tree-SHA512: ca567b97b839b56c91d52831eaac18d8c843d376be90c9fd8b49d2eb4a46b801a1d2402996d5dfe2bef3e2c9bd75d19ed443e3f42cc4679c5f20043ba556efc8
2021-06-23 08:07:19 +02:00
Andrew Chow
754f134a50 wallet: Add error message to GetReservedDestination
Adds an error output parameter to all GetReservedDestination functions
so that callers can get the actual reason that a change address could
not be fetched. This more closely matches GetNewDestination. This allows
for more granular error messages, such as one that indicates that
bech32m addresses cannot be generated yet.
2021-06-22 21:57:04 -04:00
Andrew Chow
87a0e7a3b7 Disallow bech32m addresses for legacy wallet things
We don't want the legacy wallet to ever have bech32m addresses so don't
allow importing them. This includes addmultisigaddress as that is a
legacy wallet only RPC

Additionally, bech32m multisigs are not available yet, so disallow them
in createmultisig.
2021-06-22 21:57:04 -04:00
Andrew Chow
6dbe4d1072 Use BECH32M for tr() desc, WitV1Taproot, and WitUnknown CTxDests
The tr() descriptor, WitnessV1Taproot CTxDestination, and
WitnessUnknown CTxDestination are OutputType::BECH32M so they should
report as such.
2021-06-22 21:57:04 -04:00
MarcoFalke
fafd9165e9
test: Add missing sync_all to feature_coinstatsindex 2021-06-22 20:10:33 +02:00
MarcoFalke
fadddd13ee
test: Add missing syncwithvalidationinterfacequeue 2021-06-22 19:42:51 +02:00
MarcoFalke
faa211fc6e
test: Misc cleanup
* Replace wait_until with assert_equal where possible
* Use send_and_ping helper where possible
2021-06-22 19:42:35 +02:00
MarcoFalke
fa1668bf50
test: Run pep-8
Can be reviewed with --word-diff-regex=.
2021-06-22 19:42:25 +02:00
MarcoFalke
facd97ae0f
scripted-diff: Renames
-BEGIN VERIFY SCRIPT-

 ren() { sed -i "s/\<$1\>/$2/g" test/functional/p2p_blockfilters.py ; }

 # Rename from "node" to "peer" to avoid confusion with self.nodes
 ren node0 peer_0
 ren node1 peer_1

 # Remove the confusing "C" prefix
 ren CFiltersClient FiltersClient

-END VERIFY SCRIPT-
2021-06-22 19:41:28 +02:00
MarcoFalke
fa27baa9c8
Revert "test: Add temporary logging to debug #20975"
This reverts commit faa94961d6.
2021-06-22 10:04:06 +02:00
MarcoFalke
672870ab7b
Merge bitcoin/bitcoin#22201: test: Fix TestShell to allow running in Jupyter Notebook
168b6c317c add dummy file param to fix jupyter (Josiah Baker)

Pull request description:

  this fixes argparse to use `parse_known_args`. previously, if an unknown argument was passed, argparse would fail with an `unrecognized arguments: %s` error.

  ## why
  the documentation mentions being able to run `TestShell` in a REPL interpreter or a jupyter notebook. when i tried to run inside a jupyter notebook, i got the following error:

  ![image](https://user-images.githubusercontent.com/7444140/121382910-57554880-c947-11eb-94f2-49da8679528c.png)

  this was due to the notebook passing the filename of the notebook as an argument. this is a known problem with notebooks and argparse, documented here: https://stackoverflow.com/questions/48796169/how-to-fix-ipykernel-launcher-py-error-unrecognized-arguments-in-jupyter

  ## testing
  to test, make sure you have jupyter notebooks installed. you can do this by running:
  ```
  pip install notebook
  ```
  or following instructions from [here](https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html).

  once installed, start a notebook (`jupyter notebook`), launch a python3 kernel and run the following snippet:

  ```python
  import sys

  # make sure this is the path for your system
  sys.path.insert(0, "/path/to/bitcoin/test/functional")
  from test_framework.test_shell import TestShell

  test = TestShell().setup(num_nodes=2, setup_clean_chain=True)
  ```

  you should see the following output, without errors:
  ![image](https://user-images.githubusercontent.com/7444140/121383301-a307f200-c947-11eb-83b6-6c50b2cada25.png)

  if you are unfamiliar with notebooks, here is a short guide on using them: https://jupyter.readthedocs.io/en/latest/running.html

ACKs for top commit:
  MarcoFalke:
    review ACK 168b6c317c
  jamesob:
    crACK 168b6c317c
  practicalswift:
    cr ACK 168b6c317c

Tree-SHA512: 4fee1563bf64a1cf9009934182412446cde03badf2f19553b78ad2cb3ceb0e5e085a5db41ed440473494ac047f04641311ecbba3948761c6553d0ca4b54937b4
2021-06-22 08:11:16 +02:00
Amiti Uttarwar
6168eb06b2 [test] Prevent intermittent issue
Since m_next_addr_send is on a Poisson distribution, increase the mocktime bump
to ensure we don't experience flakiness in the tests. Closes #22243.
2021-06-21 18:05:54 -07:00
Amiti Uttarwar
1d8193e2a2 [test] Remove GetAddrStore class 2021-06-21 18:05:48 -07:00
Amiti Uttarwar
ef2f149bf2 [test] Update GetAddrStore callers to use AddrReceiver 2021-06-21 18:05:43 -07:00
Amiti Uttarwar
e8c67ea19a [test] Add functionality to AddrReceiver
Add two simple helper functions to `AddrReceiver` to support callers currently
using `GetAddrStore` [used in next commit].
2021-06-21 18:05:27 -07:00
Amiti Uttarwar
09dc073cff [test] Allow AddrReceiver to be used more generally
The `on_addr` functionality of `AddrReceiver` tests logic specific to how the
addr messages are set up in the test bodies. To allow other callers to also use
`AddrReceiver`, only apply the assertion logic if the caller indicates
desirability by setting `test_addr_contents` to true when initializing the
class.
2021-06-21 10:25:06 -07:00
Josiah Baker
168b6c317c add dummy file param to fix jupyter
testshell in jupyter was failing due to an extra arg.
this adds a dummy -f param, which allows TestShell to
be used in a command line or jupyter environment
2021-06-21 17:12:16 +02:00
MarcoFalke
74013641e0
Merge bitcoin/bitcoin#22089: test: MiniWallet: fix fee calculation for P2PK and check tx vsize
d6d2ab9845 test: MiniWallet: fix fee calculation for P2PK and check tx vsize (Sebastian Falbesoner)
ce024b1c0e test: MiniWallet: force P2PK signature to have fixed size (71 bytes) (Sebastian Falbesoner)

Pull request description:

  This PR is a follow-up to #21945. It aims to both fix the fee calculation for P2PK mode transactions and enable its vsize check. Currently, the latter assumes a fixed tx length, which is fine for anyone-can-spend txs but doesn't apply to P2PK output spends due to varying DER signature size; the vsize check is therefore disabled for P2PK mode on master branch.

  Creating one million DER signatures with MiniWallet shows the following distribution of sizes (smart people with better math skills probably could deduce the ratios without trying, but hey):

  | DER signature size [bytes]  | #occurences (ratio) |
  | ------------- | ------------- |
  | 71  | 498893 (49.89%) |
  | 70 | 497244 (49.72%) |
  | 69 | 3837 (0.38%) |
  | 68 | 22 (0.0022%) |

  Note that even smaller signatures are possible (for smaller R and S values with leading zero bytes), it's just that the probability decreases exponentially.     Instead of choosing a large vsize check range and hoping that smaller signatures are never created (potentially leading to flaky tests), the proposed solution is ~~to limit the signature size to the two most common sizes 71 and 70 (>99.6% probability) and then accordingly only check for two vsize values; the value to be used for fee calculation is a decimal right between the two possible sizes (167.5 vbytes) and for the vsize check it's rounded down/up integer values are used.~~ to simply grind the signature to a fixed size of 71 bytes (49.89% probability, i.e. on average each call to `sign_tx()`, on average two ECC signing operations are needed).

  ~~The idea of grinding signatures to a fixed size (similar to https://github.com/bitcoin/bitcoin/pull/13666 which grinds to low-R values) would be counter-productive, as the signature creation in the test suite is quite expensive and this would significantly slow down tests that calculate hundreds of signatures (like e.g. feature_csv_activation.py).~~

  For more about transaction sizes on different input/output types, see the following interesting article: https://medium.com/coinmonks/on-bitcoin-transaction-sizes-97e31bc9d816

ACKs for top commit:
  MarcoFalke:
    Concept ACK d6d2ab9845

Tree-SHA512: 011c70ee0e4adf9ba12902e4b6c411db9ae96bdd8bc810bf1d67713367998e28ea328394503371fc1f5087a819547ddaea56c073b28db893ae1c0031d7927f32
2021-06-21 16:11:13 +02:00
W. J. van der Laan
6556da77d7
Merge bitcoin/bitcoin#21056: rpc: Add a -rpcwaittimeout parameter to limit time spent waiting
b9e76f1bf0 rpc: Add test for -rpcwaittimeout (Christian Decker)
f76cb10d7d rpc: Prefix rpcwaittimeout error with details on its nature (Christian Decker)
c490e17ef6 doc: Add release notes for the `-rpcwaittimeout` cli parameter (Christian Decker)
a7fcc8eb59 rpc: Add a `-rpcwaittimeout` parameter to limit time spent waiting (Christian Decker)

Pull request description:

  Adds a new numeric `-rpcwaittimeout` that can be used to limit the
  time we spend waiting on the RPC server to appear. This is used by
  downstream projects to provide a bit of slack when `bitcoind`s RPC
  interface is not available right away.

  This makes the `-rpcwait` argument more useful, since we can now limit
  how long we'll ultimately wait, before potentially giving up and reporting
  an error to the caller. It was discussed in the context of the BTCPayServer
  wanting to have c-lightning wait for the RPC interface to become available
  but still have the option of giving up eventually ([4355]).

  I checked with laanwj whether this is already possible ([comment]), and
  whether this would be a welcome change. Initially I intended to repurpose
  the (optional) argument to `-rpcwait`, however I decided against it since it
  would potentially break existing configurations, using things like `rpcwait=1`,
  or `rpcwait=true` (the former would have an unintended short timeout, when
  old behavior was to wait indefinitely).

  ~Due to its simplicity I didn't implement a test for it yet, but if that's desired I
  can provide one.~ Test was added during reviews.

  [4355]: https://github.com/ElementsProject/lightning/issues/4355
  [comment]: https://github.com/ElementsProject/lightning/issues/4355#issuecomment-768288261

ACKs for top commit:
  laanwj:
    Code review ACK b9e76f1bf0
  promag:
    ACK b9e76f1bf0.

Tree-SHA512: 3cd6728038ec7ca7c35c2e7ccb213bfbe963f99a49bb48bbc1e511c4dd23d9957c04f9af1f8ec57120e47b26eaf580b46817b099d5fc5083c98da7aa92db8638
2021-06-21 15:54:56 +02:00
Vasil Dimov
bb719a08db
style: remove () from assert in rpc_setban.py 2021-06-21 15:29:28 +02:00
Vasil Dimov
dd4e957dcd
test: ensure banlist can be read from disk after restart
With `banlist.dat` (being written in addrv1 format) if we would try to
write a Tor v3 subnet, it would serialize as a dummy-all-0s IPv6
address and subsequently, when deserialized will not result in the same
subnet.

This problem does not exist with `banlist.json` where the data is saved
in textual, human-readable form.
2021-06-21 15:27:03 +02:00
Sebastian Falbesoner
bdb8b9a347 test: doc: improve doc for from_hex helper (mention to_hex alternative) 2021-06-21 14:36:02 +02:00
Sebastian Falbesoner
1914054208 scripted-diff: test: rename FromHex to from_hex
-BEGIN VERIFY SCRIPT-
sed -i 's/\<FromHex\>/from_hex/g' $(git grep -l FromHex)
-END VERIFY SCRIPT-

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2021-06-21 14:33:59 +02:00
Sebastian Falbesoner
a79396fe5f test: remove ToHex helper, use .serialize().hex() instead 2021-06-21 14:30:03 +02:00
Sebastian Falbesoner
2ce7b47958 test: introduce tx_from_hex helper for tx deserialization
`FromHex` is mostly used for transactions, so we introduce a
shortcut `tx_from_hex` for `FromHex(CTransaction, hex_str)`.
2021-06-21 14:28:05 +02:00
W. J. van der Laan
f6a25bea82
Merge bitcoin/bitcoin#22147: p2p: Protect last outbound HB compact block peer
30aee2dfe6 tests: Add test for compact block HB selection (Pieter Wuille)
6efbcec4de Protect last outbound HB compact block peer (Suhas Daftuar)

Pull request description:

  If all our high-bandwidth compact block serving peers (BIP 152) stall block
  download, then we can be denied a block for (potentially) a long time. As
  inbound connections are much more likely to be adversarial than outbound
  connections, mitigate this risk by never removing our last outbound HB peer if
  it would be replaced by an inbound.

ACKs for top commit:
  achow101:
    ACK 30aee2dfe6
  ariard:
    Code ACK 30aee2dfe
  jonatack:
    ACK 30aee2dfe6

Tree-SHA512: 5c6c9326e3667b97e0864c371ae2174d2be9054dad479f4366127b9cd3ac60ffa01ec9707b16ef29cac122db6916cf56fd9985733390017134ace483278921d5
2021-06-21 08:18:55 +02:00
MarcoFalke
e172ea8804
Merge bitcoin/bitcoin#22210: test: Use MiniWallet in test_no_inherited_signaling RBF test
fa7d71f270 test: Run pep-8 on touched test (MarcoFalke)
fab7e99c2a test: Use MiniWallet in test_no_inherited_signaling RBF test (MarcoFalke)
fab871f649 test: Remove unused generate() from test (MarcoFalke)
faff3f35b7 test: Add txin.sequence option to MiniWallet (MarcoFalke)

Pull request description:

  This comes with nice benefits:
  * Less code and complexity
  * Test can be run without wallet compiled in

  Also add some additional checks for `getmempoolentry` (#22209) and other cleanups 🎨

ACKs for top commit:
  mjdietzx:
    Tested ACK fa7d71f270 thanks for the explanations, nicely done
  theStack:
    ACK fa7d71f270 🍷

Tree-SHA512: 0e9b8fe985779d8d7034d256deed627125bb374b6ae2972c461b3a220739a51061c6147ad69339bee16282f82716c7f3f8a7a89c693ceb1e47ea50709272332a
2021-06-19 08:47:52 +02:00
Pieter Wuille
d637a9b397 Taproot descriptor inference 2021-06-18 11:28:47 -07:00
MarcoFalke
fa304929e2
test: Add bitcoin-util tests 2021-06-18 20:08:45 +02:00
MarcoFalke
da1e6d5911
Merge bitcoin/bitcoin#14604: tests: Add test and refactor feature_block.py
55311197c4 Added new test for future blocks reacceptance (sanket1729)
511a5af462 Fixed inconsistencies between code and comments (sanket1729)

Pull request description:

  This Commit does 3 things:
  1) Adds a test case for checking reacceptance a previously rejected block which
  was too far in the future.
  ~~2) clean up uses of rehash or calc_sha256 where it was not needed~~
  3) While constructing block 44, this commit makes the code consistent with the expected figure in
  the comment just above it by adding a transaction to the block.
  4) Fix comment describing `sign_tx()` function

ACKs for top commit:
  duncandean:
    reACK 5531119
  brunoerg:
    reACK 55311197c4

Tree-SHA512: d40c72fcdbb0b2a0715adc58441eeea08147ee2ec5e371a4ccc824ebfdc6450698bd40aaeecb7ea7bfdb3cd1b264dd821b890276fff8b8d89b7225cdd9d6b546
2021-06-18 18:08:49 +02:00
MarcoFalke
0844084c13
Merge bitcoin/bitcoin#22249: test: kill process group to avoid dangling processes when using --failfast
451b96f7d2 test: kill process group to avoid dangling processes (S3RK)

Pull request description:

  This is an alternative to #19281

  This PR fixes a problem when after test failure with `--failfast` option there could be dangling nodes. The nodes will continue to occupy rpc/p2p ports on the machine and will cause further test failures.

  If there are any dangling nodes left at the end of the test run we kill the whole process group.
  Pros: the operations is immediate and won't lead to CI timeout
  Cons: the test_runner process is also killed and exit code is 137

  Example output:
  ```
  ...
  Early exiting after test failure

  TEST                           | STATUS    | DURATION

  rpc_decodescript.py            | ✓ Passed  | 2 s
  rpc_deprecated.py              | ✓ Passed  | 2 s
  rpc_deriveaddresses.py         | ✓ Passed  | 2 s
  rpc_dumptxoutset.py            | ✖ Failed  | 2 s

  ALL                            | ✖ Failed  | 8 s (accumulated)
  Runtime: 4 s

  Killed: 9
  > echo $?
  137
  ```

ACKs for top commit:
  MarcoFalke:
    review ACK 451b96f7d2
  aitorjs:
    ACK 451b96f7d2. Manual testing with and without **--failfast**.

Tree-SHA512: 87e510a1411b9e7571e63cf7ffc8b9a8935daf9112ffc0f069d6c406ba87743ec439808181f7e13cb97bb200fad528589786c47f0b43cf3a2ef0d06a23cb86dd
2021-06-18 14:22:51 +02:00
Samuel Dobson
5c2e2afe99
Merge bitcoin/bitcoin#21365: Basic Taproot signing support for descriptor wallets
458a345b05 Add support for SIGHASH_DEFAULT in RPCs, and make it default (Pieter Wuille)
c0f0c8eccb tests: check spending of P2TR (Pieter Wuille)
a2380127e9 Basic Taproot signing logic in script/sign.cpp (Pieter Wuille)
49487bc3b6 Make GetInputUTXO safer: verify non-witness UTXO match (Pieter Wuille)
fd3f6890f3 Construct and use PrecomputedTransactionData in PSBT signing (Pieter Wuille)
5cb6502ac5 Construct and use PrecomputedTransactionData in SignTransaction (Pieter Wuille)
5d2e22437b Don't nuke witness data when signing fails (Pieter Wuille)
ce9353164b Permit full precomputation in PrecomputedTransactionData (Pieter Wuille)
e841fb503d Add precomputed txdata support to MutableTransactionSignatureCreator (Pieter Wuille)
a91d532338 Add CKey::SignSchnorr function for BIP 340/341 signing (Pieter Wuille)
e77a2839b5 Use HandleMissingData also in CheckSchnorrSignature (Pieter Wuille)
dbb0ce9fbf Add TaprootSpendData data structure, equivalent to script map for P2[W]SH (Pieter Wuille)

Pull request description:

  Builds on top of #22051, adding signing support after derivation support.

  Nothing is changed in descriptor features. Signing works for key path and script path spending, through the normal sending functions, and PSBT-based RPCs. However, PSBT usability is rather low as no extensions have been defined to convey Taproot-specific information, so all script information must be known to the signing wallet.

ACKs for top commit:
  achow101:
    re-ACK 458a345b05
  fjahr:
    Code review ACK 458a345b05
  Sjors:
    ACK 458a345b05

Tree-SHA512: 30ed212cf7754763a4a81624ebc084c51727b8322711ac0b390369213c1a891d367ed8b123882ac08c99595320c11ec57ee42304ff22a69afdc3d1a0d55cc711
2021-06-18 09:12:44 +12:00
MarcoFalke
dd24567a24
Merge bitcoin/bitcoin#22120: test: p2p_invalid_block: Check that a block rejected due to too-new tim…
754e802274 test: check rejected future block later accepted (Luke Dashjr)

Pull request description:

  (Luke) was unsure if the code sufficiently avoided caching a
  time-too-new rejection, so wrote this test to check it.  It looks like
  despite only exempting BLOCK_MUTATED, it is still okay because header
  failures never cache block invalidity.  This test will help ensure that
  if this ever changes, BLOCK_TIME_FUTURE gets excluded at the same time.

  This PR re-opens https://github.com/bitcoin/bitcoin/pull/17872 which went stale and addresses the nits raised by reviewers there.

ACKs for top commit:
  MarcoFalke:
    review ACK 754e802274

Tree-SHA512: a2bbc8fffb523cf2831e1ecb05f20868e30106a38cc2e369e4973fa549cca06675a668df16f76c49cc4ce3a22925404255e5c53c4232d63ba1b9fca878509aa0
2021-06-17 09:05:52 +02:00
sanket1729
55311197c4 Added new test for future blocks reacceptance
Adds a test case for checking reacceptance a previously rejected block
that was too far in the future.
2021-06-16 16:43:20 -07:00
sanket1729
511a5af462 Fixed inconsistencies between code and comments
1) Makes the code for block 44 consistent with  the expected figure in
the comment above it by adding a transaction to the block
2) Fixed comment describing sign_tx() function
2021-06-16 16:43:20 -07:00
Luke Dashjr
754e802274
test: check rejected future block later accepted
(Luke) was unsure if the code sufficiently avoided caching a
time-too-new rejection, so wrote this test to check it.  It looks like
despite only exempting BLOCK_MUTATED, it is still okay because header
failures never cache block invalidity.  This test will help ensure that
if this ever changes, BLOCK_TIME_FUTURE gets excluded at the same time.

Co-authored-by: Will Clark <will8clark@gmail.com>
2021-06-15 21:35:29 +01:00
S3RK
451b96f7d2 test: kill process group to avoid dangling processes 2021-06-15 09:37:58 +02:00
MarcoFalke
964d91b193
Merge bitcoin/bitcoin#22130: test: refactor: dedup utility function chain_transaction()
01eedf3821 test: doc: improve doc for chain_transaction() helper (Sebastian Falbesoner)
6e63e366d6 test: refactor: dedup utility function chain_transaction() (Sebastian Falbesoner)

Pull request description:

  Both tests `mempool_packages.py` and `mempool_package_onemore.py` define a utility function `chain_transaction` with a similar implementation. This PR deduplicates it by moving it into the util package and keeping the more general properties:
  * pass a list of parent_txids/vouts instead of single values
  * always mark the BIP125-replaceable flag for txs, created via `createrawtransaction` (this is needed by the `mempool_package_onemore.py` test, but doesn't hurt the other one)

  This is a low-hanging fruit; as a potential follow-up one could probably also deduplicate the function `chain_transaction` in `rpc_packages.py`, which looks a bit different, as it also takes the parent locking script into account and doesn't send the tx.

ACKs for top commit:
  mjdietzx:
    reACK 01eedf3821
  klementtan:
    Code review ACK 01eedf3821
  MarcoFalke:
    review ACK 01eedf3821 🙅

Tree-SHA512: ac7105d02c23f53d76d4ec9dc8de1074dd8faefeecd44b107921b78665279498966152fed312ecbe252a1c34a9643d531166329a4fea0e773df3bb75d43092b0
2021-06-13 18:27:32 +02:00
MarcoFalke
9c1ec689f3
Merge bitcoin/bitcoin#22102: Remove Warning: from warning message printed for unknown new rules
6d7e46ce23 Remove `Warning:` (Prayank)

Pull request description:

  Reason: I noticed that `Warning` is printed 2 times in `-getinfo` while reviewing https://github.com/bitcoin/bitcoin/pull/21832#issuecomment-851004943

  Same string is used for GUI, log and stderr. If we need to add `Warning:` in GUI or other place we can always prepend to this string.

  CLI:

  ```
  Warnings: Unknown new rules activated (versionbit 28)

  ```

  GUI:

  ![image](https://user-images.githubusercontent.com/13405205/120110401-e36ab180-c18a-11eb-8031-4d52287dc263.png)

ACKs for top commit:
  MarcoFalke:
    review ACK 6d7e46ce23

Tree-SHA512: 25760cf6d850f6c2216d651fa46574d2d21a9d58f4577ecb58f9566ea8cd07bfcd6679bb8a1f53575e441b02d295306f492c0c99a48c909e60e5d977ec1861f6
2021-06-13 09:21:46 +02:00
Pieter Wuille
c0f0c8eccb tests: check spending of P2TR 2021-06-12 12:38:15 -07:00
W. J. van der Laan
b0e5fbf6fa
Merge bitcoin/bitcoin#22156: Allow tr() import only when Taproot is active
fbf485c9b2 Allow tr() import only when Taproot is active (Andrew Chow)

Pull request description:

  To avoid issues around fund loss, only allow descriptor wallets to import `tr()` descriptors after taproot has activated.

ACKs for top commit:
  sipa:
    utACK fbf485c9b2
  fjahr:
    Code review ACK fbf485c9b2
  laanwj:
    Code review ACK fbf485c9b2
  prayank23:
    utACK fbf485c9b2

Tree-SHA512: 83c43376515eea523dbc89bc5a0fde53e54aec492e49a40c2a33d80fc94aac459e232ae07b024b4bd75b58078c8d090bc7a2d69541c5d3d4834d2f4cfc9c8208
2021-06-12 17:22:41 +02:00
Vasil Dimov
7593b06bd1
test: ensure I2P addresses are relayed
This test would fail if `CNetAddr::IsRelayable()` returns `false` for
I2P addresses, given that this test node does not have I2P connectivity.
2021-06-11 19:17:59 +02:00
Vasil Dimov
e7468139a1
test: make CAddress in functional tests comparable
This way we can compare CAddress objects using `==` or even
arrays of CAddress using `array1 == array2`.
2021-06-11 19:16:07 +02:00
Vasil Dimov
33e211d2a4
test: implement ser/unser of I2P addresses in functional tests 2021-06-11 19:16:06 +02:00
Vasil Dimov
86742811ce
test: use NODE_* constants instead of magic numbers
We just assigned `NODE_NETWORK | NODE_WITNESS` to `nServices` a few
lines above. Use that for verifying correctness instead of `9`.
2021-06-11 13:52:42 +02:00
MarcoFalke
6985038046
Merge bitcoin/bitcoin#22118: test: check anchors.dat when node starts for the first time
ef99d03c2b test: check anchors.dat when node starts for the first time (bruno)

Pull request description:

  See https://github.com/bitcoin/bitcoin/pull/21338#discussion_r598406712, https://github.com/bitcoin/bitcoin/pull/21338#discussion_r598406187, https://github.com/bitcoin/bitcoin/pull/21338#discussion_r598405613.

ACKs for top commit:
  laanwj:
    Code review ACK ef99d03c2b

Tree-SHA512: 505f1f34fbc0c72a92968883be0f1c5f169a4ba3aa8a56e1ce8bc5e514f49e3a17ce51fd40be0073dc4bc06eaeda36dfe90ace843c181170e34643226afd78ef
2021-06-11 08:23:02 +02:00
Andrew Chow
fbf485c9b2 Allow tr() import only when Taproot is active
To avoid issues around fund loss, only allow descriptor wallets
to import tr() descriptors after taproot has activated.
2021-06-10 15:45:47 -04:00
Pieter Wuille
30aee2dfe6 tests: Add test for compact block HB selection 2021-06-10 10:22:13 -04:00
MarcoFalke
fa7d71f270
test: Run pep-8 on touched test
Can be reviewed with --ignore-all-space
2021-06-10 13:39:24 +02:00
MarcoFalke
fab7e99c2a
test: Use MiniWallet in test_no_inherited_signaling RBF test 2021-06-10 13:38:56 +02:00
MarcoFalke
fab871f649
test: Remove unused generate() from test
This is already done by the test framework in setup_nodes()
2021-06-10 13:38:18 +02:00
MarcoFalke
faff3f35b7
test: Add txin.sequence option to MiniWallet 2021-06-10 13:38:10 +02:00
fanquake
ef8f2966ac
Merge bitcoin/bitcoin#22084: package testmempoolaccept followups
ee862d6efb MOVEONLY: context-free package policies (glozow)
5cac95cd15 disallow_mempool_conflicts -> allow_bip125_replacement and check earlier (glozow)
e8ecc621be [refactor] comment/naming improvements (glozow)
7d91442461 [rpc] reserve space in txns (glozow)
6c5f19d9c4 [package] static_assert max package size >= max tx size (glozow)

Pull request description:

  various followups from #20833

ACKs for top commit:
  jnewbery:
    utACK ee862d6efb
  ariard:
    Code Review ACK ee862d6

Tree-SHA512: 96ecb41f7bbced84d4253070f5274b7267607bfe4033e2bb0d2f55ec778cc41e811130b6321131e0418b5835894e510a4be8a0f822bc9d68d9224418359ac837
2021-06-10 19:09:54 +08:00
MarcoFalke
fa9ebedec3
Reject invalid coin height and output index when loading assumeutxo 2021-06-09 22:20:01 +02:00
MarcoFalke
faca40ec68
test: Add temporary coinstats suppressions 2021-06-09 19:48:45 +02:00
Sebastian Falbesoner
d6d2ab9845 test: MiniWallet: fix fee calculation for P2PK and check tx vsize 2021-06-08 19:38:43 +02:00
Sebastian Falbesoner
ce024b1c0e test: MiniWallet: force P2PK signature to have fixed size (71 bytes)
In order to enable exact fee calculation for transactions that spend
P2PK outputs in the MiniWallet, we enforce the created signatures to
have a fixed length (>49.89% probability) by default. With that it is
easier to check the created transactions vsize and avoid flaky tests
that would appear whenever the signatures R- or S-values are smaller
(due to leading zero bytes).

Note that to get the total scriptSig size one has to add another
2 bytes, as there is also the OP_PUSHx instruction on the front and
the sighash type byte on the back, leading to a final scriptSig size
of 73 bytes.
2021-06-08 19:38:17 +02:00
MarcoFalke
82bc7faec8
Merge bitcoin/bitcoin#21946: Document and test lack of inherited signaling in RBF policy
2eb0eeda39 validation: document lack of inherited signaling in RBF policy (Antoine Riard)
906b6d9da6 test: Extend feature_rbf.py with no inherited signaling (Antoine Riard)

Pull request description:

  Contrary to BIP125 or other full-node implementation (e.g btcd), Bitcoin Core's mempool policy doesn't implement inherited signaling.

  This PR documents our mempool behavior on this and add a test demonstrating the case.

ACKs for top commit:
  jonatack:
    ACK 2eb0eeda39
  benthecarman:
    ACK 2eb0eeda39

Tree-SHA512: d41453d3b49bae3c1eb532a968f43bc047084913bd285929d4d9cba142777ff2be38163d912e28dfc635f4ecf446de68effad799c6e71be52f81e83410c712fb
2021-06-08 17:00:28 +02:00
Daniel Kraft
7a681d61b0 Add sync_blocks in wallet_orphanedreward.py.
Add an explicit sync_blocks call in wallet_orphanedreward.py, which was
missing and could lead to intermittent failures of the test due to
race conditions.

This will presumably fix https://github.com/bitcoin/bitcoin/issues/22181.
2021-06-08 09:52:10 +02:00
Sebastian Falbesoner
01eedf3821 test: doc: improve doc for chain_transaction() helper
Change to docstring format and describe the functions
purpose, its parameters and return value in more detail.
2021-06-08 00:21:37 +02:00
Sebastian Falbesoner
6e63e366d6 test: refactor: dedup utility function chain_transaction() 2021-06-08 00:21:37 +02:00
Prayank
6d7e46ce23 Remove Warning:
+ Remove `Warning:` from warning message printed for unknown new rules
+ Change warning message in test

Author:    Prayank <prayank@tutanota.de>
2021-06-07 20:19:18 +05:30
W. J. van der Laan
3c393ef9e1
Merge bitcoin/bitcoin#22149: test: Add temporary logging to debug #20975
faa94961d6 test: Add temporary logging to debug #20975 (MarcoFalke)

Pull request description:

  to be reverted after a fix

ACKs for top commit:
  laanwj:
    Code review ACK faa94961d6

Tree-SHA512: 1f3103fcf4cad0af54e26c4d257bd824b128b5f2d2b81c302e861a829fd55d6a099fa476b79b30a71fe98975ae604b9e3ff31fd48a51d442389a9bd515e60ba0
2021-06-07 16:03:45 +02:00
fanquake
260b1d74fe
Merge bitcoin/bitcoin#22092: test: convert documentation into type annotations
68ace23fa3 test: convert docs into type annotations in test_framework/test_node.py (fanquake)
8bfcba36db test: convert docs into type annotations in test_framework/wallet.py (fanquake)
b043ca8e8b test: convert docs into type annotations in test_framework/util.py (fanquake)

Pull request description:

  Rather than having function types exist as documentation, make them type annotations, which enables more `mypy` checking.

ACKs for top commit:
  instagibbs:
    utACK 68ace23fa3

Tree-SHA512: b705f26b48baabde07b9b2c0a8d547b4dcca291b16eaf5ac70462bb3a1f9e9c2783d93a9d4290889d0cbb3f7db3671446754411a1f498b265d336f6ff33478df
2021-06-07 13:05:56 +08:00
Hennadii Stepanov
e033ca1379
Merge bitcoin-core/gui#29: refactor: Optimize signal-slot connections logic
62cb8d98d2 qt: Drop BitcoinGUI* WalletFrame data member (Hennadii Stepanov)
f73e5c972a qt: Move CreateWalletActivity connection from WalletFrame to BitcoinGUI (Hennadii Stepanov)
20e2e24e90 qt: Move WalletView connections from WalletFrame to BitcoinGUI (Hennadii Stepanov)

Pull request description:

  This PR:
  - implements an idea from https://github.com/bitcoin/bitcoin/pull/17937#issuecomment-575991765
  - simplifies `WalletFrame` class interface
  - as a side effect, removes `bitcoingui` -> `walletframe` -> `bitcoingui` circular dependency
  - is an alternative to https://github.com/bitcoin/bitcoin/pull/17500

ACKs for top commit:
  promag:
    Tested ACK 62cb8d98d2 on macos 11.2.3 with depends build.
  jarolrod:
    ACK 62cb8d98d2

Tree-SHA512: 633b526a8499ba9ab4b16928daf4de4f6d610284bb9fa51891cad35300a03bde740df3466a71b46e87a62121330fcc9e606eac7666ea5e45fa6d5785b60dcbbd
2021-06-06 01:02:54 +03:00
MarcoFalke
898dd9e262
Merge bitcoin/bitcoin#22150: test: Remove unused node from feature_nulldummy
fa2b6c62cd test: Remove unused node from feature_nulldummy (MarcoFalke)

Pull request description:

  This is confusing and might even slow down the test.

  This reverts a change that was added a year ago in d438d60 and then the need for it was removed by 95d5d5e six months ago.

Top commit has no ACKs.

Tree-SHA512: 9a86792e9a634cf7bbd4e7a21b1acdfc3baba1b1962fe2b9b73848436d10351d2326dca01313c097ba2342dde7207add73e731d053c0bfa888a5d8f2b233a7cf
2021-06-05 08:41:37 +02:00
Martin Zumsande
ca3a77068b test: Fix p2p_leak.py intermittent failure by lowering timeout 2021-06-04 22:42:04 +02:00
MarcoFalke
fa2b6c62cd
test: Remove unused node from feature_nulldummy 2021-06-04 15:18:44 +02:00
MarcoFalke
faa94961d6
test: Add temporary logging to debug #20975 2021-06-04 15:05:27 +02:00
MarcoFalke
3ac5209662
Merge bitcoin/bitcoin#18795: Test: wallet issue with orphaned rewards
e4356f6a6c Testcase for wallet issue with orphaned rewards. (Daniel Kraft)

Pull request description:

  This adds a new test case demonstrating the wallet issue when block rewards are orphaned (#14148).

ACKs for top commit:
  LarryRuane:
    ACK e4356f6a6c
  leonardojobim:
    reACK e4356f6a6c .

Tree-SHA512: e9a2310ee1b3d52cfa302f431ed3d272bbc1b9195439ff318d9eb1006c0b28968dbe840e1600b6ff185e5d7ea57e4dcc837cef16051b5537445e10bc363b8c22
2021-06-04 13:54:34 +02:00
W. J. van der Laan
c7dd9ff71b
Merge bitcoin/bitcoin#22051: Basic Taproot derivation support for descriptors
2667366aaa tests: check derivation of P2TR (Pieter Wuille)
7cedafc541 Add tr() descriptor (derivation only, no signing) (Pieter Wuille)
90fcac365e Add TaprootBuilder class (Pieter Wuille)
5f6cc8daa8 Add XOnlyPubKey::CreateTapTweak (Pieter Wuille)
2fbfb1becb Make consensus checking of tweaks in pubkey.* Taproot-specific (Pieter Wuille)
a4bf84039c Separate WitnessV1Taproot variant in CTxDestination (Pieter Wuille)
41839bdb89 Avoid dependence on CTxDestination index order (Pieter Wuille)
31df02a070 Change Solver() output for WITNESS_V1_TAPROOT (Pieter Wuille)
4b1cc08f9f Make XOnlyPubKey act like byte container (Pieter Wuille)

Pull request description:

  This is a subset of #21365, to aide review.

  This adds support `tr(KEY)` or `tr(KEY,SCRIPT)` or `tr(KEY,{{S1,{{S2,S3},...}},...})` descriptors, describing Taproot outputs with specified internal key, and optionally any number of scripts, in nested groups of 2 inside `{`/`}` if there are more than one. While it permits importing `tr(KEY)`, anything beyond that is just laying foundations for more features later.

  Missing:
  * Signing support (see #21365)
  * Support for more interesting scripts inside the tree (only `pk(KEY)` is supported for now). In particular, a multisig policy based on the new `OP_CHECKSIGADD` opcode would be very useful.
  * Inferring `tr()` descriptors from outputs (given sufficient information).
  * `getaddressinfo` support.
  * MuSig support. Standardizing that is still an ongoing effort, and is generally kind of useless without corresponding PSBT support.
  * Convenient ways of constructing descriptors without spendable internal key (especially ones that arent't trivially recognizable as such).

ACKs for top commit:
  Sjors:
    utACK 2667366 (based on https://github.com/bitcoin/bitcoin/pull/21365#issuecomment-846945215 review, plus the new functional test)
  achow101:
    Code Review ACK 2667366aaa
  lsilva01:
    Tested ACK 2667366aaa
  meshcollider:
    utACK 2667366aaa

Tree-SHA512: 61046fef22c561228338cb178422f0b782ef6587ec8208d3ce2bd07afcff29a664b54b35c6b01226eb70b6540b43f6dd245043d09aa6cb6db1381b6042667e75
2021-06-03 21:58:41 +02:00
W. J. van der Laan
07ededa30c
Merge bitcoin/bitcoin#22050: p2p: remove tor v2 support
5d82a57db4 contrib: remove torv2 seed nodes (Jon Atack)
5f7e086dac contrib: update generate-seeds.py to ignore torv2 addresses (Jon Atack)
8be56f0f8e p2p, refactor: extract OnionToString() from CNetAddr::ToStringIp() (Jon Atack)
5f9d3c09b4 p2p: remove torv2 from CNetAddr::ToStringIP() (Jon Atack)
3d39042144 p2p: remove torv2 in SetIP() and ADDR_TORV2_SIZE constant (Jon Atack)
cff5ec477a p2p: remove pre-addrv2 onions from SerializeV1Array() (Jon Atack)
4192a74413 p2p: ignore torv2-in-ipv6 addresses in SetLegacyIPv6() (Jon Atack)
1d631e956f p2p: remove BIP155Network::TORV2 from GetBIP155Network() (Jon Atack)
7d1769bc45 p2p: remove torv2 from SetNetFromBIP155Network() (Jon Atack)
eba9a94b9f fuzz: rename CNetAddr/CService deserialize targets (Jon Atack)
c56a1c9b18 p2p: drop onions from IsAddrV1Compatible(), no longer relay torv2 (Jon Atack)
f8e94002fc p2p: remove torv2/ADDR_TORV2_SIZE from SetTor() (Jon Atack)
0f1c58ae87 test: update feature_proxy to torv3 (Jon Atack)

Pull request description:

  ![image](https://user-images.githubusercontent.com/2415484/120018909-4d425a00-bfd7-11eb-83c9-95a3dac97926.jpeg)

  This patch removes support in Bitcoin Core for Tor v2 onions, which are already removed from the release of Tor 0.4.6.

  - no longer serialize/deserialize and relay Tor v2 addresses
  - ignore incoming Tor v2 addresses
  - remove Tor v2 addresses from the addrman and peers.dat on node launch
  - update generate-seeds.py to ignore Tor v2 addresses
  - remove Tor v2 hard-coded seeds

  Tested with tor-0.4.6.1-alpha (no v2 support) and 0.4.5.7 (v2 support). With the latest Tor (no v2 support), this removes all the warnings like those reported with current master in https://github.com/bitcoin/bitcoin/issues/21351

  ```
  <bitcoind debug log>
  Socks5() connect to […].onion:8333 failed: general failure

  <tor log>
  Invalid hostname [scrubbed]; rejecting
  ```

  and the addrman no longer has Tor v2 addresses on launching bitcoind.
  ```rake
  $ ./src/bitcoin-cli -addrinfo
  {
    "addresses_known": {
      "ipv4": 44483,
      "ipv6": 8467,
      "torv2": 0,
      "torv3": 2296,
      "i2p": 6,
      "total": 55252
    }
  }
  ```
  After recompiling back to current master and restarting with either of the two Tor versions (0.4.5.7 or 0.4.6.1), -addrinfo initially returns 0 Tor v2 addresses and then begins finding them again.

  Ran nodes on this patch over the past week on mainnet/testnet/signet/regtest after building with DEBUG_ADDRMAN.

  Verified that this patch bootstraps an onlynet=onion node from the Tor v3 hardcoded fixed seeds on mainnet and testnet and connects to blocks and v3 onion peers: `rm ~/.bitcoin/testnet3/peers.dat ; ./src/bitcoind -testnet -dnsseed=0 -onlynet=onion`

  ![Screenshot from 2021-05-28 00-26-17](https://user-images.githubusercontent.com/2415484/119905021-ea02ea00-bf3a-11eb-875f-27ef57640c49.png)

  Tested using `addnode`, `getaddednodeinfo`,`addpeeraddress`, `disconnectnode` and `-addrinfo` that a currently valid, connectable Tor v2 peer can no longer be added:

  ![Screenshot from 2021-05-30 11-32-05](https://user-images.githubusercontent.com/2415484/120099282-29435d80-c12a-11eb-81b6-5084244d7d2a.png)

  Thanks to Vasil Dimov, Carl Dong, and Wladimir J. van der Laan for their work on BIP155 and Tor v3 that got us here.

ACKs for top commit:
  laanwj:
    Code review ACK 5d82a57db4

Tree-SHA512: 590ff3d2f6ef682608596facb4b01f44fef69716d2ab3552ae1655aa225f4bf104f9ee08d6769abb9982a8031de93340df553279ce1f5023771f9f2b651178bb
2021-06-03 18:43:55 +02:00
Christian Decker
b9e76f1bf0 rpc: Add test for -rpcwaittimeout
Suggested-by: Jon Atack <@jonatack>
2021-06-03 14:49:15 +02:00
fanquake
68ace23fa3
test: convert docs into type annotations in test_framework/test_node.py 2021-06-03 20:45:03 +08:00
fanquake
8bfcba36db
test: convert docs into type annotations in test_framework/wallet.py 2021-06-03 20:45:03 +08:00
fanquake
b043ca8e8b
test: convert docs into type annotations in test_framework/util.py 2021-06-03 20:45:03 +08:00
Jon Atack
8050eb43bf
script: fix spelling linter raising spuriously on "invokable" 2021-06-03 13:55:45 +02:00
Daniel Kraft
e4356f6a6c Testcase for wallet issue with orphaned rewards.
This adds a new test case demonstrating the wallet issue when block
rewards are orphaned (https://github.com/bitcoin/bitcoin/issues/14148).
2021-06-02 13:53:50 +02:00
glozow
5cac95cd15 disallow_mempool_conflicts -> allow_bip125_replacement and check earlier 2021-06-02 09:52:50 +01:00
MarcoFalke
2fccd9cf30
Merge bitcoin/bitcoin#22082: test: update nanobench from release 4.0.0 to 4.3.4
44d05d0a69 test: remove sanitizer suppression for nanobench (Martin Ankerl)
e3c866e3ca test: update nanobench from release 4.0.0 to 4.3.4 (Martin Ankerl)

Pull request description:

  This updates the third-party library nanobench with the latest release. It contains mostly minor bugfixes, a new pyperf output format, ability to suppress warnings with environment variable `NANOBENCH_SUPPRESS_WARNINGS`. Full changelog:

  v4.0.2
  * Changed `doNotOptimizeAway` to what google benchmark is doing. The old code did not work on some machines.
  * fix: display correct "total" value
  * minor Documentation updates

  v4.1.0
  * Updated link to new pyperf home
  * Adds ability to configure console output time unit
  *  Add support for environment variable `NANOBENCH_SUPPRESS_WARNINGS`
  * Nanobench is now usable with CMake's FetchContent (see documentation: https://nanobench.ankerl.com/tutorial.html#cmake-integration)

  v4.2.0
  * Ability to store and later compare results added, through `pyperf`.
  * See https://nanobench.ankerl.com/tutorial.html#pyperf-python-pyperf-module-output
  * Added lots of build targets to travis, similar to bitcoin's build.
  * Some minor API & documentation improvements

  v4.3.0
  * `ankerl::nanobench::Rng` can now return the state with `std::vector<uint64_t> Rng::state()`, and this can also be used to initialize the Rng.

  v4.3.1
  * Minor cmake improvements when integrationg as a third-party library: add alias `nanobench::nanobench`, default to C++17

  v4.3.2
  * Fixed a MSVC 2015 build problem
  * updates license to 2021.
  * build should now work with very old linux headers
  * Also disable UBSAN (bitcoin needed to add a suppression)

  v4.3.3
  * Do not use locale-dependent `std::to_string`

  v4.3.4
  * Add missing sanitizer suppression to `rotl`

ACKs for top commit:
  MarcoFalke:
    review ACK 44d05d0a69

Tree-SHA512: 3291c85057720cfc84a44bfaa305a7d0df4dc35779169d20de73d32e40d4cdbf3f005bf343f79710eca517441de2459e8118c195c5f5136f99d1f50ebd5dfd08
2021-06-02 09:20:16 +02:00
MarcoFalke
7e83e74e7f
Merge bitcoin/bitcoin#21178: test: run mempool_reorg.py even with wallet disabled
a3f0cbf82d test: run mempool_reorg.py even with wallet disabled (Darius Parvin)

Pull request description:

  Run mempool_reorg.py test even when the wallet is disabled, as discussed in #20078.

  As part of this PR I created a new method in `MiniWallet`, `create_self_transfer`, to return a raw tx (without broadcasting it) and its associated utxo.

ACKs for top commit:
  MarcoFalke:
    cr ACK a3f0cbf82d

Tree-SHA512: 316a38faffadcb87499c1d6eca21e9696cef65362bbffcf621788a9b771bb1fa2971b1c7835cbd34b952d7612ad83afbca824cd8be39ecd6b994e8963027f991
2021-06-01 15:05:45 +02:00
Martin Ankerl
44d05d0a69 test: remove sanitizer suppression for nanobench
In #21738 an ASAN suppression for nanobench was added. This is not needed any more,as nanobench.h already includes the necessary suppressions for the relevant code.
2021-06-01 12:00:21 +02:00
Sebastian Falbesoner
7e32fde912 test: feature_cltv.py: don't return tx copies in modification functions
The functions cltv_modify_tx(), cltv_invalidate() and cltv_validate()
all modify the passed transaction in-place, i.e. there is no need
to return a copy.
2021-05-31 19:47:30 +02:00
Sebastian Falbesoner
9ab2ce0a66 test: drop unused node parameters in feature_cltv.py
The following functions had a parameter "node" that is unsused
and hence can be removed:
    - cltv_modify_tx()
    - cltv_invalidate()
    - cltv_validate()
2021-05-31 19:34:00 +02:00
Sebastian Falbesoner
0c2139a3f1 test: fix typo in feature_cltv.py (s/ctlv/cltv/) 2021-05-31 19:18:04 +02:00
Darius Parvin
a3f0cbf82d test: run mempool_reorg.py even with wallet disabled
- run mempool_reorg.py even when the wallet is not compiled
- add `locktime` argument to `create_self_transfer` and `send_self_transfer`
- use more logs instead of comments
2021-05-31 09:28:10 -07:00
MarcoFalke
c5ee0cc11a
Merge bitcoin/bitcoin#21989: test: Use COINBASE_MATURITY in functional tests
bfa9309ad6 Use COINBASE_MATURITY constant in functional tests. (Kiminuo)
525448df9d Move COINBASE_MATURITY from `feature_nulldummy` test to `blocktools`. (Kiminuo)

Pull request description:

  `COINBASE_MATURITY` constant was added to `feature_nulldummy` test in #21373. This PR moves the constant to `blocktools.py` file and uses the constant in more tests as suggested [here](https://github.com/bitcoin/bitcoin/pull/21373#discussion_r605418462).

  Edit: Goal of this PR is to replace integer constants with `COINBASE_MATURITY` but not necessarily in *all* cases because that would mean to read and fully understand all tests. That's out of my time constraints. Any reports where `COINBASE_MATURITY` should be used are welcome though!

ACKs for top commit:
  theStack:
    ACK bfa9309ad6 🌇

Tree-SHA512: 01f04645f05a39028681f355cf3d42dd63ea3303f76d93c430e0fdce441934358a2d847a54e6068d61932f1b75e1d406f51859b057b3e4b569f7083915cb317f
2021-05-31 11:26:25 +02:00