Commit graph

5532 commits

Author SHA1 Message Date
Ryan Ofsky
3db2874bd7 Extend bilingual_str support for tinyformat
Previous bilingual_str tinyformat::format accepted bilingual format strings,
but not bilingual arguments. Extend it to accept both. This is useful when
embedding one translated string inside another translated string, for example:
`strprintf(_("Error: %s"), message)` which would fail previously if `message`
was a bilingual_str.
2023-02-28 12:04:47 -05:00
Andrew Chow
bb136aaf2c
Merge bitcoin/bitcoin#26533: prune: scan and unlink already pruned block files on startup
3141eab9c6 test: add functional test for ScanAndUnlinkAlreadyPrunedFiles (Andrew Toth)
e252909e56 test: add unit test for ScanAndUnlinkAlreadyPrunedFiles (Andrew Toth)
77557dda4a prune: scan and unlink already pruned block files on startup (Andrew Toth)

Pull request description:

  There are a few cases where we can mark a block and undo file as pruned in our block index, but not actually remove the files from disk.
  1. If we call `FindFilesToPrune` or `FindFilesToPruneManual` and crash before `UnlinkPrunedFiles`.
  2. If on Windows there is an open file handle to the file somewhere else when calling `fs::remove` in `UnlinkPrunedFiles` (https://en.cppreference.com/w/cpp/filesystem/remove, https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilew#remarks). This could be from another process, or if we are calling `ReadBlockFromDisk`/`ReadRawBlockFromDisk` without having a lock on `cs_main` (which has been allowed since ccd8ef65f9).

  This PR mitigates this by scanning all pruned block files on startup after `LoadBlockIndexDB` and unlinking them again.

ACKs for top commit:
  achow101:
    ACK 3141eab9c6
  pablomartin4btc:
    re-ACK with added functional test 3141eab9c6.
  furszy:
    Code review ACK 3141eab9
  theStack:
    Code-review ACK 3141eab9c6

Tree-SHA512: 6c73bc57838ad1b7e5d441af3c4d6bf4c61c4382e2b86485e57fbb74a61240710c0ceeceb8b4834e610ecfa3175c6955c81ea4b2285fee11ca6383f472979d8d
2023-02-28 09:54:10 -05:00
Andrew Chow
b7702bd546
Merge bitcoin/bitcoin#25943: rpc: Add a parameter to sendrawtransaction which sets a maximum value for unspendable outputs.
7013da07fb Add release note for PR#25943 (David Gumberg)
04f270b435 Add test for unspendable transactions and parameter 'maxburnamount' to sendrawtransaction. (David Gumberg)

Pull request description:

  This PR adds a user configurable, zero by default parameter — `maxburnamount` — to `sendrawtransaction`. This PR makes bitcoin core reject transactions that contain unspendable outputs which exceed `maxburnamount`.  closes #25899.

  As a result of this PR, `sendrawtransaction` will by default block 3 kinds of transactions:

  1. Those that begin with `OP_RETURN` - (datacarriers)
  2. Those whose lengths exceed the script limit.
  3. Those that contain invalid opcodes.

  The user is able to configure a `maxburnamount` that will override this check and allow a user to send a potentially unspendable output into the mempool.

  I see two legitimate use cases for this override:
  1. Users that deliberately use `OP_RETURN` for datacarrier transactions that embed data into the blockchain.
  2.  Users that refuse to update, or are unable to update their bitcoin core client would be able to make use of new opcodes that their client doesn't know about.

ACKs for top commit:
  glozow:
    reACK 7013da07fb
  achow101:
    re-ACK 7013da07fb

Tree-SHA512: f786a796fb71a587d30313c96717fdf47e1106ab4ee0c16d713695e6c31ed6f6732dff6cbc91ca9841d66232166eb058f96028028e75c1507324426309ee4525
2023-02-23 13:57:38 -05:00
fanquake
32f9ce0f52
Merge bitcoin/bitcoin#27124: docs: add ramdisk guide for running tests on OSX
2f84ad7b9e docs: add ramdisk guide for running tests on OSX (Matthew Zipkin)

Pull request description:

  Using a ramdisk on OSX sped up the test suite by about 5x (using default `jobs=4`) on my M1 macbook pro running macOS Monterey 12.3.1. This PR adds the relevant OSX commands following the Linux directions.

  Default:
  ```
  8204 s (accumulated)
  Runtime: 2104 s
  ```

  following commands from the PR:
  ```
  1606 s (accumulated)
  Runtime: 421 s
  ```

  ramdisk + `jobs=32`:
  ```
  2090 s (accumulated)
  Runtime: 85 s
  ```

ACKs for top commit:
  jonatack:
    ACK 2f84ad7b9e
  willcl-ark:
    ACK 2f84ad7b9e
  brunoerg:
    utACK 2f84ad7b9e

Tree-SHA512: 37a9903c8ac2cbfaa91e7e73fc96ef65042ff4b15763d452af7b8615255adf03429ad01cf85265a99dd569290c1d69c05a393d616868c05c190b60b053820786
2023-02-23 10:04:37 +00:00
Andrew Chow
832fa2d238
Merge bitcoin/bitcoin#25574: validation: Improve error handling when VerifyDB dosn't finish successfully
0af16e7134 doc: add release note for #25574 (Martin Zumsande)
57ef2a4812 validation: report if pruning prevents completion of verification (Martin Zumsande)
0c7785bb25 init, validation: Improve handling if VerifyDB() fails due to insufficient dbcache (Martin Zumsande)
d6f781f1cf validation: return VerifyDBResult::INTERRUPTED if verification was interrupted (Martin Zumsande)
6360b5302d validation: Change return value of VerifyDB to enum type (Martin Zumsande)

Pull request description:

  `VerifyDB()` can fail to complete due to insufficient dbcache at the level 3 checks. This PR improves the error handling in this case in the following ways:
  - The rpc `-verifychain` now returns false if the check can't be completed due to insufficient cache
  - During init, we only log a warning if the default values for `-checkblocks` and `-checklevel` are taken and the check doesn't complete. However, if the user actively specifies one of these args, we return with an InitError if we can't complete the check.

  This PR also changes `-verifychain` RPC to return `false` if the verification didn't finish due to missing block data (pruning) or due to being interrupted by the node being shutdown.

  Previously, this PR also included a fix for a possible assert during verification - this was done in #27009 (now merged).

ACKs for top commit:
  achow101:
    ACK 0af16e7134
  ryanofsky:
    Code review ACK 0af16e7134. Only small suggested changes since the last review, like renaming some of the enum values. I did leave more suggestions, but they are not very important and could be followups
  john-moffett:
    ACK 0af16e7134
  MarcoFalke:
    lgtm re-ACK 0af16e7134 🎚

Tree-SHA512: 84b4f767cf9bfbafef362312757c9bf765b41ae3977f4ece840e40c52a2266b1457832df0cdf70440be0aac2168d9b58fc817238630b0b6812f3836ca950bc0e
2023-02-22 14:19:44 -05:00
fanquake
9f6ef0c156
Merge bitcoin/bitcoin#27143: test: Replace 0xC0 constant
c3b4b5a142 test: Replace 0xC0 constant (roconnor-blockstream)

Pull request description:

  Instead it should be the named constant `LEAF_VERSION_TAPSCRIPT`.

ACKs for top commit:
  instagibbs:
    ACK c3b4b5a142
  theStack:
    ACK c3b4b5a142

Tree-SHA512: c00be584ea2d0e7c01bf5620da0da1f37e5b5298ef95df48d91d137c8c542f5d91be158d45392cf2ba8874bf27bd12924e2eed395773b49d091e3028de3356a2
2023-02-22 18:11:26 +00:00
Matthew Zipkin
2f84ad7b9e
docs: add ramdisk guide for running tests on OSX 2023-02-22 13:04:23 -05:00
Andrew Chow
5e55534586
Merge bitcoin/bitcoin#27068: wallet: SecureString to allow null characters
4bbf5ddd44 Detailed error message for passphrases with null chars (John Moffett)
b4bdabc223 doc: Release notes for 27068 (John Moffett)
4b1205ba37 Test case for passphrases with null characters (John Moffett)
00a0861181 Pass all characters to SecureString including nulls (John Moffett)

Pull request description:

  `SecureString` is a `std::string` specialization with a secure allocator. However, in practice it's treated like a C- string (no explicit length and null-terminated). This can cause unexpected and potentially insecure behavior. For instance, if a user enters a passphrase with embedded null characters (which is possible through Qt and the JSON-RPC), it will ignore any characters after the first null, potentially giving the user a false sense of security.

  Instead of assigning to `SecureString` via `std::string::c_str()`, assign it via a `std::string_view` of the original. This explicitly captures the size and still doesn't make any extraneous copies in memory.

  Note to reviewers, the following all compile identically in recent `GCC` (x86-64 and ARM64) with `-O2` (and `-std=c++17`):

  ```C++
  std::string orig_string;
  std::cin >> orig_string;
  SecureString s;
  s.reserve(100);
  // The following all compile identically
  s = orig_string;
  s = std::string_view{orig_string};
  s.assign(std::string_view{orig_string});
  s.assign(orig_string.data(), orig_string.size());
  ```

  So it's largely a matter of preference. However, one thing to keep in mind is that we want to avoid making unnecessary copies of any sensitive data in memory.

  Something like `SecureString s{orig_string};` is still invalid and probably unwanted in our case, since it'd get treated as a short string and optimized away from the secure allocator. I presume that's the reason for the `reserve()` calls.

  Fixes #27067.

ACKs for top commit:
  achow101:
    re-ACK 4bbf5ddd44
  stickies-v:
    re-ACK [4bbf5dd](4bbf5ddd44)
  furszy:
    utACK 4bbf5ddd

Tree-SHA512: 47a96905a82ca674b18076a20a388123beedf70e9de73e42574ea68afbb434734e56021835dd9b148cdbf61709926b487cc95e9021d9bc534a7c93b3e143d2f7
2023-02-22 13:02:16 -05:00
fanquake
c6e65a102c
Merge bitcoin/bitcoin#27137: test: Raise PRNG seed log to INFO
4d84eaec82 Raise PRNG seed log to INFO. (roconnor-blockstream)

Pull request description:

  Some build infrastructure, such as Nix, will delete failed builds by default, keeping only the log (stdout/stderr) of the failed build.

  For flaky tests, it would be very helpful to have the PRNG seed in the default log in order to redo the failed test.

  By simply raising the PRNG seed logging to INFO, we can, by default, record the seed in the log of every build.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 4d84eaec82
  theStack:
    ACK 4d84eaec82

Tree-SHA512: 3ccb4a4e7639a3babc3b2a6456a6d0bffc090da34e4545b317f7bfbed4e9950d1b38ea5b2a90c37ccb49b3454bdeff03a6aaf86770b9c4dd14b26320aba50b94
2023-02-22 17:51:39 +00:00
fanquake
63893d5eab
Merge bitcoin/bitcoin#26595: wallet: be able to specify a wallet name and passphrase to migratewallet
9486509be6 wallet, rpc: Update migratewallet help text for encrypted wallets (Andrew Chow)
aaf02b5721 tests: Tests for migrating wallets by name, and providing passphrase (Andrew Chow)
7fd125b27d wallet: Be able to unlock the wallet for migration (Andrew Chow)
6bdbc5ff59 rpc: Allow users to specify wallet name for migratewallet (Andrew Chow)
dbfa345403 wallet: Allow MigrateLegacyToDescriptor to take a wallet name (Andrew Chow)

Pull request description:

  `migratewallet` currently operates on wallets that are already loaded, however this is not necessarily required, and in the future, not possible once the legacy wallet is removed. So we need to also be able to give the wallet name to migrate.

  Additionally, the passphrase is required when migrating a wallet. Since a wallet may not be loaded when we migrate, and as we currently unload wallets when migrating, we need the passphrase to be given to `migratewallet` in order to migrate encrypted wallets.

  Fixes #27048

ACKs for top commit:
  john-moffett:
    reACK 9486509be6
  pinheadmz:
    ACK 9486509be6
  furszy:
    ACK 9486509b

Tree-SHA512: 35e2ba69a148e129a41e20d7fb99c4cab7947b1b7e7c362f4fd06ff8ac6e79e476e07207e063ba5b80e1a33e2343f4b4f1d72d7930ce80c34571c130d2f5cff4
2023-02-22 17:48:23 +00:00
roconnor-blockstream
c3b4b5a142 test: Replace 0xC0 constant
Instead it should be the named constant `LEAF_VERSION_TAPSCRIPT`.
2023-02-22 10:26:07 -05:00
fanquake
0c579203d2
Merge bitcoin/bitcoin#25867: lint: enable E722 do not use bare except
61bb4e783b lint: enable E722 do not use bare except (Leonardo Lazzaro)

Pull request description:

  Improve test code and enable E722 lint check.

   If you want to catch all exceptions that signal program errors, use except Exception: (bare except is equivalent to except BaseException:).

  Reference: https://peps.python.org/pep-0008/#programming-recommendations

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 61bb4e783b

Tree-SHA512: c7497769d5745fa02c78a20f4a0e555d8d3996d64af6faf1ce28e22ac1d8be415b98e967294679007b7bda2a9fd04031a9d140b24201e00257ceadeb5c5d7665
2023-02-22 09:28:09 +00:00
Andrew Chow
aaf02b5721 tests: Tests for migrating wallets by name, and providing passphrase 2023-02-21 15:51:31 -05:00
John Moffett
4b1205ba37 Test case for passphrases with null characters
Add a functional test to make sure the system
properly accepts passphrases with null characters.
2023-02-21 14:40:59 -05:00
Andrew Chow
80f4979322
Merge bitcoin/bitcoin#26347: wallet: ensure the wallet is unlocked when needed for rescanning
6a5b348f2e test: test rescanning encrypted wallets (ishaanam)
493b813e17 wallet: ensure that the passphrase is not deleted from memory when being used to rescan (ishaanam)
66a86ebabb wallet: keep track of when the passphrase is needed when rescanning (ishaanam)

Pull request description:

  Wallet passphrases are needed to top up the keypool of encrypted wallets
  during a rescan. The following RPCs need the passphrase when rescanning:
      - `importdescriptors`
      - `rescanblockchain`

  The following RPCs use the information about whether or not the
  passphrase is being used to ensure that full rescans are able to
  take place (meaning the following RPCs should not be able to run
  if a rescan requiring the wallet to be unlocked  is taking place):
      - `walletlock`
      - `encryptwallet`
      - `walletpassphrasechange`

  `m_relock_mutex` is also introduced so that the passphrase is not
  deleted from memory when the timeout provided in
  `walletpassphrase` is up and the wallet is still rescanning.
  Fixes #25702, #11249

  Thanks to achow101 for coming up with the idea of using a new mutex to solve this issue and for answering related questions.

ACKs for top commit:
  achow101:
    ACK 6a5b348f2e
  hernanmarino:
    ACK 6a5b348f2e
  furszy:
    Tested ACK 6a5b348f

Tree-SHA512: 0b6db692714f6f94594fa47249f5ee24f85713bfa70ac295a7e84b9ca6c07dda65df7b47781a2dc73e5b603a8725343a2f864428ae20d3e126c5b4802abc4ab5
2023-02-21 14:02:49 -05:00
roconnor-blockstream
4d84eaec82
Raise PRNG seed log to INFO.
Some build infrastructure, such as Nix, will delete failed builds by default, keeping only the log of the failed build.

For flaky tests, it would be very helpful to have the PRNG seed in the default log in order to redo the failed test.

By simply raising the PRNG seed logging to INFO, we can, by default, record the seed in the log of every build.
2023-02-21 12:01:13 -05:00
David Gumberg
04f270b435 Add test for unspendable transactions and parameter 'maxburnamount' to sendrawtransaction.
'maxburnamount' sets a maximum value for outputs heuristically deemed unspendable including datacarrier scripts that begin with `OP_RETURN`.
2023-02-20 11:38:52 -07:00
fanquake
94070029fb
Merge bitcoin/bitcoin#27053: wallet: reuse change dest when re-creating TX with avoidpartialspends
14b4921a91 wallet: reuse change dest when recreating TX with avoidpartialspends (Matthew Zipkin)

Pull request description:

  Closes https://github.com/bitcoin/bitcoin/issues/27051

  When the wallet creates a transaction internally, it will also create an alternative that spends using destination groups and see if the fee difference is negligible. If it costs the user the same to send the grouped version, we send it (even if the user has `avoidpartialspends` set to `false` which is default). This patch ensures that the second transaction creation attempt re-uses the change destination selected by the first attempt. Otherwise, the first change address remains reserved, will not be used in the second attempt, and then will never be used by the wallet, leaving gaps in the BIP44 chain.

  If the user had `avoidpartialspends` set to true, there is no second version of the created transaction and the change addresses are not affected.

  I believe this behavior was introduced in https://github.com/bitcoin/bitcoin/pull/14582

ACKs for top commit:
  achow101:
    ACK 14b4921a91

Tree-SHA512: a3d56f251ff4b333fc11325f30d05513e34ab0a2eb703fadd0ad98d167ae074493df1a24068298336c6ed2da6b31aa2befa490bc790bbc260ed357c8f2397659
2023-02-20 17:20:37 +00:00
fanquake
e996219f9a
Merge bitcoin/bitcoin#27113: rpc: Use a FlatSigningProvider in decodescript to allow inferring descriptors for scripts larger than 520 bytes
73ec4b2a83 tests: decodescript can infer descriptors for scripts >520 bytes (Andrew Chow)
7cc7822371 rpc: Use FlatSigningProvider in decodescript (Andrew Chow)

Pull request description:

  `FillableSigningProvider` limits scripts to 520 bytes even though segwit allows scripts to be larger than that. We can avoid this limit by using a `FlatSigningProvider` so that such larger scripts can be decoded.

  Fixes #27111

ACKs for top commit:
  instagibbs:
    ACK 73ec4b2a83

Tree-SHA512: c0e6d21025e2da864471989ac94c54e127d05459b9b048f34a0da8d76d8e372d5472a2e667ba2db74d6286e3e6faa55486ffa9232a068b519afa676394031d5a
2023-02-20 16:41:46 +00:00
fanquake
150cc8ef42
Merge bitcoin/bitcoin#27128: test: fix intermittent issue in p2p_disconnect_ban
1819564c21 test: fix intermittent issue in `p2p_disconnect_ban` (brunoerg)

Pull request description:

  Fixes #26808

  When `node0` calls `disconnectnode` to disconnect `node1`, we should check in `node1` if it worked, because for `node0` the informations in `getpeerinfo` may be updated before really completing the disconnection.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 1819564c21

Tree-SHA512: 53a386fc38e2faa6f6da3536e76857ff4b6f55e2590d73fe857b3fe5d0f3ff92c5c7e4abd50ab4be250cb2106a4d14ad95d4809ea60c6e00ed3ac0e71255b0b0
2023-02-20 16:28:02 +00:00
fanquake
446c8f581c
Merge bitcoin/bitcoin#25950: test: fix test abort for high timeout values (and --timeout-factor 0)
14302a4802 test: fix test abort for high timeout values (and `--timeout-factor 0`) (Sebastian Falbesoner)

Pull request description:

  On master, the functional tests's option `--timeout-factor 0` (which according to the test docs and parameter description should disable the RPC timeouts) currently fails, same as high values like `--timeout-factor 999999`:
  ```
  $ ./test/functional/wallet_basic.py --timeout-factor 0
  2022-08-29T01:26:39.561000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_f24yxzp5
  2022-08-29T01:26:40.262000Z TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/home/honey/bitcoin/test/functional/test_framework/test_framework.py", line 549, in start_nodes
      node.wait_for_rpc_connection()
    File "/home/honey/bitcoin/test/functional/test_framework/test_node.py", line 234, in wait_for_rpc_connection
      rpc.getblockcount()
    File "/home/honey/bitcoin/test/functional/test_framework/coverage.py", line 49, in __call__
      return_val = self.auth_service_proxy_instance.__call__(*args, **kwargs)
    File "/home/honey/bitcoin/test/functional/test_framework/authproxy.py", line 142, in __call__
      response, status = self._request('POST', self.__url.path, postdata.encode('utf-8'))
    File "/home/honey/bitcoin/test/functional/test_framework/authproxy.py", line 107, in _request
      self.__conn.request(method, path, postdata, headers)
    File "/usr/local/lib/python3.9/http/client.py", line 1285, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "/usr/local/lib/python3.9/http/client.py", line 1331, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "/usr/local/lib/python3.9/http/client.py", line 1280, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "/usr/local/lib/python3.9/http/client.py", line 1040, in _send_output
      self.send(msg)
    File "/usr/local/lib/python3.9/http/client.py", line 980, in send
      self.connect()
    File "/usr/local/lib/python3.9/http/client.py", line 946, in connect
      self.sock = self._create_connection(
    File "/usr/local/lib/python3.9/socket.py", line 844, in create_connection
      raise err
    File "/usr/local/lib/python3.9/socket.py", line 832, in create_connection
      sock.connect(sa)
  OSError: [Errno 22] Invalid argument
  ```
  This is caused by a high timeout value that Python's HTTP(S) client library can't cope with. Fix this by clamping down the connection's set timeout value in AuthProxy. The change can easily be tested by running an arbitrary test with `--timeout-factor 0` on master (should fail), on this PR (should pass) and on this PR with the clamping value increased by 1 (should fail).

  // EDIT: The behaviour was observed on OpenBSD 7.1 and Python 3.9.12.

ACKs for top commit:
  MarcoFalke:
    lgtm ACK 14302a4802

Tree-SHA512: 6469e8ac699f1bb7dea11d5fb8b3ae54d895bb908570587c5631144cd41fe980ca0b1e6d0b7bfa07983307cba15fb26ae92e6766375672bf5be838d8e5422dbc
2023-02-20 16:20:55 +00:00
brunoerg
1819564c21 test: fix intermittent issue in p2p_disconnect_ban
When `node0` calls `disconnectnode` to disconnect `node1`, we should check in `node1` if it worked, because for `node0` the informations in `getpeerinfo` may be updated before really completing the disconnection.
2023-02-20 10:36:35 -03:00
Leonardo Lazzaro
61bb4e783b lint: enable E722 do not use bare except 2023-02-18 11:24:09 +00:00
Sebastian Falbesoner
14302a4802 test: fix test abort for high timeout values (and --timeout-factor 0) 2023-02-17 23:30:59 +01:00
Andrew Chow
f722a9bd13
Merge bitcoin/bitcoin#20018: p2p: ProcessAddrFetch(-seednode) is unnecessary if -connect is specified
2555a3950f p2p: ProcessAddrFetch(-seednode) is unnecessary if -connect is specified (Dhruv Mehta)

Pull request description:

  If the user runs: `bitcoind -connect=X -seednode=Y`, I _think_ it is safe to ignore `-seednode`. A more populated `addrman` (via `getaddr` calls to peers in `-seednode`) is not useful in this configuration: `addrman` entries are used to initiate new outbound connections when slots are open, or to open feeler connections and keep `addrman` from getting stale. This is all done in a part of `ThreadOpenConnections` (below [this line](https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1803)) which is never executed when `-connect` is supplied. With `-connect`, `ThreadOpenConnections` will run [this loop](https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1785) and exit thread execution when interrupted.

  Reviewers may also find it relevant that when `-connect` is used, we [soft disable](https://github.com/bitcoin/bitcoin/blob/master/src/init.cpp#L800) `-dnsseed` in init.cpp perhaps for the same reason i.e. seeding is not useful with `-connect`.

  Running `ProcessAddrFetch` does not seem to have downside except developer confusion AFAICT. I was confused by this and felt it might affect other new bitcoiners too. If there is strong preference to not remove the line, I'd also be happy to just leave a comment there mentioning `ADDR_FETCH`/`-seednode` is irrelevant when used with `-connect`.

  If this change is accepted, the node will still make `getaddr` calls to peers in `-connect` and expand `addrman`. However, disabling those `getaddr` calls would leak information about the node's configuration.

ACKs for top commit:
  mzumsande:
    Code Review ACK 2555a3950f
  achow101:
    ACK 2555a3950f
  vasild:
    ACK 2555a3950f

Tree-SHA512: 9187a0cff58db8edeca7e15379b1c121e7ebe8c38fb82f69e3dae8846ee94c92a329d79025e0f023c7579b2d86e7dbf756e4e30e90a72236bfcd2c00714180b3
2023-02-17 14:21:06 -05:00
fanquake
bc35c4f58c
Merge bitcoin/bitcoin#27106: net: remove orphaned CSubNet::SanityCheck()
30a3230e86 script: remove out-of-date snprintf TODO (Jon Atack)
0e015146bd net: remove orphaned CSubNet::SanityCheck() (Jon Atack)

Pull request description:

  `CSubNet::SanityCheck()` was added in #20140, and not removed in #22570 when it became orphaned code.

  Also, remove an out-of-date `snprintf` TODO that was resolved in #27036, and fix up 2 words to make the spelling linter green again.

ACKs for top commit:
  fanquake:
    ACK 30a3230e86
  pinheadmz:
    ACK 30a3230e86
  brunoerg:
    crACK 30a3230e86

Tree-SHA512: f91a2a5af902d3b82ab496f19deeac17d58dbf72a8016e880ea61ad858b66e7ea0ae70b964c4032018eb3252cc34ac5fea163131c6a7f1baf87fc9ec9b5833d8
2023-02-17 10:31:24 +00:00
Martin Zumsande
57ef2a4812 validation: report if pruning prevents completion of verification
Now the verifychain RPC returns false if the checks didn't
finish because the blocks requested to be queried have been pruned.
2023-02-16 17:58:52 -05:00
Andrew Chow
73966f75f6
Merge bitcoin/bitcoin#25344: New outputs argument for bumpfee/psbtbumpfee
4c8ecccdcd test: add tests for `outputs` argument to `bumpfee`/`psbtbumpfee` (Seibart Nedor)
c0ebb98382 wallet: add `outputs` arguments to `bumpfee` and `psbtbumpfee` (Seibart Nedor)
a804f3cfc0 wallet: extract and reuse RPC argument format definition for outputs (Seibart Nedor)

Pull request description:

  This implements a modification of the proposal in #22007: instead of **adding** outputs to the set of outputs in the original transaction, the outputs given by `outputs` argument **completely replace** the outputs in the original transaction.

  As noted below, this makes it easier to "cancel" a transaction or to reduce the amounts in the outputs, which is not the case with the original proposal in #22007, but it seems from the discussion in this PR that the **replace** behavior is more desirable than **add** one.

ACKs for top commit:
  achow101:
    ACK 4c8ecccdcd
  1440000bytes:
    Code Review ACK 4c8ecccdcd
  ishaanam:
    reACK 4c8ecccdcd

Tree-SHA512: 31361f4a9b79c162bda7929583b0a3fd200e09f4c1a5378b12007576d6b14e02e9e4f0bab8aa209f08f75ac25a1f4805ad16ebff4a0334b07ad2378cc0090103
2023-02-16 13:47:41 -05:00
Andrew Chow
7fd125b27d wallet: Be able to unlock the wallet for migration
Since migration reloads the wallet, the wallet will always be locked
unless the passphrase is given. migratewallet can now take the
passphrase in order to unlock the wallet for migration.
2023-02-16 13:39:03 -05:00
Andrew Chow
73ec4b2a83 tests: decodescript can infer descriptors for scripts >520 bytes 2023-02-16 11:42:28 -05:00
merge-script
437dfe1c26
Merge bitcoin/bitcoin#26714: test: add coverage for unparsable -maxuploadtarget
7a83aa0982 test: add coverage for unparsable `-maxuploadtarget` (brunoerg)

Pull request description:

  This PR adds test coverage for the following error:
  7386da7a0b/src/init.cpp (L1096-L1099)

Top commit has no ACKs.

Tree-SHA512: c115b2b4d2d0eb2316bf9fafd7e0046aa18c9650062779b3a82d6145d188765bff5317f4ca5f79607732fde6d83e1f67756ac20a12c98d060ee68d8acc20c76e
2023-02-16 15:17:54 +01:00
merge-script
3a68e194f5
Merge bitcoin/bitcoin#26586: test: previous releases: add v24.0.1
741908afc1 test: previous releases: add v24.0.1 (Sebastian Falbesoner)

Pull request description:

  The same procedure as every release (see dba1231672 [v23.0] and d8b705f1ca [v22.0]), only a little simpler now: thanks to #25650, the previous release fetch script defaults to downloading/building the necessary tags, i.e. we don't need to extend the tag list in the CI scripts and test/README.md anymore.

ACKs for top commit:
  Sjors:
    tACK 741908afc1

Tree-SHA512: a5426e989bd0bba42aa13e7d4cf60f792bf36bd9a6cdb6ef5799f7574d9a8a20979244627bbd0c6219630367e7fd73bac9e677814bc50233f64592ad035e713e
2023-02-16 15:02:02 +01:00
fanquake
fb82d91a9c
Merge bitcoin/bitcoin#24149: Signing support for Miniscript Descriptors
6c7a17a8e0 psbt: support externally provided preimages for Miniscript satisfaction (Antoine Poinsot)
840a396029 qa: add a "smart" Miniscript fuzz target (Antoine Poinsot)
17e3547241 qa: add a fuzz target generating random nodes from a binary encoding (Antoine Poinsot)
611e12502a qa: functional test Miniscript signing with key and timelocks (Antoine Poinsot)
d57b7f2021 refactor: make descriptors in Miniscript functional test more readable (Antoine Poinsot)
0a8fc9e200 wallet: check solvability using descriptor in AvailableCoins (Antoine Poinsot)
560e62b1e2 script/sign: signing support for Miniscripts with hash preimage challenges (Antoine Poinsot)
a2f81b6a8f script/sign: signing support for Miniscript with timelocks (Antoine Poinsot)
61c6d1a844 script/sign: basic signing support for Miniscript descriptors (Antoine Poinsot)
4242c1c521 Align 'e' property of or_d and andor with website spec (Pieter Wuille)
f5deb41780 Various additional explanations of the satisfaction logic from Pieter (Pieter Wuille)
22c5b00345 miniscript: satisfaction support (Antoine Poinsot)

Pull request description:

  This makes the Miniscript descriptors solvable.

  Note this introduces signing support for much more complex scripts than the wallet was previously able to solve, and the whole tooling isn't provided for a complete Miniscript integration in the wallet. Particularly, the PSBT<->Miniscript integration isn't entirely covered in this PR.

ACKs for top commit:
  achow101:
    ACK 6c7a17a8e0
  sipa:
    utACK 6c7a17a8e0 (to the extent that it's not my own code).

Tree-SHA512: a71ec002aaf66bd429012caa338fc58384067bcd2f453a46e21d381ed1bacc8e57afb9db57c0fb4bf40de43b30808815e9ebc0ae1fbd9e61df0e7b91a17771cc
2023-02-16 10:01:33 +00:00
Jon Atack
30a3230e86 script: remove out-of-date snprintf TODO
that was resolved in PR27036 "test: Remove last uses of snprintf and simplify"
and while here, fix up 2 words in docs to make the spelling linter green again.
2023-02-15 14:42:28 -08:00
merge-script
a65d2259f1
Merge bitcoin/bitcoin#27035: test: simplify and speedup mempool_updatefromblock.py by using MiniWallet
dee8549be3 test: simplify and speedup mempool_updatefromblock.py by using MiniWallet (Sebastian Falbesoner)

Pull request description:

  This PR simplifies the functional test mempool_updatefromblock.py by using MiniWallet in order to avoid manual low-level tx creation (signing, outputs selection, fee calculation). Most of the tedious work is done by the method `MiniWallet.send_self_transfer_multi` (calling `create_self_transfer_multi` internally) which supports spending a given set of UTXOs and creating a certain number of outputs.

  As a nice side-effect, the test's performance increases significantly (~3.5x on my system):

  ```
  master
      1m56.80s real     1m50.10s user     0m06.36s system

  PR
      0m32.34s real     0m30.26s user     0m01.41s system
  ```

  The arguments `start_input_txid` and `end_address` have been removed from the `transaction_graph_test` method, as they are currently unused and I don't see them being needed for future tests.

ACKs for top commit:
  brunoerg:
    crACK dee8549be3
  MarcoFalke:
    lgtm ACK dee8549be3 🚏

Tree-SHA512: 9f6da634bdc8c272f9a2af1cddaa364ee371d4e95554463a066249eecebb668d8c6cb123ec8a5404c41b3291010c0c8806a8a01dd227733cec03e73aa93b0103
2023-02-15 16:26:00 +01:00
Matthew Zipkin
14b4921a91
wallet: reuse change dest when recreating TX with avoidpartialspends 2023-02-15 10:14:30 -05:00
fanquake
1e0198b6c1
Merge bitcoin/bitcoin#26153: Reduce wasted pseudorandom bytes in ChaCha20 + various improvements
511aa4f1c7 Add unit test for ChaCha20's new caching (Pieter Wuille)
fb243d25f7 Improve test vectors for ChaCha20 (Pieter Wuille)
93aee8bbda Inline ChaCha20 32-byte specific constants (Pieter Wuille)
62ec713961 Only support 32-byte keys in ChaCha20{,Aligned} (Pieter Wuille)
f21994a02e Use ChaCha20Aligned in MuHash3072 code (Pieter Wuille)
5d16f75763 Use ChaCha20 caching in FastRandomContext (Pieter Wuille)
38eaece67b Add fuzz test for testing that ChaCha20 works as a stream (Pieter Wuille)
5f05b27841 Add xoroshiro128++ PRNG (Martin Leitner-Ankerl)
12ff72476a Make unrestricted ChaCha20 cipher not waste keystream bytes (Pieter Wuille)
6babf40213 Rename ChaCha20::Seek -> Seek64 to clarify multiple of 64 (Pieter Wuille)
e37bcaa0a6 Split ChaCha20 into aligned/unaligned variants (Pieter Wuille)

Pull request description:

  This is an alternative to #25354 (by my benchmarking, somewhat faster), subsumes #25712, and adds additional test vectors.

  It separates the multiple-of-64-bytes-only "core" logic (which becomes simpler) from a layer around which performs caching/slicing to support arbitrary byte amounts. Both have their uses (in particular, the MuHash3072 code can benefit from multiple-of-64-bytes assumptions), plus the separation results in more readable code. Also, since FastRandomContext effectively had its own (more naive) caching on top of ChaCha20, that can be dropped in favor of ChaCha20's new built-in caching.

  I thought about rebasing #25712 on top of this, but the changes before are fairly extensive, so redid it instead.

ACKs for top commit:
  ajtowns:
    ut reACK 511aa4f1c7
  dhruv:
    tACK crACK 511aa4f1c7

Tree-SHA512: 3aa80971322a93e780c75a8d35bd39da3a9ea570fbae4491eaf0c45242f5f670a24a592c50ad870d5fd09b9f88ec06e274e8aa3cefd9561d623c63f7198cf2c7
2023-02-15 14:58:47 +00:00
ishaanam
6a5b348f2e test: test rescanning encrypted wallets 2023-02-14 23:32:43 -05:00
Andrew Chow
576e16e702
Merge bitcoin/bitcoin#26184: test: p2p: check that headers message with invalid proof-of-work disconnects peer
772671245d test: p2p: check that headers message with invalid proof-of-work disconnects peer (Sebastian Falbesoner)

Pull request description:

  One of the earliest anti-DoS checks done after receiving and deserializing a `headers` message from a peer is verifying whether the proof-of-work is valid (called in method `PeerManagerImpl::ProcessHeadersMessage`):
  f227e153e8/src/net_processing.cpp (L2752-L2762)
  The called method `PeerManagerImpl::CheckHeadersPoW` calls `Misbehaving` with a score of 100, i.e. leading to an immediate disconnect of the peer:
  f227e153e8/src/net_processing.cpp (L2368-L2372)

  This PR adds a simple test for both the misbehaving log and the resulting disconnect. For creating a block header with invalid proof-of-work, we first create one that is accepted by the node (the difficulty field `nBits` is copied from the genesis block) and based on that the nonce is modified until we have block header hash prefix that is too high to fulfill even the minimum difficulty.

ACKs for top commit:
  Sjors:
    ACK 772671245d
  achow101:
    ACK 772671245d
  brunoerg:
    crACK 772671245d
  furszy:
    Code review ACK 77267124 with a non-blocking speedup.

Tree-SHA512: 680aa7939158d1dc672b90aa6554ba2b3a92584b6d3bcb0227776035858429feb8bc66eed18b47de0fe56df7d9b3ddaee231aaeaa360136603b9ad4b19e6ac11
2023-02-14 18:45:35 -05:00
fanquake
af49d86dd7
Merge bitcoin/bitcoin#27093: test: Fix intermittent sync issue in wallet_pruning
fa9ec7b0fe test: Fix intermittent sync issue in wallet_pruning (MarcoFalke)

Pull request description:

  The `sync_fun=self.no_op` has no motivation or rationale, and seems to be causing issues.

  Fix that by removing it.

  Actually fixes https://github.com/bitcoin/bitcoin/issues/27065, see https://github.com/bitcoin/bitcoin/pull/27066#issuecomment-1428249997

ACKs for top commit:
  fanquake:
    ACK fa9ec7b0fe

Tree-SHA512: 3c67da6705d6698fcabb29de169a2b4723f74705c979380d1fddce5fe9595b4595445fd7d9790a6b2a89f10ce8ec3c64ce45248f58fd920b72b7b6fba8afb09f
2023-02-14 16:52:18 +00:00
Pieter Wuille
e4e17907b6 Modernize rpcauth.py and its tests 2023-02-13 17:11:15 -05:00
MarcoFalke
fa9ec7b0fe
test: Fix intermittent sync issue in wallet_pruning 2023-02-13 17:32:42 +01:00
Antoine Poinsot
6c7a17a8e0
psbt: support externally provided preimages for Miniscript satisfaction
Co-Authored-By: Andrew Chow <github@achow101.com>
2023-02-13 15:39:25 +01:00
merge-script
a6316590d5
Merge bitcoin/bitcoin#26970: test: fix immediate tx relay in wallet_groups.py
ab4efad51b test: fix immediate tx relay in wallet_groups.py (Sebastian Falbesoner)

Pull request description:

  In the functional test wallet_groups.py we whitelist peers on all nodes (`-whitelist=noban@127.0.0.1`) to enable immediate tx relay for fast mempool synchronization. However, considering that this setting only applies to inbound peers and the default test topology looks like this:
  ```
      node0 <--- node1 <---- node2 <--- ... <-- nodeN
  ```

  txs propagate fast only from lower- to higher-numbered nodes (i.e. "left to right" in the above diagram) and take long from higher- to lower-numbered nodes ("right to left") since in the latter direction we only have outbound peers, where the trickle relay is still active. As a consequence, if a tx is submitted from any node other than node0, the mempool synchronization can take quite long.

  This PR fixes this by simply adding another connection from node0 to the last node, leading to a ~2-3x speedup (5 runs measured via `time ./test/functional/wallet_groups.py` are shown):

  ```
  master:
      0m53.31s real     0m08.22s user     0m05.60s system
      0m32.85s real     0m07.44s user     0m04.08s system
      0m46.40s real     0m09.18s user     0m04.23s system
      0m46.96s real     0m11.10s user     0m05.74s system
      0m57.23s real     0m10.53s user     0m05.59s system

  PR:
      0m19.64s real     0m09.58s user     0m05.50s system
      0m18.05s real     0m07.77s user     0m04.03s system
      0m18.99s real     0m07.90s user     0m04.25s system
      0m17.49s real     0m07.56s user     0m03.92s system
      0m18.11s real     0m07.74s user     0m03.88s system
  ```
  Note that in most tests this is not a problem since txs very often originate from node0.

ACKs for top commit:
  brunoerg:
    utACK ab4efad51b

Tree-SHA512: 12675357e6eb5a18383f2bfe719a184c0790863b37a98749d8e757dd5dc3a36212e16a81f0a192340c11b793eda00db359c7011f46f7c27e3a093af4f5b62147
2023-02-13 11:51:03 +01:00
Antoine Poinsot
611e12502a
qa: functional test Miniscript signing with key and timelocks
We'll need a better integration of the hash preimages PSBT fields to
satisfy Miniscript with such challenges from the RPC.

Thanks to Greg Sanders for his examples and suggestions to improve this
test.
2023-02-11 14:12:13 +01:00
Antoine Poinsot
d57b7f2021
refactor: make descriptors in Miniscript functional test more readable
We'll add more of them in the next commit, let's keep it bearable.
2023-02-11 14:12:13 +01:00
Antoine Poinsot
61c6d1a844
script/sign: basic signing support for Miniscript descriptors
Try to solve a script using the Miniscript satisfier if the legacy
solver fails under P2WSH context. Only solve public key and public key
hash challenges for now.

We don't entirely replace the raw solver and especially rule out trying to
solve CHECKMULTISIG-based multisigs with the Miniscript satisfier since
some features, such as the transaction input combiner, rely on the
specific behaviour of the former.
2023-02-11 14:12:10 +01:00
Fabian Jahr
60978c8080
test: Reduce extended timeout on abortnode test
This was made obsolete by tracking the active requests and explicitly waiting for them to finish before shutdown.
2023-02-10 20:35:02 +01:00
Sebastian Falbesoner
772671245d test: p2p: check that headers message with invalid proof-of-work disconnects peer 2023-02-10 00:01:04 +01:00
721217.xyz
fa6f67837b
test: Fix intermittent sync issue in wallet_pruning 2023-02-09 12:28:56 +01:00
MarcoFalke
51d51d3082
Merge bitcoin/bitcoin#26507: test: remove unused vars in feature_block
741c215b5f test: remove unused vars in `feature_block` (brunoerg)

Pull request description:

  There is no need to assign `self.next_block` to variables if we're not using its return value. Most cases touched here, we're reassigning it right after with the value from `self.update_block`.

Top commit has no ACKs.

Tree-SHA512: 25bbea2a09f38c3a3483fa363f024d2a8edd06a00cccc93cef99e489b9a3485d58bbd6a1ed2dddc00f1cebec7e63aed8ad95701a2645ce20a0db9b69573c20a7
2023-02-08 11:42:22 +01:00
fanquake
6e08e5cb5c
Merge bitcoin/bitcoin#17127: util: Set safe permissions for data directory and wallets/ subdir
c9ba4f9ecb test: Add test for file system permissions (Hennadii Stepanov)
581f16ef34 Apply default umask in `SetupEnvironment()` (Hennadii Stepanov)
8a6219e543 Remove `-sysperms` option (Hennadii Stepanov)

Pull request description:

  On master (1e7564eca8) docs say:
  ```
  $ ./src/bitcoind -help | grep -A 3 sysperms
    -sysperms
         Create new files with system default permissions, instead of umask 077
         (only effective with disabled wallet functionality)

  ```

  Basing on that, one could expect that running `bitcoind` first time will create data directory and `wallets/` subdirectory with safe 0700 permissions.

  But that is not the case:
  ```
  $ stat .bitcoin | grep id
  Access: (0775/drwxrwxr-x)  Uid: ( 1000/ hebasto)   Gid: ( 1000/ hebasto)
  $ stat .bitcoin/wallets | grep id
  Access: (0775/drwxrwxr-x)  Uid: ( 1000/ hebasto)   Gid: ( 1000/ hebasto)
  ```

  Both directories, in fact, are created with system default permissions.

  With this PR:
  ```
  $ stat .bitcoin/wallets | grep id
  Access: (0700/drwx------)  Uid: ( 1000/ hebasto)   Gid: ( 1000/ hebasto)
  $ stat .bitcoin/wallets | grep id
  Access: (0700/drwx------)  Uid: ( 1000/ hebasto)   Gid: ( 1000/ hebasto)
  ```

  ---

  This PR:
  - is alternative to bitcoin/bitcoin#13389
  - fixes bitcoin/bitcoin#15902
  - fixes bitcoin/bitcoin#22595
  - closes bitcoin/bitcoin#13371
  - reverts bitcoin/bitcoin#4286

  Changes in behavior: removed `-sysperms` command-line argument / configure option. The related discussions are here:
  - https://github.com/bitcoin/bitcoin/pull/13389#issuecomment-395306690
  - https://github.com/bitcoin/bitcoin/pull/13389#issuecomment-539906114
  - https://github.com/bitcoin/bitcoin/pull/13389#discussion_r279160472

  If users rely on non-default access permissions, they could use `chmod`.

ACKs for top commit:
  john-moffett:
    ACK c9ba4f9ecb
  willcl-ark:
    ACK c9ba4f9ecb

Tree-SHA512: 96c745339e6bd0e4d7bf65daf9a721e2e1945b2b0ab74ca0f66576d0dc358b5de8eb8cdb89fe2160f3b19c39d2798bb8b291784316085dc73a27102d3415bd57
2023-02-07 10:44:40 +00:00
Hennadii Stepanov
c9ba4f9ecb
test: Add test for file system permissions 2023-02-06 11:08:57 +00:00
MarcoFalke
aff75463e2
Merge bitcoin/bitcoin#27036: test: Remove last uses of snprintf and simplify
b8032293e6 Remove use of snprintf and simplify (John Moffett)

Pull request description:

  These are the only remaining uses of `snprintf` in our project, and they can cause unexpected issues -- for example, see https://github.com/bitcoin/bitcoin/issues/27014. Change them to use our `ToString` (which uses a locale-independent version of `std::to_string`) to convert an `int` to `std::string`. Also remove resulting unused parts of `StringContentsSerializer`.

  Closes https://github.com/bitcoin/bitcoin/issues/27014

ACKs for top commit:
  Sjors:
    tACK b8032293e6, fixes #27014.

Tree-SHA512: c903977e654711929decafe8887d0de13b38a340d7082875acc5d41950d834dcfde074e9cabecaf5f9a760f62c34322297b4b156af29761650ef5803b1a54b59
2023-02-06 10:32:55 +01:00
John Moffett
b8032293e6 Remove use of snprintf and simplify
One test case uses snprintf to convert an
int to a string. Change it to use ToString
(which uses a locale-independent version of
std::to_string). Also remove unnecessary
parts of StringContentsSerializer.
2023-02-03 12:35:54 -05:00
Antoine Poinsot
dfc9acbf01
rpc: decode Miniscript descriptor when possible in decodescript
The descriptor inference logic would previously always use a dummy
signing provider and would never analyze the witness script of a P2WSH
scriptPubKey.

Note even a valid Miniscript might not always be decodable from Script
without more contextual information (for instance the key preimage for a
pk_h).
2023-02-03 18:15:42 +01:00
Sebastian Falbesoner
dee8549be3 test: simplify and speedup mempool_updatefromblock.py by using MiniWallet 2023-02-03 17:23:26 +01:00
Andrew Chow
fdd363ebd9
Merge bitcoin/bitcoin#26910: wallet: migrate wallet, exit early if no legacy data exist
6d31900e52 wallet: migrate wallet, exit early if no legacy data exist (furszy)

Pull request description:

  The process first creates a backup file then return an error,
  without removing the recently created file, when notices that
  the db is already running sqlite.

ACKs for top commit:
  john-moffett:
    ACK 6d31900e52
  achow101:
    ACK 6d31900e52
  ishaanam:
    crACK 6d31900e52

Tree-SHA512: 9fb52e80de96e129487ab91bef13647bc4570a782003b1e37940e2a00ca26283fd24ad39bdb63a984ae0a56140b518fd0d74aa2fc59ab04405b2c179b7d3c54a
2023-02-01 17:14:13 -05:00
MarcoFalke
357d750cab
Merge bitcoin/bitcoin#26956: test: refactor: introduce replace_in_config helper
b530d9605d test: refactor: introduce `replace_in_config` helper (Sebastian Falbesoner)

Pull request description:

  Currently two functional tests (p2p_permissions.py and wallet_crosschain.py) include quite similar code for substituting strings in a TestNode's bitcoind configuration file, so refactoring that out to a dedicated helper method seems to make sense (probably other tests could need that too in the future).

ACKs for top commit:
  kouloumos:
    ACK b530d9605d

Tree-SHA512: 5ca65a2ef3292460e5720d5c6acf7326335001858e8f71ab054560117f9479dbadb1dacd8c9235f67f3fcfd08dbc761b62704f379cbf619bba8804f16a25bc7b
2023-01-31 10:23:37 +01:00
Martin Leitner-Ankerl
5f05b27841 Add xoroshiro128++ PRNG
Xoroshiro128++ is a fast non-cryptographic random generator.
Reference implementation is available at https://prng.di.unimi.it/

Co-Authored-By: Pieter Wuille <pieter@wuille.net>
2023-01-30 18:12:21 -05:00
glozow
b1329b7523
Merge bitcoin/bitcoin#26499: wallet: Abandon descendants of orphaned coinbases
b0fa5989e1 test: Check that orphaned coinbase unconf spend is still abandoned (Andrew Chow)
9addbd7890 wallet: Automatically abandon orphaned coinbases and their children (Andrew Chow)

Pull request description:

  When a block is reorged out of the main chain, any descendants of the coinbase will no longer be valid. Currently they are only marked as inactive, which means that our balance calculations will still include them. In order to be excluded from the balance calculation, they need to either be abandoned or conflicted. This PR goes with the abandoned method.

  Note that even when they are included in balance calculations, coin selection will not select outputs belonging to these transactions because they are not in the mempool.

  Fixes #14148

ACKs for top commit:
  furszy:
    ACK b0fa5989 with a not-blocking nit.
  aureleoules:
    reACK b0fa5989e1
  ishaanam:
    ACK b0fa5989e1

Tree-SHA512: 68f12e7aa8df392d8817dc6ac0becce8dbe83837bfa538f47027e6730e5b2e1b1a090cfcea2dc598398fdb66090e02d321d799f087020d7e1badcf96e598c3ac
2023-01-30 10:09:41 +00:00
Sebastian Falbesoner
b530d9605d test: refactor: introduce replace_in_config helper 2023-01-28 23:49:55 +01:00
Martin Zumsande
6548ba68e8 test: fix intermittent errors in p2p_ibd_stalling.py
Using is_connected instead of num_test_p2p_connections
ensures that python has taken notice that the p2p was
disconnected.
2023-01-27 15:28:21 -05:00
Andrew Chow
835212cd1d
Merge bitcoin/bitcoin#25880: p2p: Make stalling timeout adaptive during IBD
39b93649c4 test: add functional test for IBD stalling logic (Martin Zumsande)
0565951f34 p2p: Make block stalling timeout adaptive (Martin Zumsande)

Pull request description:

  During IBD, there is the following stalling mechanism if we can't proceed with assigning blocks from a 1024 lookahead window because all of these blocks are either already downloaded or in-flight: We'll mark the peer from which we expect the current block that would allow us to advance our tip (and thereby move the 1024 window ahead) as a possible staller. We then give this peer 2 more seconds to deliver a block (`BLOCK_STALLING_TIMEOUT`) and if it doesn't, disconnect it and assign the critical block we need to another peer.

  Now the problem is that this second peer is immediately marked as a potential staller using the same mechanism and given 2 seconds as well - if our own connection is so slow that it simply takes us more than 2 seconds to download this block, that peer will also be disconnected (and so on...), leading to repeated disconnections and no progress in IBD. This has been described in #9213, and I have observed this when doing IBD  on slower connections or with Tor - sometimes there would be several minutes without progress, where all we did was disconnect peers and find new ones.

  The `2s` stalling timeout was introduced in #4468, when blocks weren't full and before Segwit increased the maximum possible physical size of blocks - so I think it made a lot of sense back then.
  But it would be good to revisit this timeout now.

  This PR makes the timout adaptive (idea by sipa):
  If we disconnect a peer for stalling, we now double the timeout for the next peer (up to a maximum of 64s). If we connect a block, we half it again up to the old value of 2 seconds. That way, peers that are comparatively slower will still get disconnected, but long phases of disconnecting all peers shouldn't happen anymore.

  Fixes #9213

ACKs for top commit:
  achow101:
    ACK 39b93649c4
  RandyMcMillan:
    Strong Concept ACK 39b93649c4
  vasild:
    ACK 39b93649c4
  naumenkogs:
    ACK 39b93649c4

Tree-SHA512: 85bc57093b2fb1d28d7409ed8df5a91543909405907bc129de7c6285d0810dd79bc05219e4d5aefcb55c85512b0ad5bed43a4114a17e46c35b9a3f9a983d5754
2023-01-27 01:53:21 -05:00
MarcoFalke
ffc22b7d42
Merge bitcoin/bitcoin#26923: test: refactor: simplify p2p_{tx_download,eviction}.py by using MiniWallet
8609f24be2 test: refactor: simplify p2p_eviction.py by using MiniWallet (Sebastian Falbesoner)
7aa4b32cd4 test: refactor: simplify p2p_tx_download.py by using MiniWallet (Sebastian Falbesoner)

Pull request description:

  Similar to #26892, this PR simplies the functional tests p2p_tx_download.py and p2p_eviction.py by using MiniWallet in order to avoid manual low-level tx creation. For the latter, rather than mining 100 blocks manually, the pre-mined chain of the test framework is used.

  These instances were found via `$ git grep signrawtransactionwithkey ./test/functional`. AFAICT, there are no other instances where MiniWallet could replace tx creation trivially.

ACKs for top commit:
  MarcoFalke:
    review ACK 8609f24be2

Tree-SHA512: dfb0103fe7f0625d125e8e4408baed8bfc1ff579954af17d0ead5277e05f933b2c2d98a0093e8109e947635f1718d5c58d837ab825f26077fac0a40575bd3e6f
2023-01-26 15:54:06 +01:00
Sebastian Falbesoner
ab4efad51b test: fix immediate tx relay in wallet_groups.py 2023-01-26 02:56:34 +01:00
fanquake
ab98673f05
Merge bitcoin/bitcoin#26929: rpc: Throw more user friendly arg type check error (1.5/2)
fafeddfe0e rpc: Throw more user friendly arg type check error (MarcoFalke)

Pull request description:

  The arg type check error doesn't list which arg (position or name) failed. Fix that.

ACKs for top commit:
  stickies-v:
    ACK fafeddfe0e - although I think the functional test isn't in a logical place (but not blocking)

Tree-SHA512: 17425aa145aab5045940ec74fff28f0e3b2b17ae55f91c4bb5cbcdff0ef13732f8e31621d85964dc2c04333ea37dbe528296ac61be27541384b44e37957555c8
2023-01-25 15:25:49 +00:00
MarcoFalke
0486148f75
Merge bitcoin/bitcoin#26829: init: Remove unnecessary sensitive flag from rpcbind
b9d5674541 init: Remove sensitive flag from rpcbind (Andrew Chow)

Pull request description:

  `-rpcbind` is currently flagged as a sensitive option which means that its value will be masked when the command line args are written to the debug.log file. However this is not useful as if `rpcbind` is actually activated, the bound IP addresses will be written to the log anyways. The test `feature_config_args.py` did not catch this contradiction as the test node was not started with `rpcallowip` and so `rpcbind` was not acted upon.

  This also brings `rpcbind` inline with `bind` as that is not flagged as sensitive either.

ACKs for top commit:
  Sjors:
    re-utACK b9d5674541
  willcl-ark:
    ACK b9d5674
  theStack:
    ACK b9d5674541

Tree-SHA512: 50ab5ad2e18ae70649deb1ac429d404b5f5c41f32a4943b2041480580152df22e72d4aae493379d0b23fcb649ab342376a82119760fbf6dfdcda659ffd3e244a
2023-01-25 15:32:41 +01:00
Andrew Chow
b9d5674541 init: Remove sensitive flag from rpcbind 2023-01-23 17:25:02 -05:00
MarcoFalke
fa952fad2f
test: Avoid rpc timeout in p2p_headers_sync_with_minchainwork 2023-01-23 16:35:13 +01:00
MarcoFalke
fa88c043d1
test: Fix intermittent feature_rbf issue 2023-01-21 11:18:12 +01:00
MarcoFalke
fafeddfe0e
rpc: Throw more user friendly arg type check error 2023-01-20 13:26:47 +01:00
MarcoFalke
250598a905
Merge bitcoin/bitcoin#26906: test: add an easy way to run linters locally
b68e5a7fef lint: specify the right commit range when running locally (James O'Beirne)
dff7ed5732 test: add an easy way to run linters locally (James O'Beirne)

Pull request description:

  Adds a Dockerfile configuration ~~(originally written mostly by fanquake)~~ that allows straightforward running of linters with compatible versions locally. This removes a ton of annoyance when trying to appease CI, because many of the linter versions are quite old and difficult to maintain locally.

  I realize that people may not be thrilled to add more ancillary tooling to the repo, but I think this makes a lot of sense given the linter versions listed in this container configuration are dictated by this repo (within the CI configuration), so having these things live in two separate places is a recipe for version mismatches.

  Eventually we can likely just use this container on CI directly to avoid any chance of inconsistencies between local dev experience and CI.

ACKs for top commit:
  aureleoules:
    ACK b68e5a7fef
  stickies-v:
    ACK b68e5a7fe
  john-moffett:
    ACK b68e5a7fef

Tree-SHA512: 7ef7a5dae023d81fdb6296d5d92dfa074ee321c7993e607c9f014d0f21c91558611aa00fc3ce1edc7b5e68371aea0d27fa1931291a79bb867a6c783bb536775f
2023-01-19 19:01:28 +01:00
Sebastian Falbesoner
8609f24be2 test: refactor: simplify p2p_eviction.py by using MiniWallet
Also, use the pre-mined chain of the test framework rather than
mining 100 blocks manually on each run.
2023-01-19 16:11:27 +01:00
Sebastian Falbesoner
7aa4b32cd4 test: refactor: simplify p2p_tx_download.py by using MiniWallet 2023-01-19 16:08:55 +01:00
MarcoFalke
92dcbe9cc3
Merge bitcoin/bitcoin#23395: util: Add -shutdownnotify option
d96d97ad30  doc: Add release note for shutdownnotify. (klementtan)
0bd73e2c45 util: Add -shutdownnotify option. (klementtan)

Pull request description:

  **Description**: Similar to `-startupnotify`, this PR adds a new option to allow users to specify a command to be executed when Bitcoin Core shuts down.

  **Note**: The `shutdownnotify` commands will not be executed if bitcoind shut down due to *unexpected* reasons (ie `killall -9 bitcoind`).

  ### Testing:
  **Normal shutdown commands**
  ```
  # start bitcoind with shutdownnotify optioin
  ./src/bitcoind -signet -shutdownnotify="touch foo.txt"

  # shutdown bitcoind
  ./src/bitcoin-cli -signet stop

  # check that foo.txt has been created
  ```

  **Final RPC call**
  Commands:
  ```
  $  ./src/bitcoind -signet -nolisten -noconnect -shutdownnotify="./src/bitcoin-cli -signet getblockchaininfo > tmp.txt"
  $ ./src/bitcoin-cli stop
  $ cat tmp.txt
  ```
  <details>
  <summary>Screen Shot</summary>

  ![image](https://user-images.githubusercontent.com/49265907/141186183-cbc6f82c-400d-4a8b-baba-27c0346c2c8a.png)
  </details>

ACKs for top commit:
  achow101:
    ACK d96d97ad30
  1440000bytes:
    ACK d96d97ad30
  theStack:
    re-ACK d96d97ad30

Tree-SHA512: 16f7406fd232e8b97aea5e58854c84755b0c35c88cb3ef9ee123b29a1475a376122b1e100da860cc336d4d657e6046a70e915fdb9b70c9fd097c6eef1b028161
2023-01-19 10:34:54 +01:00
furszy
6d31900e52
wallet: migrate wallet, exit early if no legacy data exist
otherwise the process will create a backup file then return
an error when notices that the db is already running sqlite.
2023-01-18 13:47:31 -03:00
James O'Beirne
dff7ed5732 test: add an easy way to run linters locally
Adds a Dockerfile configuration
that allows straightforward running of linters with compatible versions
locally. This removes a ton of annoyance when trying to appease CI,
because many of the linter versions are quite old and difficult to
maintain locally.

I realize that people may not be thrilled to more ancillary tooling to
the repo, but I think this makes a lot of sense given the linter
versions listed in this container configuration are dictated by this
repo (within the CI configuration), so having these things live in
two separate places is a recipe for version mismatches.

Eventually we can likely just use this container on CI directly to avoid
any chance of inconsistencies between local dev experience and CI.
2023-01-18 09:48:08 -05:00
MarcoFalke
fa8fe5b696
scripted-diff: Use new python 3.7 keywords
-BEGIN VERIFY SCRIPT-
 sed -i 's/universal_newlines/text/g' $(git grep -l universal_newlines)
-END VERIFY SCRIPT-
2023-01-18 13:00:34 +01:00
Aurèle Oulès
962a0930e6
Improve address decoding errors 2023-01-17 18:31:51 +01:00
fanquake
89fb354f28
Merge bitcoin/bitcoin#26625: test: Run mempool_packages.py with MiniWallet
fa6b402114 test: Run mempool_packages.py with MiniWallet (MarcoFalke)
fa448c27d2 test: Return fee from MiniWallet (MarcoFalke)
faec09f240 test: Return chain of MiniWallet txs from MiniWallet chain method (MarcoFalke)
faa12d4ccd test: Refactor MiniWallet sign_tx (MarcoFalke)
fa2d82103f test: Return wtxid from create_self_transfer_multi (MarcoFalke)

Pull request description:

  This allows to run the test even when no wallet is compiled in.

  Also, it is a lot nicer to read now.

ACKs for top commit:
  glozow:
    reACK fa6b402

Tree-SHA512: de0338068fd51db01d64ce270f94fd2982a63a6de597325cd1e1f11127e9075bd4aeacace0ed76d09a2db8b962b27237cf11edb4c1fe1a01134d397f8a11bd05
2023-01-17 16:39:45 +00:00
MarcoFalke
fa96f93f05
test: Add test for missing and omitted required arg 2023-01-17 12:31:59 +01:00
Seibart Nedor
4c8ecccdcd test: add tests for outputs argument to bumpfee/psbtbumpfee 2023-01-17 13:28:53 +02:00
MarcoFalke
635f1900d0
Merge bitcoin/bitcoin#26884: test: wallet: add coverage for -spendzeroconfchange setting
603d295199 test: wallet: add coverage for `-spendzeroconfchange` setting (Sebastian Falbesoner)
50112034bc test: remove `-spendzeroconfchange` setting from mempool_limit.py (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `-spendzeroconfchange` setting (in particular the non-default case `=0`). Note that in contrast to the name, the setting does not only apply to change outputs, but in fact to _all_ unconfirmed outputs that we sent to ourselves, i.e. we can trigger the testing path simply with a single recipient address. The first commit removes the setting from the functional test mempool_limit.py, where it doesn't have any effect, since the test was changed to use MiniWallet in commit dddca3899c.

ACKs for top commit:
  brunoerg:
    crACK 603d295199

Tree-SHA512: 15d9c8bd5eb37c6b228bf887eb27debee0a391c82356662785da4553ee2558e611834c3936ef7136812b46f877bab7aa5f3088bbd278b81f296bdda96cc8e1c3
2023-01-17 11:13:50 +01:00
fanquake
7799f53542
Merge bitcoin/bitcoin#26039: refactor: Run type check against RPCArgs (1/2)
fa9f6d7bcd rpc: Run type check against RPCArgs (MarcoFalke)
faf96721a6 test: Fix wrong types passed to RPCs (MarcoFalke)

Pull request description:

  It seems brittle to require `RPCTypeCheck` being called inside the code logic. Without compile-time enforcement this will lead to places where it is forgotten and thus to inconsistencies and bugs. Fix this by removing the calls to `RPCTypeCheck` and doing the check internally.

  The changes should be reviewed as refactoring changes. However, if they change behavior, it will be a bugfix. For example the changes here happen to also detect/fix bugs like the one fixed in commit 3b5fb6e77a.

ACKs for top commit:
  ajtowns:
    ACK fa9f6d7bcd

Tree-SHA512: fb2c0981fe6e24da3ca7dbc06898730779ea4e02ea485458505a281cf421015e44dad0221a04023fc547ea2c660d94657909843fc85d92b847611ec097532439
2023-01-17 09:39:26 +00:00
MarcoFalke
fa6b402114
test: Run mempool_packages.py with MiniWallet 2023-01-17 10:33:45 +01:00
MarcoFalke
fa448c27d2
test: Return fee from MiniWallet 2023-01-17 10:33:22 +01:00
MarcoFalke
faec09f240
test: Return chain of MiniWallet txs from MiniWallet chain method 2023-01-17 10:32:36 +01:00
MarcoFalke
faa12d4ccd
test: Refactor MiniWallet sign_tx
To make the code less verbose and easier to read.
2023-01-17 10:32:23 +01:00
MarcoFalke
fa2d82103f
test: Return wtxid from create_self_transfer_multi
This is not used right now, but may be in the future. Also, it
simplifies the create_self_transfer return logic
2023-01-17 10:30:00 +01:00
MarcoFalke
8339f3cea8
Merge bitcoin/bitcoin#26886: test: add rescan utxos inside MiniWallet's initialization
6bd098a838 test: simplify tests by using the pre-mined chain (kouloumos)
42029a7fd4 test: remove redundant blocks generation logic (kouloumos)
0377d6bb42 test: add `rescan_utxos` in MiniWallet's initialization (kouloumos)

Pull request description:

  When a pre-mined blockchain is used (default behavior), it [contains coinbase outputs in blocks 76-10](07c54de550/test/functional/test_framework/test_framework.py (L809-L813)) to [the MiniWallet's default address](07c54de550/test/functional/test_framework/wallet.py (L99-L101)). That's why we always* `rescan_utxos()` after initializing the MiniWallet, in order for the MiniWallet to account for those mature UTXOs.

  > The tests following this usage pattern can be seen with:
  > ```git grep -n "MiniWallet(" $(git grep -le "rescan_utxos()" $(git grep -Le "self.setup_clean_chain = True"))```

  **This PR adds `rescan_utxos()` inside MiniWallet's initialization to simplify usage when the MiniWallet is used with a pre-mined chain.**

  ### secondary changes

  - *There are a few tests that use the pre-mined blockchain but do not `rescan_utxos()`, they instead generate new blocks to create mature UTXOs.

    > Those were written before the `rescan_utxos()` method was introduced with https://github.com/bitcoin/bitcoin/pull/22955 (fac66d0a39) and can be seen with:
    > `git grep -n "MiniWallet(" $(git grep -Le "rescan_utxos()" $(git grep -Le "self.setup_clean_chain = True"))`
    >

    After including `rescan_utxos()` inside MiniWallets initilization, this blocks generation logic is not needed as the MiniWallet already accounts for enough mature UTXOs to perform the tests. **Therefore the now redundant blocks generation logic is removed from those tests with the second commit.**

  - The rest of the MiniWallet tests use a clean chain (`self.setup_clean_chain = True`)  and can be seen with
    `git grep -n "MiniWallet(" $(git grep -le "self.setup_clean_chain = True")`

    From those, there are a few that start from a clean chain and then create enough mature UTXOs for the MiniWallet with this kind of logic:
   07c54de550/test/functional/mempool_expiry.py (L36-L40)

    **Those tests are simplified in the third commit to instead utilize the mature UTXOs of the pre-mined chain.**

ACKs for top commit:
  MarcoFalke:
    ACK 6bd098a838 🕷
  theStack:
    re-ACK 6bd098a838

Tree-SHA512: 7f9361e36910e4000c33a32efdde4449f4a8a763bb42df96de826fcde469f9362f701b8c99e2a2c482d2d5a42a83ae5ae3844fdbed187ed0ff231f386c222493
2023-01-17 09:38:32 +01:00
Andrew Chow
04e54fd21f
Merge bitcoin/bitcoin#26325: rpc: Return accurate results for scanblocks
5ca7a7be76 rpc: Return accurate results for scanblocks (Aurèle Oulès)

Pull request description:

  Implements #26322.
  Adds a `filter_false_positives` mode to `scanblocks` to accurately verify results from blockfilters.

  If the option is enabled, pre-results given by blockfilters will be filtered out again by checking vouts and vins of all transactions of the relevant blocks against the given descriptors.

  ### Master
  ```bash
  ./src/bitcoin-cli -testnet -named scanblocks action=start scanobjects='["addr(tb1qcxf2gv93c26s6mqz7y6etpqdf70zmn67dualgr)"]'
  {
    "from_height": 0,
    "to_height": 2376055,
    "relevant_blocks": [
      "000000000001bc35077dec4104e0ab1f667ae27059bd907f9a8fac55c802ae36",
      "00000000000120a9c50542d73248fb7c37640c252850f0cf273134ad9febaf61",
      "0000000000000082f7af3835da8b6146b0bfb243b8842f09c495fa1e74d454ed",
      "0000000000000094c32651728193bfbe91f6789683b8d6ac6ae2d22ebd3cb5d3"
    ]
  }
  ```

  ### PR (without `filter_false_positives` mode)
  Same as master
  ```bash
  ./src/bitcoin-cli -testnet -named scanblocks action=start scanobjects='["addr(tb1qcxf2gv93c26s6mqz7y6etpqdf70zmn67dualgr)"]' filter_false_positives=false
  {
    "from_height": 0,
    "to_height": 2376055,
    "relevant_blocks": [
      "000000000001bc35077dec4104e0ab1f667ae27059bd907f9a8fac55c802ae36",
      "00000000000120a9c50542d73248fb7c37640c252850f0cf273134ad9febaf61",
      "0000000000000082f7af3835da8b6146b0bfb243b8842f09c495fa1e74d454ed",
      "0000000000000094c32651728193bfbe91f6789683b8d6ac6ae2d22ebd3cb5d3"
    ]
  }
  ```

  ### PR (with `filter_false_positives` mode)
  ```bash
  ./src/bitcoin-cli -testnet -named scanblocks action=start scanobjects='["addr(tb1qcxf2gv93c26s6mqz7y6etpqdf70zmn67dualgr)"]' filter_false_positives=true
  {
    "from_height": 0,
    "to_height": 2376058,
    "relevant_blocks": [
      "0000000000000082f7af3835da8b6146b0bfb243b8842f09c495fa1e74d454ed",
      "0000000000000094c32651728193bfbe91f6789683b8d6ac6ae2d22ebd3cb5d3"
    ]
  }
  ```

  Also adds a test to check that the blockhash of a transaction will be included in the `relevant_blocks` whether the `filter_false_positives` mode is enabled or not.

ACKs for top commit:
  achow101:
    ACK 5ca7a7be76
  theStack:
    re-ACK 5ca7a7be76
  furszy:
    Code review ACK 5ca7a7be

Tree-SHA512: e8f3cceddddd66f59509717b6314d89e2fef241e13cee81b18fd95e8362cbb95cc40f884342ce6cf892a86febd9e2d434afce05d51892240e67f72ae991852e7
2023-01-16 17:39:51 -05:00
Andrew Chow
b55b11f92a
Merge bitcoin/bitcoin#25375: rpc: add minconf/maxconf options to sendall and fund transaction calls
cfe5aebc79 rpc: add minconf and maxconf options to sendall (ishaanam)
a07a413466 Wallet/RPC: Allow specifying min & max chain depth for inputs used by fund calls (Juan Pablo Civile)

Pull request description:

  This PR adds a "minconf" option to `fundrawtransaction`, `walletcreatefundedpsbt`,  and `sendall`.
  Alternative implementation of #14641
  Fixes #14542

  Edit: This PR now also adds this option to `send`

ACKs for top commit:
  achow101:
    ACK cfe5aebc79
  Xekyo:
    ACK cfe5aebc79
  furszy:
    diff ACK cfe5aebc, only a non-blocking nit.

Tree-SHA512: 836e610926eec3a62308fba88ddbd6a13d8f4dac37352d0309599f893cde9c1df5e9c298fda6e076493068e4d213e4afa7290a9e3bdb5a95a5d507da3f7b59e8
2023-01-16 17:23:51 -05:00
kouloumos
6bd098a838 test: simplify tests by using the pre-mined chain 2023-01-16 19:14:21 +02:00
kouloumos
42029a7fd4 test: remove redundant blocks generation logic
those tests already have enough mature utxos from the pre-mined chain.
2023-01-16 19:14:11 +02:00
kouloumos
0377d6bb42 test: add rescan_utxos in MiniWallet's initialization
this simplifies usage when MiniWallet is used with a pre-mined chain.
2023-01-16 19:01:09 +02:00
MarcoFalke
599e941c19
Merge bitcoin/bitcoin#26657: test: Run feature_bip68_sequence.py with MiniWallet
4159ccd031 test: Run feature_bip68_sequence.py with MiniWallet (Miles Liu)
fc0caaf4aa test: Add "include mempool" flag to MiniWallet rescan_utxos (Miles Liu)
d0a909ae54 test: Add "include immature coinbase" flag to MiniWallet get_utxos (Miles Liu)
e5b9127d9e test: Add signs P2TR and RAWSCRIPT to MiniWallet sign_tx (Miles Liu)

Pull request description:

  This PR enables one more of the non-wallet functional tests (feature_bip68_sequence.py) to be run even when no wallet is compiled in by using the MiniWallet instead, as proposed in #20078.

ACKs for top commit:
  achow101:
    ACK 4159ccd031
  MarcoFalke:
    review ACK 4159ccd031 🤸

Tree-SHA512: e891b189381e961c840b45fc30d058363707fd54c1c4bdc3d29623b03309981f1d3ebfac27e6aecf621bdbcd7e31754a3ef7c53f86346f7dd241c137e64c92bd
2023-01-16 16:26:12 +01:00
MarcoFalke
2182149dc5
Merge bitcoin/bitcoin#26631: test: add coverage for dust mempool policy (-dustrelayfee setting)
d6fc1d6a33 test: add coverage for dust mempool policy (`-dustrelayfee` setting) (Sebastian Falbesoner)
8a5dbe2879 test: add `CScript` method for checking for witness program (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `-dustrelayfee` setting, which specifies the fee-rate used to define dust. Output scripts for all common types that are treated as standard by default (P2PK, P2(W)PKH, P2(W)SH, P2TR, bare multisig, null data, unknown witness versions v2+) are created and then checked for dust-mempool-policy each via the `testmempoolaccept` RPC: a tx with an output's nValue equal to the dust threshold should be accepted, one with an nValue of just one 1 satoshi below that should be rejected with reason `dust`. This is repeatedly done for a fixed (but obviously somewhat arbitrary) list of different `-dustrelayfee` settings on a single node, including the default and zero (i.e. no dust limit) settings.

  Note that the first commit introduces a necessary `CScript` helper method `IsWitnessProgram` (using PascalCase in Python is likely controversial; in this case the style for the already existing method `GetSigOpCount` was followed, which also refers to a method in the core `CScript` class).

  Some historical information about dust, contributed by pablomartin4btc:
  "The concept of dust was first introduced in https://github.com/bitcoin/bitcoin/pull/2577. This [commit](eb30d1a5b2) from https://github.com/bitcoin/bitcoin/pull/9380 introduced the -dustrelayfee option. Previous to that PR, the dust feerate was whatever -minrelaytxfee was set to."

ACKs for top commit:
  LarryRuane:
    ACK d6fc1d6a33
  glozow:
    ACK d6fc1d6a33
  kouloumos:
    ACK d6fc1d6a33

Tree-SHA512: 35ea2b2497dfb466395af5665bb217f7250aa7cab9dc43539a5658ab69a454e3623ff58fce7489fcc1105b37f8cb4840a93cec658c5df1de611732bc6439ccad
2023-01-16 11:36:13 +01:00
MarcoFalke
ac4c79a267
Merge bitcoin/bitcoin#26892: test: refactor: simplify p2p_permissions.py by using MiniWallet
8cbd926a2c test: refactor: simplify p2p_permissions.py by using MiniWallet (Sebastian Falbesoner)

Pull request description:

  This PR simplies the functional test p2p_permissions.py by using MiniWallet in order to avoid manual low-level tx creation. Also, rather than mining 100 blocks manually, the pre-mined chain of the test framework is used, which speeds up the test a little (~2-3 seconds faster on my machine).

ACKs for top commit:
  MarcoFalke:
    ACK 8cbd926a2c

Tree-SHA512: 36cbc2a0f6fb0251c8696cd017163ed30529690736bafd36e80b53007bd02b9030b68fe93b90dc50323526c8b7d8e0abd8f20890d46ff6015d5c632b64a08535
2023-01-16 10:37:14 +01:00
Kolby ML
61360e0cf9 test: Remove redundant function call 2023-01-15 18:34:01 -07:00
Sebastian Falbesoner
8cbd926a2c test: refactor: simplify p2p_permissions.py by using MiniWallet
Also, use the pre-mined chain of the test framework rather than mining
100 blocks manually on each run.
2023-01-15 01:11:15 +01:00
Sebastian Falbesoner
603d295199 test: wallet: add coverage for -spendzeroconfchange setting 2023-01-13 21:56:17 +01:00
brunoerg
a1aaa7f51f rpc, wallet: add abandoned field for all categories of transactions in ListTransactions 2023-01-13 10:29:00 -03:00
Sebastian Falbesoner
50112034bc test: remove -spendzeroconfchange setting from mempool_limit.py
Since this test was changed to use MiniWallet instead of the Bitcoin
Core wallet (see commit d447ded6ba),
the setting doesn't have any effect and hence can be removed.
2023-01-13 03:41:42 +01:00
fanquake
eea73d465e
test: skip sqlite3 tests if it isn't available
Fixes #26819. Related too #26873.
2023-01-12 13:37:15 +00:00
MarcoFalke
edc3d1b296
Merge bitcoin/bitcoin#26854: test: Fix intermittent timeout in p2p_permissions.py
fa1bf4e705 test: Fix intermittent timeout in p2p_permissions.py (MarcoFalke)

Pull request description:

  The sync is based on `bytesrecv_per_msg["verack"]`. However, the bytes are counted before processing the message, so they are not sufficient to ensure the connection is fully up.

ACKs for top commit:
  mzumsande:
    ACK fa1bf4e705
  aureleoules:
    ACK fa1bf4e705

Tree-SHA512: eb1ed537032c76a449b1ed5e42ff062e9b8b3c7e11fde2a5b8183ae0d6fbe31dba39e2c758836160cd8157d9ac5cc1f5d1916415861b8d711b7370c88f5e9790
2023-01-12 12:51:34 +01:00
Andrew Chow
fbe5e1220a
Merge bitcoin/bitcoin#26675: wallet: For feebump, ignore abandoned descendant spends
f9ce0eadf4 For feebump, ignore abandoned descendant spends (John Moffett)

Pull request description:

  Closes #26667

  To be eligible for fee-bumping, a transaction must not have any of its outputs (eg - change) spent in other unconfirmed transactions in the wallet. This behavior is currently [enforced](9e229a542f/src/wallet/feebumper.cpp (L25-L28)) and [tested](9e229a542f/test/functional/wallet_bumpfee.py (L270-L286)).

  However, this check shouldn't apply to spends in abandoned descendant transactions, as explained by #26667.

  `CWallet::IsSpent` already carves out an exception for abandoned transactions, so we can just use that.

  I've also added a new test to cover this case.

ACKs for top commit:
  Sjors:
    re-utACK f9ce0eadf4
  achow101:
    ACK f9ce0eadf4
  furszy:
    ACK f9ce0ead

Tree-SHA512: 19d957d1cf6747668bb114e27a305027bfca5a9bed2b1d9cc9e1b0bd4666486c7c4b60b045a7fe677eb9734d746f5de76390781fb1e9e0bceb4a46d20acd1749
2023-01-11 18:24:53 -05:00
ishaanam
cfe5aebc79 rpc: add minconf and maxconf options to sendall 2023-01-11 17:08:35 -05:00
Juan Pablo Civile
a07a413466 Wallet/RPC: Allow specifying min & max chain depth for inputs used by fund calls
Enables users to craft BIP-125 replacements with changes to the output
list, ensuring that if additional funds are needed they will be added.
2023-01-11 17:08:23 -05:00
MarcoFalke
faf96721a6
test: Fix wrong types passed to RPCs 2023-01-11 17:41:34 +01:00
MarcoFalke
fa1bf4e705
test: Fix intermittent timeout in p2p_permissions.py 2023-01-11 15:20:17 +01:00
MarcoFalke
b168b71a5d
Merge bitcoin/bitcoin#26730: test: add coverage for purpose arg in listlabels
c467cfffce test: add coverage for `purpose` arg in `listlabels` (brunoerg)

Pull request description:

  This PR adds test coverage for `listlabels` command when specifying the `purpose` (send and receive).

  dcdfd72861/src/wallet/rpc/addresses.cpp (L698-L704)

ACKs for top commit:
  kristapsk:
    ACK c467cfffce

Tree-SHA512: 7e7143c1264692f7b22952e7c70dbe9ed3f5dcd2e3b69962a47be9f9c21b3f4a9089ca87962fbc8ff9116e7d2dbeb7f36d6a132c9ac13724a255cfe1b32373a8
2023-01-11 14:55:37 +01:00
glozow
26002570ab
Merge bitcoin/bitcoin#26646: validation, bugfix: provide more info in *MempoolAcceptResult
264f9ef17f [validation] return MempoolAcceptResult for every tx on PCKG_TX failure (glozow)
dae81e01e8 [refactor] rename variables in AcceptPackage for clarity (glozow)
da484bc738 [doc] release note effective-feerate and effective-includes RPC results (glozow)
5eab397b98 [validation] remove PackageMempoolAcceptResult::m_package_feerate (glozow)
601bac88cb [rpc] return effective-includes in testmempoolaccept and submitpackage (glozow)
1691eaa818 [rpc] return effective-feerate in testmempoolaccept and submitpackage (glozow)
d6c7b78ef2 [validation] return wtxids of other transactions whose fees were used (glozow)
1605886380 [validation] return effective feerate from mempool validation (glozow)
5d35b4a7de [test] package validation quits early due to non-policy, non-missing-inputs failure (glozow)
be2e4d94e5 [validation] when quitting early in AcceptPackage, set package_state and tx result (glozow)

Pull request description:

  This PR fixes a bug and improves the mempool accept interface to return information more predictably.

  Bug: In package validation, we first try the transactions individually (see doc/policy/packages.md for more explanation) and, if they all failed for missing inputs and policy-related (i.e. fee) reasons, we'll try package validation. Otherwise, we'll just "quit early" since, for example, if a transaction had an invalid signature, adding a child will not help make it valid. Currently, when we quit early, we're not setting the `package_state` to be invalid, so the caller might think it succeeded. Also, we're returning no results - it makes more sense to return the individual transaction failure. Thanks instagibbs for catching https://github.com/bitcoin/bitcoin/pull/25038#discussion_r1013293248!

  Also, make the package results interface generally more useful/predictable:
  - Always return the feerate at which a transaction was considered for `CheckFeeRate` in `MempoolAcceptResult::m_effective_feerate` when it was successful. This can replace the current `PackageMempoolAcceptResult::m_package_feerate`, which only sometimes exists.
  - Always provide an entry for every transaction in `PackageMempoolAcceptResult::m_tx_results` when the error is `PCKG_TX`.

ACKs for top commit:
  instagibbs:
    reACK 264f9ef17f
  achow101:
    ACK 264f9ef17f
  naumenkogs:
    reACK 264f9ef17f

Tree-SHA512: ce7fd9927a80030317cc6157822596e85a540feff5dbf5eea7c62da2eb50c917cdddc9da1e2ff62cc18b98b27d360151811546bd9d498859679a04bbee090837
2023-01-11 13:25:39 +00:00
MarcoFalke
dbca00ef76
Merge bitcoin/bitcoin#26838: doc: I2P documentation updates
3e1d2941e9 doc: remove recommended I2P router versions (jonatack)
295849abb5 doc: update/clarify/de-emphasize I2P transient address section (jonatack)
dffa319457 doc: update bandwidth section of I2P documentation (jonatack)
0ed9cc5892 doc: clarify -i2pacceptincoming help documentation (jonatack)

Pull request description:

  Address the documentation updates requested in issue #26754, clarify/simplify the -i2pacceptincoming help, and a few other fixups.

ACKs for top commit:
  willcl-ark:
    ACK 3e1d294
  1440000bytes:
    ACK 3e1d2941e9
  w0xlt:
    ACK 3e1d2941e9
  vasild:
    ACK 3e1d2941e9

Tree-SHA512: e647221884af34646b99150617f4d4cc8d5fce325a769294f49047b9d8c9c8ab2b365cfdd9f56b3bd0303da706233f03d24cececf6e161c53f04ed947751052a
2023-01-11 13:03:54 +01:00
Andrew Chow
b0fa5989e1 test: Check that orphaned coinbase unconf spend is still abandoned
When an orphaned coinbase is reorged back into the main chain, any
unconfirmed ancestors should still be marked as abandoned due to the
original reorg that orphaned that coinbase.
2023-01-10 18:25:20 -05:00
Andrew Chow
9addbd7890 wallet: Automatically abandon orphaned coinbases and their children 2023-01-10 18:23:45 -05:00
Andrew Chow
68f88bc03f
Merge bitcoin/bitcoin#26186: rpc: Sanitize label name in various RPCs with tests
65e78bda7c test: Invalid label name coverage (Aurèle Oulès)
552b51e682 refactor: Add sanity checks in LabelFromValue (Aurèle Oulès)
67e7ba8e1a rpc: Sanitize label name in various RPCs (Aurèle Oulès)

Pull request description:

  The following RPCs did not sanitize the optional label name:
  - importprivkey
  - importaddress
  - importpubkey
  - importmulti
  - importdescriptors
  - listsinceblock

  Thus is was possible to import an address with a label `*` which should not be possible.
  The wildcard label is used for backwards compatibility in the `listtransactions` rpc.
  I added test coverage for these RPCs.

ACKs for top commit:
  ajtowns:
    ACK 65e78bda7c
  achow101:
    ACK 65e78bda7c
  furszy:
    diff ACK 65e78bd
  stickies-v:
    re-ACK 65e78bda7c
  theStack:
    re-ACK 65e78bda7c

Tree-SHA512: ad99f2824d4cfae352166b76da4ca0069b7c2eccf81aaa0654be25bbb3c6e5d6b005d93960f3f4154155f80e12be2d0cebd5529922ae3d2a36ee4eed82440b31
2023-01-10 17:31:19 -05:00
glozow
5eab397b98 [validation] remove PackageMempoolAcceptResult::m_package_feerate
This value creates an extremely confusing interface as its existence is
dependent upon implementation details (whether something was submitted
on its own, etc). MempoolAcceptResult::m_effective_feerate is much more
helpful, as it always exists for submitted transactions.
2023-01-10 11:09:03 +00:00
glozow
601bac88cb [rpc] return effective-includes in testmempoolaccept and submitpackage 2023-01-10 11:07:38 +00:00
glozow
1691eaa818 [rpc] return effective-feerate in testmempoolaccept and submitpackage 2023-01-10 11:06:10 +00:00
jonatack
0ed9cc5892 doc: clarify -i2pacceptincoming help documentation
and also hoist the default setting to a constexpr and
remove unused f-string operators in a related functional test.
2023-01-09 08:18:47 -08:00
brunoerg
abccb27466 test: add coverage for absolute timestamp in setban 2023-01-06 13:33:38 -03:00
brunoerg
b99f1f20f7 p2p, rpc: don't allow past absolute timestamp in setban 2023-01-06 13:33:38 -03:00
MarcoFalke
adc41cf3b2
Merge bitcoin/bitcoin#26805: tests: Use unique port for ZMQ tests to allow for multiple test instances
c6119f4788 tests: Use unique port for ZMQ tests (Andrew Chow)

Pull request description:

  The ZMQ interface tests should use unique ports as we do for the p2p and rpc ports so that multiple instances of the test can be run at the same time.

  Without this, the test may hang until killed, or fail.

ACKs for top commit:
  MarcoFalke:
    ACK c6119f4788

Tree-SHA512: 2ca3ed2f35e5a83d7ab83740674fed362a8d146dc751156cfe100133a591347cd1ac9d164046f1744d65451a57c52cb22d3bb2161105f421f8f655c4a2512c59
2023-01-06 16:31:34 +01:00
Aurèle Oulès
5ca7a7be76
rpc: Return accurate results for scanblocks
This makes use of undo data to accurately verify results
from blockfilters.
2023-01-06 12:01:22 +01:00
Miles Liu
4159ccd031
test: Run feature_bip68_sequence.py with MiniWallet 2023-01-06 09:52:39 +08:00
Miles Liu
fc0caaf4aa
test: Add "include mempool" flag to MiniWallet rescan_utxos 2023-01-06 09:52:39 +08:00
Miles Liu
d0a909ae54
test: Add "include immature coinbase" flag to MiniWallet get_utxos 2023-01-06 09:52:39 +08:00
Miles Liu
e5b9127d9e
test: Add signs P2TR and RAWSCRIPT to MiniWallet sign_tx 2023-01-06 09:52:39 +08:00
Andrew Toth
3141eab9c6 test: add functional test for ScanAndUnlinkAlreadyPrunedFiles 2023-01-05 17:04:28 -05:00
brunoerg
4bdcf57158 test: test banlist database recreation 2023-01-05 17:42:27 -03:00
Andrew Chow
b4fb0a3255
Merge bitcoin/bitcoin#26761: wallet: fully migrate address book entries for watchonly/solvable wallets
730e14a317 test: wallet: check that labels are migrated to watchonly wallet (Sebastian Falbesoner)
d5f4ae7fac wallet: fully migrate address book entries for watchonly/solvable wallets (Sebastian Falbesoner)

Pull request description:

  Currently `migratewallet` migrates the address book (i.e. labels and purposes) for watchonly and solvable wallets only in RAM, but doesn't persist them on disk. Fix this by adding another loop for both of the special wallet types after which writes the corresponding NAME and PURPOSE entries to the database in a single batch. Also adds a corresponding test that checks if labels were migrated correctly for a watchonly wallet.

ACKs for top commit:
  achow101:
    ACK 730e14a317
  furszy:
    code ACK 730e14a3, left a non-blocking nit.
  aureleoules:
    ACK 730e14a317

Tree-SHA512: 159487e11e858924ef762e0190ccaea185bdff239e3d2280c8d63c4ac2649ec71714dc4d53dec644f03488f91c3b4bbbbf3434dad23bc0fcecb6657f353ea766
2023-01-05 12:22:51 -05:00
MarcoFalke
fac810bb0a
test: Fix feature_startupnotify intermittent issue 2023-01-05 14:10:07 +01:00
MarcoFalke
296e882250
Merge bitcoin/bitcoin#26598: contrib: remove builder keys
e6864fa157 contrib: remove builder keys (fanquake)

Pull request description:

  This has been superseded by adding a builder-keys/ directory in
  guix.sigs, where the presence of keys, and validity of signatures
  is checked. Preventing issues like missing keys or invalid signatures.

  New (or exisiting) Guix builders can add their key in the next PR
  they open adding attestations.

  Related to issues like #26566, #26563.

  Also follows up with the comment here: https://github.com/bitcoin/bitcoin/pull/26565#issuecomment-1326053939.

ACKs for top commit:
  hebasto:
    ACK e6864fa157, modulo s/update/remove/ in the PR tittle.

Tree-SHA512: 095b4cf12ed0baeaf0ee7b8edcb3e2647e9c0f812e8fd63915ddb454f81dacc9c2d2b409de2773b7adb5ff643893d614d8aad1bc44c26da648e1bbbe19e11e05
2023-01-05 09:18:16 +01:00
Andrew Chow
360e047a71
Merge bitcoin/bitcoin#26747: wallet: fix confusing error / GUI crash on cross-chain legacy wallet restore
21ad4e26ec test: add coverage for cross-chain wallet restore (Sebastian Falbesoner)
8c7222bda3 wallet: fix GUI crash on cross-chain legacy wallet restore (Sebastian Falbesoner)

Pull request description:

  Restoring a wallet backup from another chain should result in a dedicated error message (we have _"Wallet files should not be reused across chains. Restart bitcoind with -walletcrosschain to override."_ for that). Unfortunately this is currently not the case for legacy wallet restores, as in the course of cleaning up the newly created wallet directory a `filesystem_error` exception is thrown due to the directory not being empty; the wallet database did indeed load successfully (otherwise we wouldn't know that the chain doesn't match) and hence BDB-related files and directories are already created in the wallet directory.

  For bitcoind, this leads to a very confusing error message:
  ```
  $ ./src/bitcoin-cli restorewallet test123 ~/.bitcoin/regtest/wallets/regtest_wallet/wallet.dat
  error code: -1
  error message: filesystem error: in remove: Directory not empty ["/home/thestack/.bitcoin/wallets/test123"]
  ```

  Even worse, the GUI crashes in such a scenario:
  ```
  libc++abi: terminating with uncaught exception of type std::__1::__fs::filesystem::filesystem_error: filesystem error: in remove: Directory not empty ["/home/thestack/.bitcoin/wallets/foobar"]
  Abort trap (core dumped)
  ```

  Fix this by simply deleting the whole folder via `fs::remove_all`. With this, the expected error message appears both for the `restorewallet` RPC call and in the GUI (as a message-box):

  ```
  $ ./src/bitcoin-cli restorewallet test123 ~/.bitcoin/regtest/wallets/regtest_wallet/wallet.dat
  error code: -4
  error message:
  Wallet loading failed. Wallet files should not be reused across chains. Restart bitcoind with -walletcrosschain to override.
  ```

ACKs for top commit:
  achow101:
    ACK 21ad4e26ec
  aureleoules:
    ACK 21ad4e26ec
  furszy:
    utACK 21ad4e26

Tree-SHA512: 313f6494c2fbe823bff9b975cb2d9410bb518977a1e59a5159ee9836bc012947fa50b56be0e41b1a2f50d9c0c7f4fddfdf4fbe479d8a59a6ee44bb389c804abc
2023-01-04 17:46:37 -05:00
MarcoFalke
4bb840a453
Merge bitcoin/bitcoin#26802: test: Use same Python executable for subprocesses as for all-lint.py
f6eadaa413 Use same Python executable for subprocesses as for all-lint.py (Kristaps Kaupe)

Pull request description:

  Before this all linters were ran by `/usr/bin/env python3`, no matter what was used to run `test/lint/all-lint.py`. This change allows to use non-default Python executable for `test/lint/all-lint.py` and then all subprocesses will also use same Python interpreter (for example, `python3.10 ./test/lint/all-lint.py`). See https://github.com/bitcoin/bitcoin/issues/26792#issuecomment-1369558866 as use case.

ACKs for top commit:
  fanquake:
    ACK f6eadaa413 - did not test

Tree-SHA512: 4da3b5581a0dd8ab9a6387829495019091a93a7ceaf2135d65d40a1983fd11a0b92b20891ef30d2a132abb0a690cd9b2f7eb5fcc38df06a340394ef449d640af
2023-01-04 13:53:27 +01:00
Aurèle Oulès
65e78bda7c
test: Invalid label name coverage 2023-01-04 13:45:05 +01:00
Andrew Chow
3f8591d46b
Merge bitcoin/bitcoin#26661: wallet: Coin Selection, return accurate error messages
76dc547ee7 gui: create tx, launch error dialog if backend throws runtime_error (furszy)
f4d79477ff wallet: coin selection, add duplicated inputs checks (furszy)
0aa065b14e wallet: return accurate error messages from Coin Selection (furszy)
7e8340ab1a wallet: make SelectCoins flow return util::Result (furszy)
e5e147fe97 wallet: refactor eight consecutive 'AttemptSelection' calls into a loop (furszy)

Pull request description:

  Work decoupled from #25806, which cleanup and improves the Coin Selection flow further.

  Adding the capability to propagate specific error messages from the Coin Selection process to the user.
  Instead of always returning the general "Insufficient funds" message which is not always accurate to what happened internally.
  Letting us instruct the user how to proceed under certain circumstances.

  The following error messages were added:

  1) If the selection result exceeds the maximum transaction weight,
     we now will return:
  -> "The inputs size exceeds the maximum weight. Please try sending
  a smaller amount or manually consolidating your wallet's UTXOs".

  2) If the user pre-selected inputs and disallowed the automatic coin
     selection process (no other inputs are allowed), we now will
     return:
  -> "The preselected coins total amount does not cover the transaction
  target. Please allow other inputs to be automatically selected or include
  more coins manually".

  3) The double-counted preset inputs during Coin Selection error will now
  throw an "internal bug detected" message instead of crashing the node.

  The essence of this work comes from several comments:
  1. https://github.com/bitcoin/bitcoin/pull/26560#discussion_r1037395665
  2. https://github.com/bitcoin/bitcoin/pull/25729#discussion_r940619491
  3. https://github.com/bitcoin/bitcoin/pull/25269#pullrequestreview-1135240825
  4. https://github.com/bitcoin/bitcoin/issues/23144 (which is connected to #24845)

ACKs for top commit:
  ishaanam:
    crACK 76dc547ee7
  achow101:
    ACK 76dc547ee7
  aureleoules:
    ACK 76dc547ee7
  theStack:
    ACK 76dc547ee7 🌇

Tree-SHA512: 9de30792d7a5849cae77747aa978e70390b66ee9d082779a56088a024f82e725b0af050e6603aece0ac8229f6d73bc471ba97b4ab69dc7eddf419f5f56ae89a5
2023-01-03 18:53:36 -05:00
Sebastian Falbesoner
21ad4e26ec test: add coverage for cross-chain wallet restore 2023-01-04 00:06:05 +01:00
Andrew Chow
c6119f4788 tests: Use unique port for ZMQ tests
The ZMQ interface tests should use unique ports as we do for the p2p and
rpc ports so that multiple instances of the test can be run at the same
time.
2023-01-03 17:30:26 -05:00
Kristaps Kaupe
f6eadaa413
Use same Python executable for subprocesses as for all-lint.py 2023-01-03 23:23:07 +02:00
Jon Atack
459cb637ac script, test: fix python linter E275 errors with flake8 5.0.4 2023-01-03 10:59:56 -08:00
Andrew Chow
cb552c5f21
Merge bitcoin/bitcoin#26192: rpc: Improve error when wallet is already loaded
04609284ad rpc: Improve error when wallet is already loaded (Aurèle Oulès)

Pull request description:

  Currently, trying to load a descriptor (sqlite) wallet that is already loaded throws the following error:
  > error code: -4
  > error message:
  > Wallet file verification failed. SQLiteDatabase: Unable to obtain an exclusive lock on the database, is it being used by another instance of Bitcoin Core?

  I don't think it is very clear what it means for a user.

  While a legacy wallet would throw:
  > error code: -35
  > error message:
  > Wallet file verification failed. Refusing to load database. Data file '/home/user/.bitcoin/signet/wallets/test_wallet/wallet.dat' is already loaded.

  This PR changes the error message for both types of wallet to:
  > error code: -35
  > error message:
  > Wallet file verification failed. Wallet "test_wallet" is already loaded.

ACKs for top commit:
  achow101:
    ACK 04609284ad
  hernanmarino:
    ACK  0460928
  theStack:
    Tested ACK 04609284ad

Tree-SHA512: a8f3d5133bfaef7417a6c05d160910ea08f32ac62bfdf7f5ec305ff5b62e9113b55f385abab4d5a4ad711aabcb1eb7ef746eb41f841b196e8fb5393ab3ccc01e
2023-01-03 13:02:20 -05:00
Yusuf Sahin HAMZA
057057a2d7
Add test for sendmany rpc that uses subtractfeefrom parameter 2023-01-01 02:53:16 +03:00
MarcoFalke
faa835e7e5
Revert "test: Drop no longer needed race:epoll_ctl TSan suppression"
This reverts commit a3f5e54152.
2022-12-30 09:47:52 +01:00
MarcoFalke
3b6e0f0345
Merge bitcoin/bitcoin#26738: test: add coverage for unknown wallet flag in setwalletflag
3666a06730 test: add coverage for unknown wallet flag in `setwalletflag` (brunoerg)

Pull request description:

  This PR adds test coverage for the following error:
  6d40a1a7e7/src/wallet/rpc/wallet.cpp (L275-L277)

  https://marcofalke.github.io/btc_cov/total.coverage/src/wallet/rpc/wallet.cpp.gcov.html

ACKs for top commit:
  aureleoules:
    ACK 3666a06730

Tree-SHA512: b6b2415442dfbc2404aed9720cc899995686007d6ba222dae461d064e4454d5af1326d3d527770b51b1005721ac42a49972f1eabf21108f656c30d3584790747
2022-12-29 11:46:56 +01:00
Sebastian Falbesoner
730e14a317 test: wallet: check that labels are migrated to watchonly wallet 2022-12-28 13:51:08 +01:00
Hennadii Stepanov
a3f5e54152
test: Drop no longer needed race:epoll_ctl TSan suppression 2022-12-27 18:33:34 +00:00
Hennadii Stepanov
306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00
Fabian Jahr
fe329dc936
test: Add test for getblockfrompeer on pruned nodes 2022-12-22 20:01:47 +01:00
furszy
0aa065b14e
wallet: return accurate error messages from Coin Selection
and not the general "Insufficient funds" when the wallet
actually have funds.

Two new error messages:

1) If the selection result exceeds the maximum transaction weight,
   we now will return: "The inputs size exceeds the maximum weight".

2) If the user preselected inputs and disallowed the automatic coin
   selection process (no other inputs are allowed), we now will
   return: "The preselected coins total amount does not cover the
   transaction target".
2022-12-21 23:14:50 -03:00
Andrew Chow
f3bc1a7282
Merge bitcoin/bitcoin#26265: POLICY: Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65 non-witness bytes
b2aa9e8528 Add release note for MIN_STANDARD_TX_NONWITNESS_SIZE relaxation (Greg Sanders)
8c5b3646b5 Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65 non-witness bytes (Greg Sanders)

Pull request description:

  Since the original fix was set to be a "reasonable" transaction to reduce allocations and the true motivation later revealed, it makes sense to relax this check to something more principled.

  There are more exotic transaction patterns that could take advantage of a relaxed requirement, such as 1 input, 1 output OP_RETURN to burn a utxo to fees for CPFP purposes when change isn't practical.

  Two changes could be accomplished:

  1) Anything not 64 bytes could be allowed

  2) Anything above 64 bytes could be allowed

  In the Great Consensus Cleanup, suggestion (2)
  was proposed as a consensus change, and is the simpler of the two suggestions. It would not allow an "empty" OP_RETURN but would reduce the required padding from 22 bytes to 5.

  The functional test is also modified to test the actual case
  we care about: 64 bytes

  Related mailing list discussions here:
  https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2022-October/020995.html
  And a couple years earlier:
  https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-May/017883.html

ACKs for top commit:
  achow101:
    reACK b2aa9e8528
  glozow:
    reACK b2aa9e8528
  pablomartin4btc:
    re-ACK b2aa9e8528
  jonatack:
    ACK b2aa9e8528 with some suggestions

Tree-SHA512: c1ec1af9ddcf31b2272209a4f1ee0c5607399f8172e5a1dfd4604cf98bfb933810dd9369a5917ad122add003327c9fcf6ee26995de3aca41d5c42dba527991ad
2022-12-21 12:58:46 -05:00
brunoerg
3666a06730 test: add coverage for unknown wallet flag in setwalletflag 2022-12-21 11:03:24 -03:00
MarcoFalke
6d40a1a7e7
Merge bitcoin/bitcoin#26694: test: get_previous_releases.py: M1/M2 macs can't run unsigned arm64 binaries; self-sign when needed
dc12f2e212 test: improve error msg on previous release tarball extraction failure (kdmukai)
7121fd8fa7 test: self-sign previous release binaries for arm64 macOS (kdmukai)

Pull request description:

  ## The Problem
  If you run `test/get_previous_releases.py -b` on an M1 or M2 mac, you'll get an unsigned v23.0 binary in the arm64 tarball. macOS [sets stricter requirements on ARM binaries](https://news.ycombinator.com/item?id=26996578) so the unsigned arm64 binary is apparently completely unusable without being signed/notarized(?).

  This means that any test that depends on a previous release (e.g. `wallet_backwards_compatibility.py`) will fail because the v23.0 node cannot launch:

  ```
  TestFramework (ERROR): Assertion failed
  Traceback (most recent call last):
    File "/Users/kdmukai/dev/bitcoin-core/test/functional/test_framework/test_framework.py", line 563, in start_nodes
      node.wait_for_rpc_connection()
    File "/Users/kdmukai/dev/bitcoin-core/test/functional/test_framework/test_node.py", line 231, in wait_for_rpc_connection
      raise FailedToStartError(self._node_msg(
  test_framework.test_node.FailedToStartError: [node 2] bitcoind exited with status -9 during initialization
  ```

  This can also be confirmed by downloading bitcoin-23.0-arm64-apple-darwin.tar.gz (https://bitcoincore.org/bin/bitcoin-core-23.0/) and trying to run any of the binaries manually on an M1 or M2 mac.

  ## Solution in this PR
  (UPDATED) Per @ hebasto, we can self-sign the arm64 binaries. This PR checks each binary in the previous release's "bin/" and verifies if the arm64 binary is signed. If not, attempt to self-sign and confirm success.

  (note: an earlier version of this PR downloaded the x86_64 binary as a workaround but this approach has been discarded)

  ## Longer term solution
  If possible, produce signed arm64 binaries in a future v23.x tarball?

  Note that this same problem affects the new v24.0.1 arm64 tarball so perhaps a signed v24.x.x tarball would also be ideal?

  That being said, this PR will check all current and future arm64 binaries and self-sign as needed, so perhaps we need not worry about pre-signing the tarball binaries. And I did test a version of `get_previous_releases.py` that includes the new v24.0.1 binaries and it successfully self-signed both v23.0 and v24.0.1, as expected.

  ## Further info:
  Somewhat related to: https://github.com/bitcoin/bitcoin/issues/15774#issuecomment-1265164753

  And @ fanquake noted on IRC that you can confirm which binaries are or are not signed via:
  ```
  $ codesign -v -d bitcoin-qt
  bitcoin-qt: code object is not signed at all
  ```

ACKs for top commit:
  hebasto:
    ACK dc12f2e212

Tree-SHA512: 644895f8e97f5ffb3c4754c1db2c48abd77fa100c2058e3c896af04806596fc2b9c807a3f3a2add5be53301ad40ca2b8171585bd254e691f6eb38714d938396b
2022-12-21 11:02:20 +01:00
MarcoFalke
0139a0d5c0
Merge bitcoin/bitcoin#26722: test: speed up the two slowest functional tests by 18-35% via keypoolrefill()
31fdc54dba test: speed up wallet_fundrawtransaction.py and wallet_sendall.py (kdmukai)

Pull request description:

  ## Problem
  `wallet_fundrawtransaction.py` and `wallet_sendall.py` are the two slowest functional tests *when running without a RAM disk*.
  ```
  # M1 MacBook Pro timings
  wallet_fundrawtransaction.py --descriptors   | ✓ Passed  | 55 s
  wallet_fundrawtransaction.py --legacy-wallet | ✓ Passed  | 381 s

  wallet_sendall.py --descriptors   | ✓ Passed  | 43 s
  wallet_sendall.py --legacy-wallet | ✓ Passed  | 327 s
  ```

  In each case, the majority of the time is spent iterating through 1500 to 1600 `getnewaddress()` calls. This is particularly slow in the `--legacy-wallet` runs.

  see:  https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_fundrawtransaction.py#L986-L987
  see:  https://github.com/bitcoin/bitcoin/blob/master/test/functional/wallet_sendall.py#L324

  ## Solution
  Pre-fill the keypool before iterating through those `getnewaddress()` calls.

  With this change, the execution time drops to:
  ```
  wallet_fundrawtransaction.py --descriptors   | ✓ Passed  | 52 s     # -3s diff
  wallet_fundrawtransaction.py --legacy-wallet | ✓ Passed  | 291 s    # -90s diff

  wallet_sendall.py --descriptors   | ✓ Passed  | 27 s     # -16s diff
  wallet_sendall.py --legacy-wallet | ✓ Passed  | 228 s    # -99s diff
  ```

  ---

  Tagging @ Sjors as he had encouraged me to take a look at speeding up the tests.

ACKs for top commit:
  achow101:
    ACK 31fdc54dba

Tree-SHA512: e8dd89323551779832a407d068977c827c09dff55c1079d3c19aab39fcce6957df22b1da797ed7aa3bc2f6dd22fdf9e6f5e1a9a0200fdb16ed6042fc5f6dd992
2022-12-21 09:06:24 +01:00
Andrew Chow
8456bfac6b
Merge bitcoin/bitcoin#26638: test: prefer sqlite for wallet tests
17554efb60 test: prefer sqlite for wallet tests (S3RK)
8e0fabaabf test: make wallet_migration.py pass with both wallet flags (S3RK)

Pull request description:

  Fixes #26511

ACKs for top commit:
  MarcoFalke:
    review ACK 17554efb60
  achow101:
    ACK 17554efb60

Tree-SHA512: 97cae275998f07032feffe1b533d4747b8ff03c3c1fb830af69ee38cadb75fd58532956f66f79c0d275b00620ce53b0b5240f885e4f29b8bd4d0b6e6cbc683fa
2022-12-20 18:12:08 -05:00
Andrew Chow
cbcad79eef
Merge bitcoin/bitcoin#21576: rpc, gui: bumpfee signer support
2c07cfacd1 gui: bumpfee signer support (Sjors Provoost)
7e02a33297 rpc: bumpfee signer support (Sjors Provoost)
304ece9945 rpc: document bools in FillPSBT() calls (Sjors Provoost)

Pull request description:

  The `bumpfee` RPC call and GUI fee bump interface now work with an external signer.

ACKs for top commit:
  achow101:
    ACK 2c07cfacd1
  furszy:
    code review ACK 2c07cfac
  jarolrod:
    tACK 2c07cfa

Tree-SHA512: 0c7b931f76fac67c9e33b9b935f29af6f69ac67a5ffcc586ed2f1676feac427735b1d971723b29ef332bb6fb5762949598ebbf728587e8f0ded95a9bfbb3e7a4
2022-12-20 15:30:17 -05:00
brunoerg
c467cfffce test: add coverage for purpose arg in listlabels 2022-12-20 11:15:28 -03:00
fanquake
dcdfd72861
Merge bitcoin/bitcoin#26721: test, lint: add crypted to ignore-words
a4defcdd57 test, lint: add `crypted` to `ignore-words` (brunoerg)

Pull request description:

  Fixes #26719

  "Crypted" is used in some comments at `walletload_tests` because it refers to `DBKeys::CRYPTED_KEY`, it's not necessary
  a mistake.

  Obs: I can change the approach (changing `walletload_tests` comments to use `encrypted` word instead of adding it to the `ignore_words`) if reviewers think it makes more sense.

ACKs for top commit:
  achow101:
    ACK a4defcdd57

Tree-SHA512: 49f38eed30ffb0fda4e792566591c3455629379619eb9a5c4240c5b00e14cd27ba1faa36337192233752e642f0998373b86fcb8ca586508bbf15900d68b17950
2022-12-20 11:46:07 +00:00
kdmukai
dc12f2e212 test: improve error msg on previous release tarball extraction failure 2022-12-19 11:25:33 -06:00
fanquake
e6864fa157
contrib: remove builder keys
This has been superseded by adding a builder-keys/ directory in
guix.sigs, where the presence of keys, and validity of signatures
is checked. Preventing issues like missing keys or invalid signatures.

New (or exisiting) Guix builders can add their key in the next PR
they open adding attestations.
2022-12-19 17:21:35 +00:00
kdmukai
7121fd8fa7 test: self-sign previous release binaries for arm64 macOS 2022-12-19 11:18:24 -06:00
kdmukai
31fdc54dba test: speed up wallet_fundrawtransaction.py and wallet_sendall.py 2022-12-19 11:12:40 -06:00
Greg Sanders
8c5b3646b5 Relax MIN_STANDARD_TX_NONWITNESS_SIZE to 65 non-witness bytes
Since the original fix was set to be a "reasonable" transaction
to reduce allocations and the true motivation later revealed,
it makes sense to relax this check to something more principled.

There are more exotic transaction patterns that could take advantage
of a relaxed requirement, such as 1 input, 1 output OP_RETURN to burn
a utxo to fees for CPFP purposes when change isn't practical.

Two changes could be accomplished:

1) Anything not 64 bytes could be allowed

2) Anything above 64 bytes could be allowed

In the Great Consensus Cleanup, suggestion (2) was the route taken.
It would not allow an "empty" OP_RETURN
but would reduce the required padding from 22 bytes to 5.

The functional test is also modified to test the actual case
we care about: 64 bytes
2022-12-19 10:03:51 -05:00
MarcoFalke
8ab19237e1
Merge bitcoin/bitcoin#26723: test: call keypoolrefill with priv key disabled should throw an error
ec63a4892e test: call `keypoolrefill` with private keys disabled should throw an error (brunoerg)

Pull request description:

  This PR adds test coverage for the following error:
  cb32328d1b/src/wallet/rpc/addresses.cpp (L332-L334)

ACKs for top commit:
  aureleoules:
    ACK ec63a4892e

Tree-SHA512: b5deda8981ff472f290e6e16c8723a58e02cbe099afd1f672c099f4add0a1d9b192b11a2c3f0e11b96794671f6b9efa75812b7a174248d7c58d7fd7d3310e7b9
2022-12-19 15:17:44 +01:00
MarcoFalke
bd13d6b369
Merge bitcoin/bitcoin#26656: tests: Improve runtime of some tests when --enable-debug
1647a11f39 tests: Reorder longer running tests in test_runner (Andrew Chow)
ff6c9fe027 tests: Whitelist test p2p connection in rpc_packages (Andrew Chow)
8c20796aac tests: Use waitfornewblock for work queue test in interface_rpc (Andrew Chow)
6c872d5e65 tests: Initialize sigops draining script with bytes in feature_taproot (Andrew Chow)
544cbf776c tests: Use batched RPC in feature_fee_estimation (Andrew Chow)
4ad7272f8b tests: reduce number of generated blocks for wallet_import_rescan (Andrew Chow)

Pull request description:

  When configured with `--enable-debug`, many tests become dramatically slower. These slow downs are particularly noticed in tests that generate a lot of blocks in separate calls, make a lot of RPC calls, or send a lot of data from the test framework's P2P connection. This PR aims to improve the runtime of some of the slower tests and improve the overall runtime of the test runner. This has improved the runtime of the test runner from ~400s to ~140s on my computer.

  The slowest test by far was `wallet_import_rescan.py`. This was taking ~320s. Most of that time was spent waiting for blocks to be mined and then synced to the other nodes. It was generating a new block for every new transaction it was creating in a setup loop. However it is not necessary to have one tx per block. By mining a block only every 10 txs, the runtime is improved to ~61s.

  The second slowest test was `feature_fee_estimation.py`. This test spends most of its time waiting for RPCs to respond. I was able to improve its runtime by batching RPC requests. This has improved the runtime from ~201s to ~140s.

  In `feature_taproot.py`, the test was constructing a Python `CScript` using a very large list of `OP_CHECKSIG`s. The constructor for the Python implementation of `CScript` was iterating this list in order to create a `bytes` from it even though a `bytes` could be created from it without iterating. By making the `bytes` before passing it into the constructor, we are able to improve this test's runtime from ~131s to ~106s.

  Although `interface_rpc.py` was not typically a slow test, I found that it would occasionally have a super long runtime. It typically takes ~7s, but I have observed it taking >400s to run on occasion. This longer runtime occurs more often when `--enable-debug`. This long runtime was caused by the "exceeding work queue" test which is really just trying to trigger a race condition. In this test, it would create a few threads and try an RPC in a loop in the hopes that eventually one of the RPCs would be added to the work queue while another was processing. It used `getrpcinfo` for this, but this function is fairly fast. I believe what was happening was that with `--enable-debug`, all of the code for receiving the RPC would often take longer to run than the RPC itself, so the majority of the requests would succeed, until we got lucky after 10's of thousands of requests. By changing this to use a slow RPC, the race condition can be triggered more reliably, and much sooner as well. I've used `waitfornewblock` with a 500ms timeout. This improves the runtime to ~3s consistently.

  The last test I've changed was `rpc_packages.py`. This test was one of the higher runtime variability tests. The main source of this variation appears to be waiting for the test node to relay a transaction to the test framework's P2P connection. By whitelisting that peer, the variability is reduced to nearly 0.

  Lastly, I've reordered the tests in `test_runner.py` to account for the slower runtimes when configured with `--enable-debug`. Some of the slow tests I've looked at were listed as being fast which was causing overall `test_runner.py` runtime to be extended. This change makes the test runner's runtime be bounded by the slowest test (currently `feature_fee_estimation.py` with my usual config (`-j 60`).

ACKs for top commit:
  willcl-ark:
    ACK 1647a11

Tree-SHA512: 529e0da4bc51f12c78a40d6d70b3a492b97723c96a3526148c46943d923c118737b32d2aec23d246392e50ab48013891ef19fe6205bf538b61b70d4f16a203eb
2022-12-19 10:14:35 +01:00
brunoerg
ec63a4892e test: call keypoolrefill with private keys disabled should throw an error 2022-12-18 22:00:38 -03:00
brunoerg
a4defcdd57 test, lint: add crypted to ignore-words 2022-12-18 11:46:32 -03:00
Hennadii Stepanov
2b77a33e5b
test: Improve check-doc.py pattern 2022-12-17 16:25:17 +00:00
Andrew Chow
66c08e741d
Merge bitcoin/bitcoin#24865: rpc: Enable wallet import on pruned nodes and add test
564b580bf0 test: Introduce MIN_BLOCKS_TO_KEEP constant (Aurèle Oulès)
71d9a7c03b test: Wallet imports on pruned nodes (Aurèle Oulès)
e6906fcf9e rpc: Enable wallet import on pruned nodes (Aurèle Oulès)

Pull request description:

  Reopens #16037

  I have rebased the PR, addressed the comments of the original PR and added a functional test.

  > Before this change importwallet fails if any block is pruned. This PR makes it possible to importwallet if all required blocks aren't pruned. This is possible because the dump format includes key timestamps.

  For reviewers:
  `python test/functional/wallet_pruning.py --nocleanup` will generate a large blockchain (~700MB) that can be used to manually test wallet imports on a pruned node. Node0 is not pruned, while node1 is.

ACKs for top commit:
  kouloumos:
    ACK 564b580bf0
  achow101:
    reACK 564b580bf0
  furszy:
    ACK 564b580
  w0xlt:
    ACK 564b580bf0

Tree-SHA512: b345a6c455fcb6581cdaa5f7a55d79e763a55cb08c81d66be5b12794985d79cd51b9b39bdcd0f7ba0a2a2643e9b2ddc49310ff03d16b430df2f74e990800eabf
2022-12-16 17:30:57 -05:00
brunoerg
7a83aa0982 test: add coverage for unparsable -maxuploadtarget 2022-12-16 14:57:19 -03:00
Sebastian Falbesoner
d6fc1d6a33 test: add coverage for dust mempool policy (-dustrelayfee setting) 2022-12-16 15:03:22 +01:00
John Moffett
f9ce0eadf4 For feebump, ignore abandoned descendant spends
To be eligible for fee-bumping, a transaction must not have any
of its outputs (eg - change) spent in other unconfirmed transactions
in the wallet. However, this check should not apply to abandoned
transactions.

A new test case is added to cover this case.
2022-12-15 14:38:25 -05:00
MarcoFalke
9a72119e7e
Merge bitcoin/bitcoin#26651: test: Avoid intermittent timeout in feature_assumevalid.py
fa34e5f3d3 test: Avoid intermittent timeout in feature_assumevalid.py (MarcoFalke)

Pull request description:

  Currently the test will spin up p2p connections in the beginning, then announce the headers to all nodes, but only send the blocks sequentially. This takes a long time, so when getting to the last node, it will have already timed out, while node1 is busy eating blocks. Example:

  ```
   node2 2022-12-06T19:31:35.419291Z [msghand] [net_processing.cpp:5783] [SendMessages] [net] Requesting block 2cfdb317b3b901f79e2d4f96339d0c0dffd8ef2685d324f62ab0e2fa3402430e (1) peer=0
   node2 2022-12-06T19:31:35.424784Z [msghand] [net.cpp:2776] [PushMessage] [net] sending getdata (577 bytes) peer=0
  [...]
   node2 2022-12-06T19:41:35.423257Z [msghand] [net_processing.cpp:5729] [SendMessages] Timeout downloading block 2cfdb317b3b901f79e2d4f96339d0c0dffd8ef2685d324f62ab0e2fa3402430e from peer=0, disconnecting
   node1 2022-12-06T19:41:35.438706Z [msghand] [net_processing.cpp:5783] [SendMessages] [net] Requesting block 6575919043306ed309014d0bd79814b4fab8afaa281e026d8cc3a1c4c2336fbc (1748) peer=0
   node2 2022-12-06T19:41:35.521253Z [net] [net.cpp:573] [CloseSocketDisconnect] [net] disconnecting peer=0
   node2 2022-12-06T19:41:35.630417Z [net] [net_processing.cpp:1532] [FinalizeNode] [net] Cleared nodestate for peer=0
  ```

  Fix this by only spinning up the p2p connection right before they are needed.

ACKs for top commit:
  jamesob:
    ACK fa34e5f3d3 ([`jamesob/ackr/26651.1.MarcoFalke.test_avoid_intermittent`](https://github.com/jamesob/bitcoin/tree/ackr/26651.1.MarcoFalke.test_avoid_intermittent))

Tree-SHA512: 7a1b114c07dfa30237c8cd8637dd6646c5c2dc2530c9de61db231738fddc800b620c31dc664237e33d35e951cf161f015fda593162efc9d85c5f68c6e37217d4
2022-12-15 13:09:06 +01:00
Aurèle Oulès
564b580bf0
test: Introduce MIN_BLOCKS_TO_KEEP constant 2022-12-15 09:53:51 +01:00
Aurèle Oulès
71d9a7c03b
test: Wallet imports on pruned nodes
Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Co-authored-by: Andreas Kouloumos <kouloumosa@gmail.com>
2022-12-15 09:53:50 +01:00
MarcoFalke
678889e6c6
Merge bitcoin/bitcoin#26689: test: add add_wallet_options to TestShell
bcb7123406 test: add add_wallet_options to TestShell (josibake)

Pull request description:

  following 555519d082, `TestShell` now always runs with `-disablewallet`. simple fix is to add `add_wallet_options` to `add_options`; looks like testshell was overlooked when adding in the `add_wallet_options` call to the functional tests in #26480

ACKs for top commit:
  amitiuttarwar:
    ACK bcb7123406

Tree-SHA512: db554a8b3c8ff5bd10cab9592b316035a92f86a0a0ae8ff914de9687bbbb6fc2235bdf82c4cd40e4071782f8b6edf91aad372e82ed3b826c9d8ae39dbe3dbf57
2022-12-14 09:16:02 +01:00
Andrew Chow
daf881de9d
Merge bitcoin/bitcoin#23319: rpc: Return fee and prevout (utxos) to getrawtransaction
f86697163e rpc: Return fee and prevout(s) to getrawtransaction (Douglas Chimento)

Pull request description:

  Add fee response in BTC to getrawtransaction #23264

  ### For Reviewers

  * Verbose arg is now an int
  * Verbose = 2 includes a `fee` field and `prevout`
  * [./test/functional/rpc_rawtransaction.py](./test/functional/rpc_rawtransaction.py) contains a new test to validate fields of new verbosity 2 (not the values)

  ```
  bitcoin-cli -chain=test getrawtransaction 9ae533f7da9be4a34997db78343a8d8d6d6186b6bba3959e56f416a5c70e7de4 2 000000000000001d442e556146d5f2841d85150c200e8d8b8a4b5005b13878f6
  ```
  ```
    "in_active_chain": true,
    "txid": "9ae533f7da9be4a34997db78343a8d8d6d6186b6bba3959e56f416a5c70e7de4",
    "hash": "7f23e3f3a0a256ddea1d35ffd43e9afdd67cc68389ef1a804bb20c76abd6863e",
   ....
    "vin": [
      {
        "txid": "23fc75d6d74f6f97e225839af69ff36a612fe04db58a4414ec4828d1749a05a0",
        "vout": 0,
        "scriptSig": {
          "asm": "",
          "hex": ""
        },
        "prevout": {
          "generated": false,
          "height": 2099486,
          "value": 0.00017764,
          "scriptPubKey": {
            "asm": "0 7846ce1ced3253d8bd43008db2ca364cc722f5a2",
            "hex": "00147846ce1ced3253d8bd43008db2ca364cc722f5a2",
            "address": "tb1q0prvu88dxffa302rqzxm9j3kfnrj9adzk49mlp",
            "type": "witness_v0_keyhash"
          }
        },
        "sequence": 4294967295
      },
  ...
   "fee": 0.00000762
  }
  ```

ACKs for top commit:
  achow101:
    ACK f86697163e
  aureleoules:
    ACK f86697163e
  hernanmarino:
    re ACK f86697163e
  pablomartin4btc:
    re-tACK f86697163e

Tree-SHA512: 591fdc285d74fa7803e04ad01c7b70bc20fac6b1369e7bd5b8e2cde9b750ea52d6c70d79225b74bef4f4bbc0fb960877778017184e146119da4a55f9593d1224
2022-12-13 18:09:09 -05:00
MarcoFalke
a4baf3f177
Merge bitcoin/bitcoin#26628: RPC: Reject RPC requests with same named parameter specified multiple times
8c3ff7d52a test: Suggested cleanups for rpc_namedparams test (Ryan Ofsky)
d1ca563825 bitcoin-cli: Make it an error to specify the "args" parameter two different ways (Ryan Ofsky)
6bd1d20b8c rpc: Make it an error server-side to specify same named parameter multiple times (Ryan Ofsky)
e2c3b18e67 test: Add RPC tests for same named parameter specified more than once (Ryan Ofsky)

Pull request description:

  Make the JSON-RPC server reject requests with the same named parameter specified multiple times, instead of silently overwriting earlier parameter values with later ones.

  Generally JSON keys are supposed to unique, and their order isn't supposed to be significant, so having the server silently discard duplicate keys is error-prone. Most likely if an RPC client is sending a request with duplicate keys it means something is wrong with the request and there should be an error.

  After this change, named parameters are still allowed to specified multiple times on the `bitcoin-cli` command line, since `bitcoin-cli` automatically replaces earlier values with later values before sending the JSON-RPC request. This makes sense, since it's not unusual for the order of command line options to be significant or for later command line options to override earlier ones.

ACKs for top commit:
  MarcoFalke:
    review ACK 8c3ff7d52a 🗂
  kristapsk:
    ACK 8c3ff7d52a
  stickies-v:
    ACK 8c3ff7d52

Tree-SHA512: 2d1357dcc2c171da287aeefc7b333ba4e67babfb64fc14d7fa0940256e18010a2a65054f3bf7fa1571b144d2de8b82d53076111b5f97ba29320cfe84b6ed986f
2022-12-13 17:57:23 +01:00
fanquake
968f03e65c
Merge bitcoin/bitcoin#26477: validation: fix broken maxtipage comparison
e4be0e9b06 test: add -maxtipage test for the maximum allowable value (James O'Beirne)
a451e832b4 fix: validation: cast now() to seconds for maxtipage comparison (James O'Beirne)

Pull request description:

  Since faf44876db, the maxtipage comparison in IsInitialBlockDownload() has been broken, since the NodeClock::now() time_point is in the system's native denomination (nanoseconds).

  Without this patch, specifying the maximum allowable -maxtipage (9223372036854775807) results in a SIGABRT crash:

  ```
  % gdb --args ./src/bitcoind -maxtipage=9223372036854775207 -minimumchainwork=0x00 -stopatheight=30000
  ...
  2022-11-09T15:55:17Z [dnsseed] dnsseed thread exit
  [Thread 0x7fff937fe640 (LWP 69883) exited]

  Thread 29 "b-msghand" received signal SIGABRT, Aborted.
  [Switching to Thread 0x7fff91ffb640 (LWP 69886)]
  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
  44      ./nptl/pthread_kill.c: No such file or directory.
  (gdb) bt
  #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
  #1  0x00007ffff768989f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
  #2  0x00007ffff763da52 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
  #3  0x00007ffff7628469 in __GI_abort () at ./stdlib/abort.c:79
  #4  0x00007ffff7cf79a4 in __mulvdi3 () from /lib/x86_64-linux-gnu/libgcc_s.so.1
  #5  0x00005555558d13ab in std::chrono::__duration_cast_impl<std::chrono::duration<long, std::ratio<1l, 1000000000l> >, std::ratio<1000000000l, 1l>, long, false, true>::__cast<long, std::ratio<1l, 1l> > (__d=...) at /usr/include/c++/12/bits/chrono.h:521
  #6  std::chrono::duration_cast<std::chrono::duration<long, std::ratio<1l, 1000000000l> >, long, std::ratio<1l, 1l> > (__d=...)
      at /usr/include/c++/12/bits/chrono.h:260
  #7  std::chrono::duration<long, std::ratio<1l, 1000000000l> >::duration<long, std::ratio<1l, 1l>, void> (__d=..., this=<optimized out>)
      at /usr/include/c++/12/bits/chrono.h:514
  #8  std::chrono::operator-<long, std::ratio<1l, 1000000000l>, long, std::ratio<1l, 1l> > (__rhs=..., __lhs=...)
      at /usr/include/c++/12/bits/chrono.h:650
  #9  std::chrono::operator-<NodeClock, std::chrono::duration<long, std::ratio<1l, 1000000000l> >, long, std::ratio<1l, 1l> > (__rhs=...,
      __lhs=...) at /usr/include/c++/12/bits/chrono.h:1020
  #10 Chainstate::IsInitialBlockDownload (this=0x555556071940) at ./src/validation.cpp:1545
  #11 0x00005555556efd1e in operator() (__closure=<optimized out>) at ./src/net_processing.cpp:3369
  #12 (anonymous namespace)::PeerManagerImpl::ProcessMessage (this=0x555556219be0, pfrom=..., msg_type=..., vRecv=..., time_received=...,
      interruptMsgProc=...) at ./src/net_processing.cpp:3369
  #13 0x00005555556f75cc in (anonymous namespace)::PeerManagerImpl::ProcessMessages (this=0x555556219be0, pfrom=<optimized out>,
      interruptMsgProc=std::atomic<bool> = { false }) at ./src/net_processing.cpp:4985
  #14 0x00005555556a83c9 in CConnman::ThreadMessageHandler (this=0x5555560ebc70) at ./src/net.cpp:2014
  #15 0x0000555555c4d5d6 in std::function<void ()>::operator()() const (this=0x7fff91ffadb0) at /usr/include/c++/12/bits/std_function.h:591
  #16 util::TraceThread(std::basic_string_view<char, std::char_traits<char> >, std::function<void ()>) (
      thread_name="0\255\377\221\377\177\000\000\v\000\000\000\000\000\000\000TraceThread\000\000\000\000\000P\255\377\221\377\177\000\000\017\000\000\000\000\000\000\000util/thread.cpp\000\000\000\000\000\000\000\000\000\000ihB鵿6\000\000\000\000\000\000\000\000\260\255\377\221\377\177\000\000\277\211\321UUU\000\000p\324\304UUU\000\000\002\000\000\000\000\000\000\000\240xh\367\377\177\000\000\000\000\000\000\000\000\000\000]\340iUUU\000\000p\274\016VUU\000\000\000\000\000\000\000\000\000\000\300\303iUUU\000\000p\206jUUU", '\000' <repeats 11 times>, "ihB鵿6\200\251!VUU\000\000"..., thread_func=...) at util/thread.cpp:21
  #17 0x000055555569e05d in std::__invoke_impl<void, void (*)(std::basic_string_view<char>, std::function<void()>), char const*, CConnman::Start(CScheduler&, const Options&)::<lambda()> > (__f=<optimized out>) at /usr/include/c++/12/bits/invoke.h:61
  #18 std::__invoke<void (*)(std::basic_string_view<char>, std::function<void()>), char const*, CConnman::Start(CScheduler&, const Options&)::<lambda()> > (__fn=<optimized out>) at /usr/include/c++/12/bits/invoke.h:96
  #19 std:🧵:_Invoker<std::tuple<void (*)(std::basic_string_view<char, std::char_traits<char> >, std::function<void()>), char const*, CConnman::Start(CScheduler&, const Options&)::<lambda()> > >::_M_invoke<0, 1, 2> (this=<optimized out>) at /usr/include/c++/12/bits/std_thread.h:252
  #20 std:🧵:_Invoker<std::tuple<void (*)(std::basic_string_view<char, std::char_traits<char> >, std::function<void()>), char const*, CConnman::Start(CScheduler&, const Options&)::<lambda()> > >::operator() (this=<optimized out>) at /usr/include/c++/12/bits/std_thread.h:259
  #21 std:🧵:_State_impl<std:🧵:_Invoker<std::tuple<void (*)(std::basic_string_view<char, std::char_traits<char> >, std::function<void()>), char const*, CConnman::Start(CScheduler&, const Options&)::<lambda()> > > >::_M_run(void) (this=<optimized out>)
      at /usr/include/c++/12/bits/std_thread.h:210
  #22 0x00007ffff7ad43d3 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
  #23 0x00007ffff7687b27 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:435
  #24 0x00007ffff770a78c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  (gdb)
  ```

ACKs for top commit:
  MarcoFalke:
    review ACK e4be0e9b06 🏽

Tree-SHA512: d892d6264a284d952a68a8631a6301277373b8df939dafd9e2652f2f22ab60712cde63b90c27c67ea2d05f02443452e3e4e1b9f25479bfaca00d4c4de13b9fbd
2022-12-13 10:07:37 +00:00
josibake
bcb7123406
test: add add_wallet_options to TestShell
without this, testShell runs with -disablewallet
2022-12-12 17:58:15 +01:00
Sebastian Falbesoner
741908afc1 test: previous releases: add v24.0.1 2022-12-11 03:39:57 +01:00
fanquake
3b5fb6e77a
Merge bitcoin/bitcoin#26213: rpc: Strict type checking for RPC boolean parameters
fa0153e609 refactor: Replace isTrue with get_bool (MarcoFalke)
fa2cc5d1d6 bugfix: Strict type checking for RPC boolean parameters (MarcoFalke)

Pull request description:

ACKs for top commit:
  ryanofsky:
    Code review ACK fa0153e609
  furszy:
    Code ACK fa0153e6

Tree-SHA512: b221f823c69d90c94447fd491071ff3659cfd512872b495ebc3e711f50633351974102c9ef7e50fa4a393c4131d349adea8fd41cc9d66f1f31e1f5e7a5f78757
2022-12-10 09:58:33 +00:00
Andrew Chow
1647a11f39 tests: Reorder longer running tests in test_runner
The logest running tests should be at the front of the list in
test_runner.py. Since compiling with --enable-debug can have a
significant effect on test runtime, the order is based on the runtime
with that option configured.
2022-12-09 13:57:55 -05:00
Andrew Chow
ff6c9fe027 tests: Whitelist test p2p connection in rpc_packages
test_submit_child_with_parents creates a p2p connection which waits for
the node to announce transactions to it. By whitelisting this
connection, we can reduce the amount of time spent waiting for this
announcement which improves the test runtime and runtime variance.
2022-12-09 13:57:01 -05:00
Andrew Chow
8c20796aac tests: Use waitfornewblock for work queue test in interface_rpc
The work queue exceeded test in interface_rpc.py would repeatedly call
an RPC until the error was achieved. However hitting this error is
dependent on the processing speed of the computer and the optimization
level of the binary. Configurations that result in slower processing
would result in the RPC used being processed before the error could be
hit, resulting the test's runtime having a high variance.

Switching the RPC to waitfornewblock allows it to run in a much more
consistent time that is still fairly fast. waitfornewblock forces
the RPC server to allocate a thread and wait, occupying a spot in the
work queue. This is perfect for this test because the slower the RPC,
the more likely we will achieve the race condition necessary to pass the
test. Using a timeout of 500 ms appears to work reliably without causing
the test to take too long.
2022-12-09 13:57:01 -05:00
Andrew Chow
6c872d5e65 tests: Initialize sigops draining script with bytes in feature_taproot
The sigops draining script in feature_taproot's block_submit was
initialized with a list that would end up always being iterated by
CScript's constructor. Since this list is very large, a lot of time
would be wasted. By creating and passing a bytes object initialized from
that list, we can avoid this iteration and dramatically improve the
runtime of feature_taproot.
2022-12-09 13:57:01 -05:00
Andrew Chow
544cbf776c tests: Use batched RPC in feature_fee_estimation
feature_fee_estimation has a lot of loops that hit the RPC many times in
succession in order to setup scenarios. Using batched requests for these
can reduce the test's runtime without effecting the test's behavior.
2022-12-09 13:57:01 -05:00
Andrew Chow
4ad7272f8b tests: reduce number of generated blocks for wallet_import_rescan
Generating blocks is slow, especially when --enable-debug. There is no
need to generate a new block for each transaction, so avoid doing that
to improve this test's runtime.
2022-12-09 13:57:01 -05:00
MarcoFalke
fa7d71accc
test: Move rpc_fundrawtransaction.py to wallet_fundrawtransaction.py 2022-12-09 11:54:29 +01:00
MarcoFalke
fa933d6985
test: Move feature_backwards_compatibility.py to wallet_backwards_compatibility.py 2022-12-09 11:54:17 +01:00
MarcoFalke
16624e6ff3
Merge bitcoin/bitcoin#26660: test: Use last release in compatibility tests
fabb24cbef test: Use last release in compatibility tests (MarcoFalke)

Pull request description:

  In compatibility tests it makes sense to always use the last release without the new feature, as it is likely more in use than any even older previous release.

ACKs for top commit:
  Sjors:
    utACK fabb24c

Tree-SHA512: beb854f4d28ba313282e1e0303abb0e09377828b138bde5a3e209337210b6b4c24855ab90a68f8789387001e4ca33b15cc37dbc9b7809929f4e7d1b69833a527
2022-12-09 09:25:52 +01:00
MarcoFalke
fabb24cbef
test: Use last release in compatibility tests 2022-12-08 14:57:25 +01:00
MarcoFalke
fa34e5f3d3
test: Avoid intermittent timeout in feature_assumevalid.py 2022-12-08 14:24:46 +01:00
Aurèle Oulès
c29bff5b91
test: Fix backwards compatibility intermittent failure 2022-12-08 11:13:34 +01:00
Andrew Chow
a653f4bb1f
Merge bitcoin/bitcoin#25934: wallet, rpc: add label to listsinceblock
4e362c2b72 doc: add release note for 25934 (brunoerg)
fe488b4c4b test: add coverage for `label` in `listsinceblock` (brunoerg)
722e9a418d wallet, rpc: add `label` to `listsinceblock` (brunoerg)
852891ff98 refactor, wallet: use optional for `label` in `ListTransactions` (brunoerg)

Pull request description:

  This PR adds `label` parameter to `listsinceblock` to be able to fetch all incoming transactions having the specified label since a specific block.

  It's possible to use it in `listtransactions`, however, it's only possible to set the number of transactions to return, not a specific block to fetch from. `getreceivedbylabel` only returns the total amount received, not the txs info. `listreceivedbylabel` doesn't list all the informations about the transactions and it's not possible to fetch since a block.

ACKs for top commit:
  achow101:
    ACK 4e362c2b72
  w0xlt:
    ACK 4e362c2b72
  aureleoules:
    ACK 4e362c2b72

Tree-SHA512: fbde5db8cebf7a27804154fa61997b5155ad512e978cebb78c17acab9efcb624ea5f39d649899d12e5e675f80d4d0064cae8132b864de0d93a8d1e6fbcb9a737
2022-12-07 18:42:41 -05:00
brunoerg
c371cae07a test, init: perturb file to ensure failure instead of only deleting them 2022-12-07 15:01:31 -03:00
MarcoFalke
fa2cc5d1d6
bugfix: Strict type checking for RPC boolean parameters 2022-12-07 17:55:58 +01:00
MarcoFalke
9052d869c9
Merge bitcoin/bitcoin#26517: test: Changed small_txpuzzle_randfee to return the virtual size instead of the transaction hex for feerate calculation.
6fb102c9f3 test: Changed small_txpuzzle_randfee to return the virtual size instead of the transaction hex for feerate calculation. (Randall Naar)

Pull request description:

  The fee rates used in feature_fee_estimation.py are calculated using the raw transaction size instead of the virtual transaction size (which is used in 'CBlockPolicyEstimator::processBlockTx' and 'CBlockPolicyEstimator::processBlock'). This leads to inconsistencies as the fee rates used in check_raw_estimates are incorrect and can cause assertions to fail.

  refs #25179

ACKs for top commit:
  MarcoFalke:
    ACK 6fb102c9f3

Tree-SHA512: b2bca85fffa605aeb17574f050736d4556506d782dd7fd969e165e48e108fd95ef4c4e2abbae83cce05ca777a00f4459cabfa0932694fa8bb93ddfba09d84357
2022-12-07 17:33:37 +01:00
brunoerg
fe488b4c4b test: add coverage for label in listsinceblock 2022-12-06 15:27:50 -03:00
Andrew Chow
ef744c03e5
Merge bitcoin/bitcoin#25729: wallet: Check max transaction weight in CoinSelection
c7c7ee9d0b test: Check max transaction weight in CoinSelection (Aurèle Oulès)
6b563cae92 wallet: Check max tx weight in coin selector (Aurèle Oulès)

Pull request description:

  This PR is an attempt to fix #5782.

  I have added 4 test scenarios, 3 of them provided here https://github.com/bitcoin/bitcoin/issues/5782#issuecomment-73819058 (slightly modified to use a segwit wallet).

  Here are my benchmarks :
  ## PR
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |        1,466,341.00 |              681.97 |    0.6% |   11,176,762.00 |    3,358,752.00 |  3.328 |   1,897,839.00 |    0.3% |      0.02 | `CoinSelection`

  ## Master

  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |        1,526,029.00 |              655.30 |    0.5% |   11,142,188.00 |    3,499,200.00 |  3.184 |   1,994,156.00 |    0.2% |      0.02 | `CoinSelection`

ACKs for top commit:
  achow101:
    reACK c7c7ee9d0b
  w0xlt:
    ACK c7c7ee9d0b
  furszy:
    diff ACK c7c7ee9d

Tree-SHA512: ef0b28576ff845174651ba494aa9adee234c96e6f886d0e032eceb7050296e45b099dda0039d1dfb9944469f067627b2101f3ff855c70353cf39d1fc7ee81828
2022-12-06 12:08:58 -05:00
w0xlt
b082f28101 rpc, wallet: use the same next_index in listdescriptors and importdescriptors 2022-12-06 11:38:07 -03:00
S3RK
17554efb60 test: prefer sqlite for wallet tests 2022-12-06 09:17:25 +01:00
S3RK
8e0fabaabf test: make wallet_migration.py pass with both wallet flags 2022-12-06 09:17:24 +01:00
Andrew Chow
5d9b5305af
Merge bitcoin/bitcoin#19888: rpc, test: Improve getblockstats for unspendables
d885bb2f6e test: Test exclusion of OP_RETURN from getblockstats (Fabian Jahr)
ba9d288b24 test: Fix getblockstats test data generator (Fabian Jahr)
2ca5a496c2 rpc: Improve getblockstats (Fabian Jahr)
cb94db119f validation, index: Add unspendable coinbase helper functions (Fabian Jahr)

Pull request description:

  Fixes #19885

  The genesis block does not have undo data saved to disk so the RPC errored because of that.

ACKs for top commit:
  achow101:
    ACK d885bb2f6e
  aureleoules:
    ACK d885bb2f6e
  stickies-v:
    ACK d885bb2f6

Tree-SHA512: f37bda736ed605b7a41a81eeb4bfbb5d2b8518f847819e5d6a090548a61caf1455623e15165d72589ab3f4478252b00e7b624f9313ad6708cac06dd5edb62e9a
2022-12-05 17:46:54 -05:00
Andrew Chow
2ce3d26757
Merge bitcoin/bitcoin#26462: wallet: fix crash on loading descriptor wallet containing legacy key type entries
3198e4239e test: check that loading descriptor wallet with legacy entries throws error (Sebastian Falbesoner)
349ed2a0ee wallet: throw error if legacy entries are present on loading descriptor wallets (Sebastian Falbesoner)

Pull request description:

  Loading a descriptor wallet currently leads to a segfault if a legacy key type entry is present that can be deserialized successfully and needs SPKman-interaction. To reproduce with a "cscript" entry (see second commit for details):

  ```
  $ ./src/bitcoin-cli createwallet crashme
  $ ./src/bitcoin-cli unloadwallet crashme
  $ sqlite3 ~/.bitcoin/wallets/crashme/wallet.dat
  SQLite version 3.38.2 2022-03-26 13:51:10
  Enter ".help" for usage hints.
  sqlite> INSERT INTO main VALUES(x'07637363726970740000000000000000000000000000000000000000', x'00');
  $ ./src/bitcoin-cli loadwallet crashme

  --- bitcoind output: ---
  2022-11-06T13:51:01Z Using SQLite Version 3.38.2
  2022-11-06T13:51:01Z Using wallet /home/honey/.bitcoin/wallets/crashme
  2022-11-06T13:51:01Z init message: Loading wallet…
  2022-11-06T13:51:01Z [crashme] Wallet file version = 10500, last client version = 249900

  Segmentation fault (core dumped)
  ```

  Background: In the wallet key-value-loading routine, most legacy type entries require a `LegacyScriptPubKeyMan` instance after successful deserialization. On a descriptor wallet, creating that (via method `GetOrCreateLegacyScriptPubKeyMan`) fails and then leads to a null-pointer dereference crash. E.g. for CSCRIPT: 50422b770a/src/wallet/walletdb.cpp (L589-L594)

  ~~This PR fixes this by simply ignoring legacy entries if the wallet flags indicate that we have a descriptor wallet. The second commits adds a regression test to the descriptor wallet's functional test (fortunately Python includes sqlite3 support in the standard library).~~

  ~~Probably it would be even better to throw a warning to the user if unexpected legacy entries are found in descriptor wallets, but I think as a first mitigation everything is obvisouly better than crashing. As far as I'm aware, descriptor wallets created/migrated by Bitcoin Core should never end up in a state containing legacy type entries though.~~

  This PR fixes this by throwing an error if legacy entries are found in descriptor wallets on loading.

ACKs for top commit:
  achow101:
    ACK 3198e4239e
  aureleoules:
    ACK 3198e4239e

Tree-SHA512: ee43da3f61248e0fde55d9a705869202cb83df678ebf4816f0e77263f0beac0d7bae9490465d1753159efb093ee37182931d76b2e2b6e8c6f8761285700ace1c
2022-12-05 17:37:48 -05:00
Aurèle Oulès
6b563cae92
wallet: Check max tx weight in coin selector
Co-authored-by: Andrew Chow <github@achow101.com>
2022-12-05 19:32:11 +01:00
Andrew Chow
7734a0160d
Merge bitcoin/bitcoin#26640: test: Run mempool_compatibility.py with MiniWallet
fa43f60a0c test: Run mempool_compatibility.py with MiniWallet (MarcoFalke)

Pull request description:

  By using the already existing miniwallet, the test can be run even when no wallet is compiled.

ACKs for top commit:
  glozow:
    ACK fa43f60a0c
  achow101:
    ACK fa43f60a0c

Tree-SHA512: 6877b3f2f364663f04c28ab9f3d69780de6d1b77cc862379bba8c8242bbcfb0d26eb84c56cf721141407c393f1f3b49f667ae4fb32b3566108d71250e8b5d7bc
2022-12-05 12:39:15 -05:00
Andrew Chow
f0c4807a6a
Merge bitcoin/bitcoin#26560: wallet: bugfix, invalid CoinsResult cached total amount
7362f8e5e2 refactor: make CoinsResult total amounts members private (furszy)
3282fad599 wallet: add assert to SelectionResult::Merge for safety (S3RK)
c4e3b7d6a1 wallet: SelectCoins, return early if wallet's UTXOs cannot cover the target (furszy)
cac2725fd0 test: bugfix, coinselector_test, use 'CoinsResult::Erase/Add' instead of direct member access (furszy)
cf79384697 test: Coin Selection, duplicated preset inputs selection (furszy)
341ba7ffd8 test: wallet, coverage for CoinsResult::Erase function (furszy)
f930aefff9 wallet: bugfix, 'CoinsResult::Erase' is erasing only one output of the set (furszy)

Pull request description:

  This comes with #26559.

  Solving few bugs inside the wallet's transaction creation
  process and adding test coverage for them.
  Plus, making use of the `CoinsResult::total_amount` cached value
  inside the Coin Selection process to return early if we don't have
  enough funds to cover the target amount.

  ### Bugs

  1) The `CoinsResult::Erase` method removes only one
  output from the available coins vector (there is a [loop break](c1061be14a/src/wallet/spend.cpp (L112))
  that should have never been there) and not all the preset inputs.

     Which on master is not a problem, because since [#25685](https://github.com/bitcoin/bitcoin/pull/25685)
     we are no longer using the method. But, it's a bug on v24
     (check [#26559](https://github.com/bitcoin/bitcoin/pull/26559)).

     This method it's being fixed and not removed because I'm later using it to solve
     another bug inside this PR.

  2) As we update the total cached amount of the `CoinsResult` object inside
     `AvailableCoins` and we don't use such function inside the coin selection
     tests (we manually load up the `CoinsResult` object), there is a discrepancy
     between the outputs that we add/erase and the total amount cached value.

  ### Improvements

  * This makes use of the `CoinsResult` total amount field to early return
    with an "Insufficient funds" error inside Coin Selection if the tx target
    amount is greater than the sum of all the wallet available coins plus the
    preset inputs amounts (we don't need to perform the entire coin selection
    process if we already know that there aren't enough funds inside our wallet).

  ### Test Coverage

  1) Adds test coverage for the duplicated preset input selection bug that we have in v24.
    Where the wallet invalidly selects the preset inputs twice during the Coin Selection
    process. Which ends up with a "good" Coin Selection result that does not cover the
    total tx target amount. Which, alone, crashes the wallet due an insane fee.
    But.. to make it worst, adding the subtract fee from output functionality
    to this mix ends up with the wallet by-passing the "insane" fee assertion,
    decreasing the output amount to fulfill the insane fee, and.. sadly,
    broadcasting the tx to the network.

  2) Adds test coverage for the `CoinsResult::Erase` method.

  ------------------------------------

  TO DO:
  * [ ] Update [#26559 ](https://github.com/bitcoin/bitcoin/pull/26559) description.

ACKs for top commit:
  achow101:
    ACK 7362f8e5e2
  glozow:
    ACK 7362f8e5e2, I assume there will be a followup PR to add coin selection sanity checks and we can discuss the best way to do that there.
  josibake:
    ACK [7362f8e](7362f8e5e2)

Tree-SHA512: 37a6828ea10d8d36c8d5873ceede7c8bef72ae4c34bef21721fa9dad83ad6dba93711c3170a26ab6e05bdbc267bb17433da08ccb83b82956d05fb16090328cba
2022-12-05 12:00:45 -05:00
MarcoFalke
38cbf43dee
Merge bitcoin/bitcoin#26414: test: Move tx creation to create_self_transfer_multi
0b78110f73 test: Move tx creation to create_self_transfer_multi (kouloumos)

Pull request description:

  Two birds with one stone: replacement of https://github.com/bitcoin/bitcoin/pull/26278 with simplification of the MiniWallet's transaction creation logic.

  Currently the MiniWallet creates simple txns (1 input, 1 output) with `create_self_transfer`.  https://github.com/bitcoin/bitcoin/pull/24637 introduced `create_self_transfer_multi` **which uses** `create_self_transfer` to create a "transaction template" which then adjusts (copy and mutate inputs and outputs) in order to create more complex multi-input multi-output transactions.
  This can more easily lead to issues such as https://github.com/bitcoin/bitcoin/pull/26278 and is more of a maintenance burden.

  This PR simplifies the logic by going the other way around. Now `create_self_transfer` **uses** `create_self_transfer_multi`.
  The transaction creation logic has been moved to `create_self_transfer_multi` which is being called by `create_self_transfer` to construct the simple case of 1 input 1 output transaction.

ACKs for top commit:
  MarcoFalke:
    ACK 0b78110f73 👒

Tree-SHA512: 147e577ed5444bee57865bd375b37c9b49d6539e9875c30c2667e70fcba27fe80bcb4552a4e6efb42760d34b40d5dad826883b778eaeefe29425ec081787b4bd
2022-12-05 16:22:42 +01:00
MarcoFalke
fa43f60a0c
test: Run mempool_compatibility.py with MiniWallet 2022-12-05 13:13:00 +01:00
Sebastian Falbesoner
8a5dbe2879 test: add CScript method for checking for witness program
This is needed in the next commit to calculate the dust threshold
for a given output script and min feerate for defining dust.
2022-12-04 03:07:42 +01:00
MarcoFalke
fadf7b8fef
test: Fix intermittent issue in rpc_net.py 2022-12-03 17:42:05 +01:00
MarcoFalke
cac29f5cd6
Merge bitcoin/bitcoin#26622: test: Add test for sendall min-fee setting
cb44c5923a test: Add sendall test for min-fee setting (Aurèle Oulès)

Pull request description:

  While experimenting with mutation testing it appeared that the minimum fee-rate check was not tested for the `sendall` RPC.

  https://bcm-ui.aureleoules.com/mutations/3581479318544ea6b97f788cec6e6ef1

ACKs for top commit:
  0xB10C:
    ACK cb44c5923a
  ishaanam:
    ACK cb44c5923a
  stickies-v:
    re-ACK [cb44c59](cb44c5923a)

Tree-SHA512: 31978436e1f01cc6abf44addc62b6887e65611e9a7ae7dc72e6a73cdfdb3a6a4f0a6c53043b47ecd1b10fc902385a172921e68818a7f5061c96e5e1ef5280b48
2022-12-03 12:28:13 +01:00
Ryan Ofsky
d1ca563825 bitcoin-cli: Make it an error to specify the "args" parameter two different ways
MarcoFalke reported the case of positional arguments silently overwriting the
named "args" parameter in bitcoin-cli
https://github.com/bitcoin/bitcoin/pull/19762#discussion_r1035761471 and this
behavior is confusing and was not intended when support for "args" parameters
was added to bitcoin-cli in #19762.

Instead of letting one "args" value overwrite the other in the client, just
pass the values to the server verbatim, and let the error be handled server
side.
2022-12-02 17:53:58 -05:00
Ryan Ofsky
e2c3b18e67 test: Add RPC tests for same named parameter specified more than once
Current behavior isn't ideal and will be changed in upcoming commits, but it's
useful to have test coverage regardless.

MarcoFalke reported the case of bitcoin-cli positional arguments overwriting
the named "args" parameter in
https://github.com/bitcoin/bitcoin/pull/19762#discussion_r1035761471
2022-12-02 17:37:08 -05:00
furszy
cf79384697
test: Coin Selection, duplicated preset inputs selection
This exercises the bug inside CoinsResult::Erase that
ends up on (1) a wallet crash or (2) a created and
broadcasted tx that contains a reduced recipient's amount.

This is covered by making the wallet selects the preset
inputs twice during the coin selection process.

Making the wallet think that the selection process result covers
the entire tx target when it does not. It's actually creating
a tx that sends more coins than what inputs are covering for.

Which, combined with the SFFO option, makes the wallet
incorrectly reduce the recipient's amount by the difference
between the original target and the wrongly counted inputs.
Which means, a created and relayed tx sending less coins to
the destination than what the user inputted.
2022-12-02 12:39:15 -03:00
fanquake
78aee0fe2c
Merge bitcoin/bitcoin#26569: p2p: Ensure transaction announcements are only queued for fully connected peers
8f2dac5409 [test] Add p2p_tx_privacy.py (dergoegge)
ce63fca13e [net processing] Assume that TxRelay::m_tx_inventory_to_send is empty pre-verack (dergoegge)
845e3a34c4 [net processing] Ensure transaction announcements are only queued for fully connected peers (dergoegge)

Pull request description:

  `TxRelay::m_next_inv_send_time` is initialized to 0, which means that any txids in `TxRelay::m_tx_inventory_to_send` will be announced on the first call to `PeerManagerImpl::SendMessages` for a fully connected peer (i.e. it completed the version handshake).

  Prior to #21160, `TxRelay::m_tx_inventory_to_send` was guaranteed to be empty on the first `SendMessages` call, as transaction announcements were only queued for fully connected peers. #21160 replaced a `CConnman::ForEachNode` call with a loop over `PeerManagerImpl::m_peer_map`, in which the txid for a transaction to be relayed is added to `TxRelay::m_tx_inventory_to_send` for all peers. Even for those peers that have not completed the version handshake. Prior to the PR this was not the case as `ForEachNode` has a "fully connected check" before calling a function for each node.

ACKs for top commit:
  MarcoFalke:
    ACK 8f2dac5409 🔝
  jnewbery:
    utACK 8f2dac5409

Tree-SHA512: e9eaccf7e00633ee0806fff1068b0e413a69a5e389d96c9659f68079915a6381ad5040c61f716cfcde77931d1b563b1049da97a232a95c6cd8355bd3d13404b9
2022-12-02 15:13:31 +00:00
Aurèle Oulès
cb44c5923a
test: Add sendall test for min-fee setting 2022-12-02 13:30:40 +01:00
MarcoFalke
4037478114
Merge bitcoin/bitcoin#26610: test: Remove unused blocktools imports from wallet_bumpfee
fa15c671f7 test: Remove unused blocktools imports from wallet_bumpfee (MarcoFalke)

Pull request description:

  Seems bloaty and confusing to use "tools" when a single RPC can already achieve the same.

ACKs for top commit:
  theStack:
    ACK fa15c671f7

Tree-SHA512: 87f9c31bbb286fee5e479ae54a1f9131f4d4294d665a985df8b14a0cc837a2a2e145ccd3660612768d88cfa0827a3eef392f85519b6cb7df365ba9fadafb0a41
2022-12-02 09:43:26 +01:00
MarcoFalke
02515117dc
Merge bitcoin/bitcoin#26620: test: refactor: eliminate genesis block timestamp magic numbers
dbed28968a test: refactor: eliminate genesis block timestamp magic numbers (Sebastian Falbesoner)

Pull request description:

  This tiny PR replaces all occurences of the regtest/testnet genesis block timestamp (found via `git grep 1296688602`) with the constant `TIME_GENESIS_BLOCK` to increase the readability.

ACKs for top commit:
  aureleoules:
    ACK dbed28968a

Tree-SHA512: be39d5c2631ad20eb775c2a077b1b1f056a1a4930aa44e6fdec73b974fd4bdf8da0103a3a38e3514b68fcf6a6316e007a371c523da5076a315545c9bf3091aee
2022-12-01 18:37:59 +01:00
MarcoFalke
a04121bdf9
Merge bitcoin/bitcoin#26617: test: add extra_args to BitcoinTestFramework class
150340aeac test: remove unneeded extra_args code (josibake)
989a52e0a5 test: add extra_args to BTF class (josibake)

Pull request description:

  ## problem
  If you try to add `extra_args` when using `TestShell`, you will get the following error:

  ```python
  >>> import sys
  >>>
  >>> sys.path.insert(0, "/home/josibake/bitcoin/test/functional")
  >>>
  >>> from test_framework.test_shell import TestShell
  >>> test = TestShell().setup(num_nodes=2, extra_args=[[],['-fallbackfee=0.0002']])
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/josibake/bitcoin/test/functional/test_framework/test_shell.py", line 41, in setup
      raise KeyError(key + " not a valid parameter key!")
  KeyError: 'extra_args not a valid parameter key!'
  >>>
  ```

  ## solution

  add `self.extra_args = None` so that `extra_args` is recognized as a valid parameter to be passed to `BitcoinTestFramework`

  ```python
  >>> import sys
  >>>
  >>> sys.path.insert(0, "/home/josibake/bitcoin/test/functional")
  >>>
  >>> from test_framework.test_shell import TestShell
  >>> test = TestShell().setup(num_nodes=2, extra_args=[[],['-fallbackfee=0.0002']])
  2022-12-01T11:23:23.765000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_sbwthbb_
  ```

ACKs for top commit:
  willcl-ark:
    re-ACK 150340aeac

Tree-SHA512: e6fa2a780a8f2d3472c322e8cdb00ec35cb220c3b4d6ca02291eb8b41c0d8676a635fbc79c6be80e3bb71d700a2501a4b73f762478f533ae453d492d449307bb
2022-12-01 17:50:46 +01:00
josibake
150340aeac
test: remove unneeded extra_args code 2022-12-01 16:55:43 +01:00
Sebastian Falbesoner
dbed28968a test: refactor: eliminate genesis block timestamp magic numbers 2022-12-01 12:59:59 +01:00
josibake
989a52e0a5
test: add extra_args to BTF class
this allows us to pass extra_args when using TestShell
2022-12-01 12:14:10 +01:00
fanquake
e334f7a545
Merge bitcoin/bitcoin#26594: wallet: Avoid a segfault in migratewallet failure cleanup
5e65a216d1 wallet: Explicitly say migratewallet on encrypted wallets is unsupported (Andrew Chow)
88afc73ae0 tests: Test for migrating encrypted wallets (Andrew Chow)
86ef7b3c7b wallet: Avoid null pointer deref when cleaning up migratewallet (Andrew Chow)

Pull request description:

  When `migratewallet` fails, we do an automatic cleanup in order to reset everything so that the user does not experience any interruptions. However, this apparently has a segfault in it, caused by the the pointers to the watchonly and solvables wallets being nullptr. If those wallets are not created (either not needed, or failed early on), we will accidentally attempt to dereference these nullptrs, which causes a segfault.

  This failure can be easily reached by trying to migrate an encrypted wallet. Currently, we can't migrate encrypted wallets because of how we unload wallets before migrating, and therefore forget the encryption key if the wallet was unlocked. So any encrypted wallets will fail, entering the cleanup, and because watchonly and solvables wallets don't exist yet, the segfault is reached.

  This PR fixes this by not putting those nullptrs in a place that we will end up dereferencing them later. It also adds a test that uses the encrypted wallet issue.

ACKs for top commit:
  S3RK:
    reACK 5e65a216d1
  stickies-v:
    ACK [5e65a21](5e65a216d1)
  furszy:
    diff ACK 5e65a21

Tree-SHA512: f75643797220d4232ad3ab8cb4b46d0f3667f00486e910ca748c9b6d174d446968f1ec4dd7f907da1be9566088849da7edcd8cd8f12de671c3241b513deb8e80
2022-12-01 10:17:09 +00:00
dergoegge
8f2dac5409 [test] Add p2p_tx_privacy.py 2022-11-30 16:36:16 +00:00
MarcoFalke
fa15c671f7
test: Remove unused blocktools imports from wallet_bumpfee 2022-11-30 16:59:21 +01:00
Andrew Chow
5e65a216d1 wallet: Explicitly say migratewallet on encrypted wallets is unsupported 2022-11-30 10:30:57 -05:00
fanquake
bcee94d107
Merge bitcoin/bitcoin#26359: p2p: Erlay support signaling follow-ups
46339d29b1 test, refactor: Reorder sendtxrcncl tests for better readability (Gleb Naumenko)
14263c13f1 p2p, refactor: Extend logs for unexpected sendtxrcncl (Gleb Naumenko)
87493e112e p2p, test, refactor: Minor code improvements (Gleb Naumenko)
00c5dec818 p2p: Clarify sendtxrcncl policies (Gleb Naumenko)
ac6ee5ba21 test: Expand unit and functional tests for txreconciliation (Gleb Naumenko)
bc84e24a4f p2p, refactor: Switch to enum class for ReconciliationRegisterResult (Gleb Naumenko)
a60f729e29 p2p: Drop roles from sendtxrcncl (Gleb Naumenko)
6772cbf69c tests: stabilize sendtxrcncl test (Gleb Naumenko)

Pull request description:

  Non-trivial changes include:
  - Getting rid of roles in `sendtxrcncl` message (summarized in the [BIP PR](https://github.com/bitcoin/bips/pull/1376));
  - Disconnect the peer if it send `sendtxrcncl` although we are in `blocksonly` and notified the peer with `fRelay=0`;
  - Don't send `sendtxrcncl` to feeler connections.

ACKs for top commit:
  vasild:
    ACK 46339d29b1
  ariard:
    ACK 46339d2
  mzumsande:
    Code Review ACK 46339d29b1

Tree-SHA512: b5cc6934b4670c12b7dbb3189e739ef747ee542ec56678bf4e4355bfb481b746d32363c173635685b71969b3fe4bd52b1c8ebd3ea3b35c82044bba69220f6417
2022-11-30 10:52:44 +00:00
MarcoFalke
3be21060d6
Merge bitcoin/bitcoin#26600: test: Set wallet type in test_runner when only one type is allowed
fadb8696dd test: Set wallet type in test_runner when only one type is allowed (MarcoFalke)

Pull request description:

  Currently devs are free to set or not set the wallet type in the test_runner when only one type is allowed to be set.

  This is inconsistent and causes review comments such as:

  * https://github.com/bitcoin/bitcoin/pull/24865#discussion_r1009752111

ACKs for top commit:
  achow101:
    ACK fadb8696dd

Tree-SHA512: 1ca0946df07b5bf6778fea957d74393757781c324d554fec2f7d03bf1915033e644d9a4c3d77e0b24090ab593d7ed3cb3c9169666bc39fff423706fceaa1af80
2022-11-30 10:23:05 +01:00
Andrew Chow
88afc73ae0 tests: Test for migrating encrypted wallets
Due to an oversight, we cannot currently migrate encrypted wallets,
regardless of whether they are unlocked. Migrating such wallets will
trigger an error, and result in the cleanup being run. This conveniently
allows us to check some parts of the cleanup code.
2022-11-29 19:31:27 -05:00
Andrew Chow
a63192afb8
Merge bitcoin/bitcoin#19762: rpc: Allow named and positional arguments to be used together
d8b12a75db rpc: Allow named and positional arguments to be used together (Ryan Ofsky)

Pull request description:

  It's nice to be able to use named options and positional arguments together.

  Most shell tools accept both, and python functions combine options and arguments allowing them to be passed with even more flexibility. This change adds support for python's approach so as a motivating example:

  ```sh
  bitcoin-cli -named createwallet wallet_name=mywallet load_on_startup=1
  ```

  Can be shortened to:

  ```sh
  bitcoin-cli -named createwallet mywallet load_on_startup=1
  ```

  JSON-RPC standard doesn't have a convention for passing named and positional parameters together, so this implementation makes one up and interprets any unused `"args"` named parameter as a positional parameter array.

  This change is backwards compatible. It doesn't change the interpretation of any previously valid calls, just treats some previously invalid calls as valid.

  Another use case even if you only occasionally use named arguments is that you can define an alias:

  ```
  alias bcli='bitcoin-cli -named'
  ```

  And now use both named named and unnamed arguments from the same alias without having to manually add `-named` option for named arguments or see annoying error "No '=' in named argument... this needs to be present for every argument (even if it is empty)`" for unnamed arguments

ACKs for top commit:
  achow101:
    ACK d8b12a75db
  stickies-v:
    re-ACK d8b12a75d
  aureleoules:
    re-ACK d8b12a75db

Tree-SHA512: 0cff8b50f584bcbbd376624adccf40536566ed8d1bcd6c88ad565dbc208f19d5e7a48c994efd6329d42b560149340d330397278f08a2912af5f3418d8c8837a9
2022-11-29 18:37:55 -05:00
MarcoFalke
fadb8696dd
test: Set wallet type in test_runner when only one type is allowed 2022-11-29 14:26:55 +01:00
MarcoFalke
d415b7261c
Merge bitcoin/bitcoin#26588: ci: Skip COMMIT_RANGE if no CIRRUS_PR
fad1c55301 lint: Skip COMMIT_RANGE if no CIRRUS_PR (MarcoFalke)

Pull request description:

  It doesn't make sense to run this for non-PRs, because:

  * There are known whitespace "violations" in previous commits, so the lint may fail
  * Once the changes are merged, it is too late to fix them up (force pushes are illegal)
  * It isn't possible to determine which commits to run on if there is no reference branch (target branch of the pull request)

  Moreover, the test fails on non-master:

  * https://github.com/bitcoin/bitcoin/runs/8664441400

  Fix all issues by skipping it.

ACKs for top commit:
  hebasto:
    ACK fad1c55301, also tested in my personal Cirrus account.

Tree-SHA512: be15f00e2b2a9069583833545883e0e5968a33d2455dad59e6fb47c1102b4dd16ef932e9ba945e29e9d941e6c17bd531a02c66b0491097801be6bda476875537
2022-11-28 17:18:29 +01:00
Andrew Chow
8597260872
Merge bitcoin/bitcoin#26480: test: Remove wallet option from non-wallet tests
fa10f193b5 test: Set default in add_wallet_options if only one type can be chosen (MacroFake)
555519d082 test: Remove wallet option from non-wallet tests (MacroFake)
fac8d59d31 test: Set -disablewallet when no wallet has been compiled (MacroFake)
fa68937b89 test: Make requires_wallet private (MacroFake)

Pull request description:

  The tests have several issues:

  * Some tests that are wallet-type specific offer the option to run the test with the incompatible type

  For example, `wallet_dump.py` offers `--descriptors` and on current master fails with `JSONRPCException: Invalid public key`. After the changes here, it fails with a clear error: `unrecognized arguments: --descriptors`.

  * Tests that don't use the wallet at all offer the option to run it with a wallet type. This is confusing and wastes developers time if they are "tricked" into running the test for both wallet types, even though no wallet code is executed at all.

  For example, `feature_addrman.py` will happily accept and run with `--descriptors` or `--legacy-wallet`. After the changes here, it no longer silently ignores the flag, but reports a clear error: `unrecognized arguments`.

ACKs for top commit:
  achow101:
    ACK fa10f193b5

Tree-SHA512: a5784da7305f4ec58c0013f433289000d94fc3d434b00fc329ffa37b812e2cd1da0071e34c3462bf79d904808564f2ae6d3d582f6b86b26215f9b07391b58460
2022-11-28 11:16:49 -05:00
MarcoFalke
5939794940
Merge bitcoin/bitcoin#26589: test: small fixups/improvements for get_previous_releases.py
9b5feb76bc script: small fixups/improvements for get_previous_releases.py (Sebastian Falbesoner)

Pull request description:

  This is a small follow-up to #25650 (commit 614d4682ba) with three fixes/improvements:

  - fix "Checksum did not match" detection, which was not adapted to the new `SHA256_SUMS` structure and hence never executed (the list of tarball names isn't directly in the dictionary's values anymore, but has to be extracted from the `'tarball'` field of each value)
  - make both help text and default tag download order deterministic by sorting default tags
  - `--tags` argument help text: add missing space between "for" and "backwards"

ACKs for top commit:
  Sjors:
    tACK 9b5feb76bc. Tested that if I change a checksum, or remove a release, it catches that.
  josibake:
    tested ACK 9b5feb76bc

Tree-SHA512: 791fa693477eebbda7fd41f3f5ec78fe7eab57df06979aa907ab258a6945534bdc3b931ddfce0fb440c9666b98c88ce5e1b6dc353ed39e129e87d3634855165c
2022-11-28 13:59:54 +01:00
glozow
00c323610a
Merge bitcoin/bitcoin#25986: test: refactor RPCPackagesTest to use MiniWallet
17cad44851 test: refactor `RPCPackagesTest` to use `MiniWallet` (w0xlt)

Pull request description:

  This PR refactors `RPCPackagesTest` to use `MiniWallet` and removes `create_child_with_parents`, `make_chain`, and `create_raw_chain` from `test_framework/wallet`, as requested in https://github.com/bitcoin/bitcoin/issues/25965.

  Close https://github.com/bitcoin/bitcoin/issues/25965.

ACKs for top commit:
  glozow:
    ACK 17cad44851
  pablomartin4btc:
    tested ACK 17cad44; went thru all changes and recommendations from @kouloumos & @glozow; also went up to #20833 to get a bit of background of the origin and purpose of these tests.
  kouloumos:
    ACK 17cad44851

Tree-SHA512: 9228c532afaecedd577019dbc56f8749046d66f904dd69eb23e7ca3d7806e2132d90af29be276c7635fefb37ef348ae781eb3b225cd6741b20300e6f381041c3
2022-11-28 11:54:52 +00:00
MarcoFalke
fad1c55301
lint: Skip COMMIT_RANGE if no CIRRUS_PR 2022-11-28 11:09:30 +01:00
Sebastian Falbesoner
9b5feb76bc script: small fixups/improvements for get_previous_releases.py
This is a small follow-up to #25650 (commit
614d4682ba) with three fixes/improvements:

- fix "Checksum did not match" detection, which was not adapted to the new
  SHA256_SUMS structure and hence never executed (the list of tarball
  names isn't directly in the dictionary's values anymore, but has to be
  extracted from the 'tarball' field of each value)
- make both help text and default tag download order deterministic by
  sorting default tags
- "--tags" argument help text: add missing space between "for" and
  "backwards"
2022-11-28 03:22:01 +01:00
fanquake
38d06e1561
Merge bitcoin/bitcoin#26383: test: Add feature_taproot case involving invalid internal pubkey
5d413c8e79 Add feature_taproot case involved invalid internal pubkey (Pieter Wuille)

Pull request description:

  Add a test case to feature_taproot which involves an output that is (incorrectly) constructed, using an invalid internal public key and valid script tree. It is designed to detect cases where the script path spending validation logic does not detect this case, and instead treats the internal public key as the point at infinity.

  Equivalent unit test case added in https://github.com/bitcoin-core/qa-assets/pull/98.

ACKs for top commit:
  instagibbs:
    ACK 5d413c8e79
  aureleoules:
    reACK 5d413c8e79

Tree-SHA512: dfa014e383cd2743f3c9a996e1f2a2fceb9e244edf4b05dc0c110c4ba32a87684482222907805a4ca998aebcb42a197bb3e7967bfb5f0554fe9f1e5aa5463603
2022-11-22 16:31:05 +00:00
fanquake
1ef498f75b
Merge bitcoin/bitcoin#26520: doc: test: update/fix TestShell example instructions
31d0067f8b doc: test: update/fix TestShell example instructions (Sebastian Falbesoner)

Pull request description:

  This PR tackles two issues in the TestShell documentation:
  - add missing instruction for creating a wallet prior to the `getnewaddress` call (needed as there is no default wallet created anymore since v0.21)
  - fix `generatetoaddress` call syntax (the scripted-diff in commit fa0b916971 only worked for tests using `BitcoinTestFramework`)

ACKs for top commit:
  fanquake:
    ACK 31d0067f8b - current instructions don't work. These do.

Tree-SHA512: d2b7808a06892ad16728cb2b6d4a72b255ad711d27fe98b1de562f80444e7bb25d73296abdde4308162fe3be702864e2f7b7dbbbb000fe54c709951c09e6c730
2022-11-22 10:53:04 +00:00
Martin Zumsande
0f6cd72237 test: Fix intermittent failure in rpc_net.py
The wait in disconnect_p2ps checked for subver, which
is unavailable for the peer that didn't send a version msg.
2022-11-21 18:10:25 -05:00
Pieter Wuille
5d413c8e79 Add feature_taproot case involved invalid internal pubkey 2022-11-21 14:00:43 -05:00
MacroFake
60a00889b0
Merge bitcoin/bitcoin#26545: test: Remove unused sanitizer suppressions
fadb714039 test: Remove unused sanitizer suppressions (MacroFake)

Pull request description:

ACKs for top commit:
  fanquake:
    ACK fadb714039
  hebasto:
    ACK fadb714039

Tree-SHA512: 28d4d2eacdbad567434f0f792dbcaa424344dbd13e8686c72f1cbf8a79343b6ee9661246b13ab3f295757269861405315f42180ef49b69411d0b45f9b7796dd7
2022-11-21 17:27:34 +01:00
Sebastian Falbesoner
40bdc8a6e4 test: remove unused class NodePongAdd1
This class was introduced in commit
fa3365430c ("net: Use mockable time for
ping/pong, add tests"), but actually never used.
2022-11-21 13:03:35 +01:00
MacroFake
fadb714039
test: Remove unused sanitizer suppressions 2022-11-21 12:13:42 +01:00
MacroFake
df2f16666c
Merge bitcoin/bitcoin#26508: RPC/Blockchain: Minor improvements for scanblocks & scantxoutset docs/errors
f9869843a6 RPC/blockchain: scan{blocks,txoutset>: Further doc improvements (Luke Dashjr)
54b45e155e RPC/Blockchain: Clarify invalid-action error in scanblocks & scantxoutset (Luke Dashjr)

Pull request description:

  * Clarify invalid-action error in scanblocks & scantxoutset
  * Mention action=='start' only returns after scan completes (already in scantxoutset)
  * Document `relevant_blocks`

ACKs for top commit:
  kristapsk:
    utACK f9869843a6
  aureleoules:
    ACK f9869843a6
  MarnixCroes:
    ACK f9869843a6

Tree-SHA512: a37c9cc8a9a2f59376e8d8ed7dbf5e140eb3fefb4b7c19a23fc8190f3aef060bda1f0d5d06dc81cd7dca9e871d65f6c8094bab6e8d42e0bcef0fc7ffd2342d09
2022-11-21 11:32:36 +01:00
glozow
d0b1f613c2
Merge bitcoin/bitcoin#17786: refactor: Nuke policy/fees->mempool circular dependencies
c8dc0e3eaa refactor: Inline `CTxMemPoolEntry` class's functions (Hennadii Stepanov)
75bbe594e5 refactor: Move `CTxMemPoolEntry` class to its own module (Hennadii Stepanov)

Pull request description:

  This PR:
  - gets rid of the `policy/fees` -> `txmempool` -> `policy/fees` circular dependency
  - is an alternative to #13949, which nukes only one circular dependency

ACKs for top commit:
  ryanofsky:
    Code review ACK c8dc0e3eaa. Just include and whitespace changes since last review, and there's a moveonly commit now so it's very easy to review
  theStack:
    Code-review ACK c8dc0e3eaa
  glozow:
    utACK c8dc0e3eaa, agree these changes are an improvement.

Tree-SHA512: 36ece824e6ed3ab1a1e198b30a906c8ac12de24545f840eb046958a17315ac9260c7de26e11e2fbab7208adc3d74918db7a7e389444130f8810548ca2e81af41
2022-11-18 17:04:49 -08:00
Andrew Chow
aeb395dcdb
Merge bitcoin/bitcoin#25315: Add warning on first startup if free disk space is less than necessary
6630a1e844 Add warning on first startup if free disk space is less than necessary (Ben Woosley)

Pull request description:

  This reworks/revives https://github.com/bitcoin/bitcoin/pull/15848 to add a check for low disk space on first startup and issue a warning if disk space is below the expected space required to accommodate the blocks.

  This PR was fashioned by a team of developers at the [bitcoin++](https://www.btcplusplus.dev/) conference workshop: "[Let's contribute to Bitcoin Core](https://sched.co/12P6Z)"

  Fixes #15813

ACKs for top commit:
  achow101:
    ACK 6630a1e844
  willcl-ark:
    tACK 6630a1e844 rebased on master. Warning shows on first start but not on restart after some blocks have been downloaded.
  aureleoules:
    ACK 6630a1e844
  pablomartin4btc:
    re-ACK 6630a1e844
  hernanmarino:
    ReACK 6630a1e844

Tree-SHA512: 0f18acabdf2b514e96e2eea8f304960b952226b83dc91334cf7d1f6355ea2f257aaec0ee38d43ac36435385ecd918333d20657c35a8a7407e7cf2680ccb643bb
2022-11-18 11:33:10 -05:00