Commit Graph

48934 Commits

Author SHA1 Message Date
Ryan Ofsky
ce2044a91d Merge bitcoin/bitcoin#33362: Run feature_bind_port_(discover|externalip).py in CI
75cf9708a0 ci: add one more routable address to the VMs (docker containers) (Vasil Dimov)
1b93983bf5 test: make feature_bind_port_(discover|externalip).py auto-detect the skip condition (Vasil Dimov)

Pull request description:

  `feature_bind_port_discover.py` and `feature_bind_port_externalip.py` require a routable address on the machine to run. Since that was not predictably available on CI, those tests required a manual setting up of IP addresses (e.g. using `ifconfig`) and then running the tests with a command line option telling them that the addresses are set up. The tests were not run in CI and [got rot](https://github.com/bitcoin/bitcoin/issues/31293#issuecomment-2497792487).

  Change that to auto-detect, from the tests, whether the needed IP addresses are present and if yes, run the test, otherwise skip it. Also change the CI to configure the needed addresses when running the functional tests. This way the tests will be run regularly on CI.

  Fixes: https://github.com/bitcoin/bitcoin/issues/31336

ACKs for top commit:
  willcl-ark:
    ACK 75cf9708a0
  frankomosh:
    Tested ACK 75cf9708a0. Built from source.
  ryanofsky:
    Code review ACK 75cf9708a0. Tested locally with and without the special addresses, and the detection seems to work well.

Tree-SHA512: 252911a37a06764f644a1a83c808f5255ac3bc74919426afa5d082c59e1ea924196354735f229d381cb5aff2340e001c2240bbadc8b5f27e5321fb4cfaef0fdb
2026-05-19 13:34:59 -04:00
merge-script
2284288e9a Merge bitcoin/bitcoin#35279: psbt, test: remove address type restrictions in test
81348576cc psbt, test: remove address type restrictions in test (rkrux)

Pull request description:

  Because the corresponding Taproot fields were added in PSBT in #22558,
  so these restrictions are no longer necessary.

ACKs for top commit:
  kevkevinpal:
    ACK [8134857](81348576cc)
  polespinasa:
    lgtm ACK 81348576cc
  furszy:
    utACK 81348576cc

Tree-SHA512: 5621509e103674ee5f39454871ca5acb2bf4c16b85dbbdc38abac22fbaea44cafe4bbd91dc3a5c6435b3859a4dc58f12bf7aeec2952c9f80fbbdad2adb52847c
2026-05-19 16:09:44 +01:00
merge-script
278b9e39df Merge bitcoin/bitcoin#34934: fuzz: exercise ForNode/ForEachNode callbacks in connman fuzz harness
371eac8069 fuzz: exercise ForNode/ForEachNode callbacks in connman fuzz harness (frankomosh)

Pull request description:

  Track inserted node IDs and sometimes reuse them in `ForNode()` so the successful lookup path is exercised more reliably. Replace no-op callbacks with lightweight CNode accessor calls to make `ForEachNode()` and `ForNode()` cover previously unreached callback code paths.

  This addresses feedback from https://github.com/bitcoin/bitcoin/pull/34830#issuecomment-4074732710  where it was noted that the callbacks had "neither the return type checked nor its side-effect”.

  Coverage reports from the connman fuzz corpus, before and after the change:

  - [Before](https://frankomosh.github.io/fuzz-coverage/connman-callback-coverage/before/index.html)
  - [After](https://frankomosh.github.io/fuzz-coverage/connman-callback-coverage/after/index.html)

  `diff cov_show_before.txt cov_show_after.txt` filtered to `ForNode`/`ForEachNode`/`IsFullOutboundConn`/`ConnectionTypeAsString`:

  **`IsFullOutboundConn` — `net.h:786-788`**
  ```diff
  -  786|      0|    bool IsFullOutboundConn() const {
  -  787|      0|        return m_conn_type == ConnectionType::OUTBOUND_FULL_RELAY;
  -  788|      0|    }
  +  786|  1.13M|    bool IsFullOutboundConn() const {
  +  787|  1.13M|        return m_conn_type == ConnectionType::OUTBOUND_FULL_RELAY;
  +  788|  1.13M|    }
  ```

  **`ConnectionTypeAsString` — `net.h:967`**
  ```diff
  -  967|      0|    std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
  +  967|  1.11M|    std::string ConnectionTypeAsString() const { return ::ConnectionTypeAsString(m_conn_type); }
  ```

  **`ForNode` — `net.cpp:4126-4131`**
  ```diff
  -  4126|  1.08k|        if(pnode->GetId() == id) {
  -    |  Branch (4126:12): [True: 0, False: 1.08k]
  -  4127|      0|            found = pnode;
  -  4131|     39|    return found != nullptr && NodeFullyConnected(found) && func(found);
  -                                              ^0                          ^0
  +  4126|    602|        if(pnode->GetId() == id) {
  +    |  Branch (4126:12): [True: 1, False: 601]
  +  4127|      1|            found = pnode;
  +  4131|     28|    return found != nullptr && NodeFullyConnected(found) && func(found);
  +                                              ^1                          ^1
  ```

  **`ForEachNode` — `net.h:1270-1271`**
  ```diff
  -  1270|  1.13M|            if (NodeFullyConnected(node))
  -    |  Branch (1270:17): [True: 0, False: 1.13M]
  -  1271|      0|                func(node);
  +  1270|  1.11M|            if (NodeFullyConnected(node))
  +    |  Branch (1270:17): [True: 1.11M, False: 0]
  +  1271|  1.11M|                func(node);
  ```

  Two previously uncovered functions (`IsFullOutboundConn`, `ConnectionTypeAsString`) are now exercised through the iteration callbacks. `ForNode` finds matching nodes.

ACKs for top commit:
  nervana21:
    tACK 371eac8069
  maflcko:
    lgtm ACK 371eac8069

Tree-SHA512: 3587c021b16e38ca252676a21b66c5383ab2bd3eec9073e61e9a93db7ef84a94ce5a0c037ac512483680cafabb44103b86df0893e8a9b1bf63b8383bd54f4641
2026-05-19 15:32:56 +01:00
merge-script
ed15e14b63 Merge bitcoin/bitcoin#35193: test: avoid non-loopback network traffic from node_init_tests/init_test
1c500b1709 test: avoid non-loopback network traffic from node_init_tests/init_test (Vasil Dimov)

Pull request description:

  The test `node_init_tests/init_test` calls:
  `AppInitMain()` -> `StartMapPort()` -> `StartThreadMapPort()` -> `ThreadMapPort()` -> `ProcessPCP()` -> `PCPRequestPortMap()` -> `CreateSock()` and on the returned value from `CreateSock()` it calls the `Connect()` method.

  Thus, change `BasicTestingSetup::BasicTestingSetup()` to set `-natpmp` to 0. This way `node_init_tests/init_test` or other tests will not do network activity due to `ThreadMapPort()`.

  Also add a comment about `natpmp=0` in
  `test/functional/test_framework/util.py`.

  Also set `-dnsseed=0` in `BasicTestingSetup::BasicTestingSetup()` to
  avoid DNS queries.

ACKs for top commit:
  fjahr:
    re-ACK 1c500b1709
  ryanofsky:
    Code review ACK 1c500b1709, just disabling -dnsseed since previous review, which makes sense.

Tree-SHA512: 3b275d91361804da6d1dc109dffe741ea4b3dd3be916eb12fa63efa233e13ea4dab5a9f8448bd8bf99bc41817f3b7a768abe91531a3f63eae8b4c912bfcbd13e
2026-05-19 09:28:41 +01:00
Ava Chow
4f348c2d73 Merge bitcoin/bitcoin#28802: ArgsManager: support command-specific options
89af67d79f tests: Add some fuzz test coverage for command-specific args (Anthony Towns)
92df785859 tests: Add some test coverage for ArgsManager::AddCommand (Anthony Towns)
33c8090be9 ArgsManager: automate checking for correct command options (Anthony Towns)
186354a0d8 bitcoin-wallet: use command-specific options (Anthony Towns)
d21e82b7d6 ArgsManager: support command-specific options (Anthony Towns)

Pull request description:

  Adds the ability to link particular options to one or more (`OptionsCategory::COMMANDS`) commands, and uses this feature
  in `bitcoin-wallet`. Separates out the help information for these command-specific options (duplicating it if an option applies to multiple commands), and provides a function for checking at runtime if some options have been specified by the user that only apply to other commands.

  #### Motivation

  Currently, `ArgsManager` supports commands like `bitcoin-wallet dump` but while some of the options are command-specific (like `-dumpfile`), `ArgsManager` itself doesn't know that.  As a result, `-dumpfile` is listed in the global help rather than under the relevant commands, and if you use `-dumpfile` with a different command that doesn't support it, `ArgsManager` cannot automatically report that as an error, resulting in the commands that don't support the option having to have error-handling specific to all the options they don't support.

  #### Changes

  Help output moves command-specific options under their associated commands:

  Before:

  ```
  Options:
    -dumpfile=<file name>
         When used with 'dump', writes out the records to this file. When used
         with 'createfromdump', loads the records into a new wallet.
    ...

  Commands:
    createfromdump
         Create new wallet file from dumped records

    dump
         Print out all of the wallet key-value records
  ```

  After:

  ```
  Commands:
    createfromdump
         Create new wallet file from dumped records

         -dumpfile=<file name>
              When used with 'dump', writes out the records to this file. When
              used with 'createfromdump', loads the records into a new wallet.

    dump
         Print out all of the wallet key-value records

         -dumpfile=<file name>
              When used with 'dump', writes out the records to this file. When
              used with 'createfromdump', loads the records into a new wallet.
  ```

  Error messages are now generated automatically by `ArgsManager` rather than ad-hoc wallet code for each option:

  Before:
  ```c++
      if (args.IsArgSet("-dumpfile") && command != "dump" && command != "createfromdump") {
          tfm::format(std::cerr, "The -dumpfile option can only be used with the \"dump\" and \"createfromdump\" commands.\n");
          return false;
      }
  ```

  After:
  ```c++
      std::vector<std::string> details;
      if (!args.CheckCommandOptions(command, &details)) {
          tfm::format(std::cerr, "Error: Invalid arguments provided:\n%s\n", util::MakeUnorderedList(details));
          return false;
      }
  ```

  #### Limitations

  - If an option applies to multiple commands, it shares the same help text. There's no way to provide per-command descriptions.
  - Option parsing rules are unchanged — options still cannot appear after the command.

ACKs for top commit:
  achow101:
    ACK 89af67d79f
  sedited:
    Re-ACK 89af67d79f
  ryanofsky:
    Code review ACK 89af67d79f. Since last review: rebase, integration with ClearArgs and fuzz test, and Assume -> Assert switch

Tree-SHA512: 7ae7c3b74d0c8c4db8459e9f0b9c7498b2fa4758954ec49983decbba177877b039779f0f7b55e60c3a0ed74c5e9e4ac4734ba9e049bf3a7743280ef8300869fa
2026-05-18 13:37:09 -07:00
Ava Chow
c7056ff03f Merge bitcoin/bitcoin#34893: psbt: preserve proprietary fields when combining PSBTs
da769855d0 test: add PSBT proprietary merge regression coverage (w0xlt)
3f5b3c7a80 psbt: preserve proprietary fields when combining PSBTs (w0xlt)

Pull request description:

  BIP 174 proprietary fields are currently parsed, serialized, and exposed by `decodepsbt`, but they are not preserved by `combinepsbt`.

  The reason is that the merge paths in `PartiallySignedTransaction::Merge()`, `PSBTInput::Merge()`, and `PSBTOutput::Merge()` union `unknown`, but never union `m_proprietary`.

  This means application-specific PSBT metadata can be lost during combination, even though BIP 174 treats proprietary records as normal PSBT key-value pairs for private or application-specific use.

  This PR fixes that by preserving proprietary fields in all three merge paths.

ACKs for top commit:
  nervana21:
    re-ACK da769855d0
  Bicaru20:
    re-ACK da769855d0
  achow101:
    ACK da769855d0
  theStack:
    Code-review ACK da769855d0

Tree-SHA512: 4474674ac00c3155fd7d3d777bdeb70d4ca2006c8fe62eb84a888ef2f7aa02739bf31d8e9f2cb59e324be1085c77897f0bbf6673254c12408ab09a1582e28b83
2026-05-18 13:01:05 -07:00
merge-script
b2a3ca3df9 Merge bitcoin/bitcoin#35117: i2p: clean up SESSION CREATE error logging
b6c3670442 i2p: clean up SAM error logging (takeshikurosawaa)

Pull request description:

  Clean up the I2P SAM error path.

  `SESSION CREATE` may contain the private key, so the generic SAM reply
  error path now reports the redacted request text instead of the full
  request. It also avoids echoing raw router replies in those generic
  error messages.

  No network behavior change intended.

ACKs for top commit:
  davidgumberg:
    crACK b6c3670442
  vasild:
    ACK b6c3670442

Tree-SHA512: 204c8b64c6d3dd2f94f92cdc6d3daefd7773c42066984b9da859ebc2912c2ed38079d9e82a2d1f09d8d720750047114a80189e688929d7a0af5da2c2ee4a88da
2026-05-18 14:19:18 +01:00
Ryan Ofsky
7802e578c3 Merge bitcoin/bitcoin#34860: mining: always pad scriptSig at low heights, drop include_dummy_extranonce
8544537f41 mining: drop unused include_dummy_extranonce option (Sjors Provoost)
58eeab790d mining: only pad with OP_0 at heights <= 16 (Sjors Provoost)
00d22328b0 mining: pad coinbase to fix createNewBlock at heights <=16 (Sjors Provoost)
605ff37403 test: bad-cb-length for createNewBlock() at low heights (Sjors Provoost)
1966621b76 test: refactor IPC mining test to use script_BIP34_coinbase_height (Sjors Provoost)

Pull request description:

  Blocks 0-16 on any new chain require mining code to be careful not to violate the `bad-cb-length` rule, which states the coinbase transaction scriptSig must be at least 2 bytes.

  Our mining code deals with that by padding the `scriptSig` with a 0 `extraNonce`. It does this for every height. As a result IPC clients would get an unnecessary `0` in the `scriptSigPrefix` field of  `CoinbaseTx`. #32420 fixed that by introducing a `include_dummy_extranonce` option in `BlockCreateOptions` and turning that off for IPC clients.

  A minor issue was missed though: `createNewBlock()` now fails with `bad-cb-length`. An easy workaround is to use the `generate` RPC for the first 16 blocks, as demonstrated in the 2nd commit.

  The real fix is to have the miner code always pad the `scriptSig` at lower heights, but to _not_ include that in the `scriptSigPrefix` field of  `CoinbaseTx` (introduced in #33819). This is what the 3rd commit implements.

  Now that we set `scriptSigPrefix` independent of what our internal miner code does - to get past `CheckBlock()` - the original motivation for `include_dummy_extranonce` goes away and we can just drop it entirely. The last commit drops it, while the 4th commit adjusts the tests and hardcoded block and assume utxo hashes.

  This last change does not break IPC clients, because `include_dummy_extranonce` was never exposed in `mining.capnp`.

  Instead of adjusting the hardcoded hashes, an alternative approach would be to just always pad the `scriptSig` internally, since we exclude the padding from `scriptSigPrefix` anyway. However, IPC clients can also call `getBlock()` to get the raw block and might be confused about the difference. The miner code is also easier to understand if we limit the exception (`coinbase_tx.script_sig_prefix != coinbaseTx.vin[0].scriptSig`) to `nHeight <= 16`, where the explanation is based purely on consensus rules rather than historical test suite reasons.

  The first two commits are preperation test changes:
  -  extract `assert_capnp_failed` helper for macOS (also part of #34727)
  -  use `script_BIP34_coinbase_height` in IPC mining test (existing code in `interface_ipc_mining.py` was incorrect for low height

  Fixes #35126

ACKs for top commit:
  ryanofsky:
    Code review ACK 8544537f41. Just rebased to fix silent conflict and applied some minor suggestions since last review. As part of rereviewing I left some more minor suggestions that are fine to ignore.
  sedited:
    Re-ACK 8544537f41

Tree-SHA512: a01d48842bf4bcc1a9c51a89ef9d750766db7d04edb4dcd6b3a8bf195c6b4fa07445256a49367ff0db00ab489a52a3d7ff6a5c3ab9290ecb1fcb82f532552e9b
2026-05-17 13:26:23 -04:00
w0xlt
da769855d0 test: add PSBT proprietary merge regression coverage
Add unit and functional regression tests asserting that combine/merge preserves proprietary fields at the global, input, and output scopes.
2026-05-17 00:01:43 -07:00
w0xlt
3f5b3c7a80 psbt: preserve proprietary fields when combining PSBTs
CombinePSBTs currently preserves unknown records but drops proprietary records at the global, input, and output levels because the Merge() paths never union m_proprietary.

Preserve proprietary records in PartiallySignedTransaction::Merge(), PSBTInput::Merge(), and PSBTOutput::Merge() so combine/merge keeps all PSBT key-value data.
2026-05-16 23:57:14 -07:00
Ava Chow
ed1795aa17 Merge bitcoin/bitcoin#35285: bench: add benchmark for GetMappedAS()
096bb0b5c0 bench: add benchmark for GetMappedAS() (0xb10c)

Pull request description:

  With #28792 merged, we can use the embedded ASMap file to benchmark the IP -> ASN lookups. Before, this would have been cumbersome as it required having a real, external ASMap file. We want to benchmark against a real file, as a smaller test file has significantly faster lookups.

  The benchmarks cover individual IP address lookups of mapped and unmapped IPv4 and IPv6 addresses along with a multi-IP lookup. For the IPs we assume to be mapped, we assert that they are mapped. Updating the embedded ASMap file might change the benchmark results slightly as some lookups will be a bit faster and others slower.

  ```
  $ ./build/bin/bench_bitcoin --filter=ASMapGetMappedAS.* -min-time=5000

      |               ns/op |                op/s |    err% |     total | benchmark
      |--------------------:|--------------------:|--------:|----------:|:----------
      |              460.41 |        2,171,994.61 |    0.2% |      5.48 | `ASMapGetMappedASCloudflarev4`
      |              356.96 |        2,801,460.45 |    0.0% |      5.33 | `ASMapGetMappedASCloudflarev6`
      |              476.58 |        2,098,304.01 |    0.1% |      5.51 | `ASMapGetMappedASGooglev4`
      |              359.17 |        2,784,224.15 |    0.0% |      5.33 | `ASMapGetMappedASGooglev6`
      |              398.82 |        2,507,410.35 |    0.1% |      5.50 | `ASMapGetMappedASMulti`
      |              346.11 |        2,889,237.31 |    0.3% |      5.32 | `ASMapGetMappedASQuad9v4`
      |              274.21 |        3,646,832.70 |    0.1% |      5.50 | `ASMapGetMappedASQuad9v6`
      |                5.32 |      187,875,440.96 |    0.1% |      5.50 | `ASMapGetMappedASUnmappedv4`
      |               65.19 |       15,339,680.04 |    0.1% |      5.51 | `ASMapGetMappedASUnmappedv6`
  ```

  _LLM disclosure: while I wrote the initial benchmarks, I had a LLM review it and point out style nits and typos to me._

ACKs for top commit:
  l0rinc:
    ACK 096bb0b5c0
  fjahr:
    ACK 096bb0b5c0
  sipa:
    ACK 096bb0b5c0
  achow101:
    ACK 096bb0b5c0

Tree-SHA512: 417427fd546fe7ec0903dde6f1a6557479a2e353eaf26be61dacc0031adae1a9970263b143fe9e2b83f489da01031cc83eff8e11ccedb00f5852e44c40189da2
2026-05-15 16:59:46 -07:00
Ava Chow
379b9fbf03 Merge bitcoin/bitcoin#34225: refactor, key: move CreateMuSig2{Nonce,PartialSig} functions to musig.{h,cpp} module
8ba5f68b1d refactor, key: move `CreateMuSig2PartialSig` to `musig.{h,cpp}` module (Sebastian Falbesoner)
d087f266fc refactor, key: move `CreateMuSig2Nonce` to `musig.{h,cpp}` module (Sebastian Falbesoner)
f36d89f436 key: add `GetSecp256k1SignContext` access function (w0xlt)

Pull request description:

  This PR is a follow-up of #29675, see https://github.com/bitcoin/bitcoin/pull/29675#discussion_r2265077463. It moves all MuSig2 functions that currently live in `CKey` and call secp256k1 musig module API functions (i.e. `secp256k1_musig_...`) to the `musig.{h,cpp}` module, as this seems to be a better place. For accessing the `secp256k1_context_signing` object from the outside, a new function `GetSecp256k1SignContext` is added in the third commit.

  As the patch is mostly move-only, it can be best reviewed via the git option `--color-moved=dimmed-zebra`

ACKs for top commit:
  achow101:
    ACK 8ba5f68b1d
  w0xlt:
    reACK 8ba5f68b1d
  rkrux:
    lgtm ACK 8ba5f68b1d
  furszy:
    ACK 8ba5f68b1d

Tree-SHA512: 95fcaa5d7a09037a0dce0053b8c640a7372a1251a2a3615c565f4dacc5aad5cf0ee8bfc43aa0d0def628465c16330d69f6ea9fcc07bbadc971863248f60d1878
2026-05-15 16:42:44 -07:00
0xb10c
096bb0b5c0 bench: add benchmark for GetMappedAS()
With #28792 merged, we can use the embedded ASMap file to benchmark
the IP -> ASN lookups. Before, this would have been cumbersome as it
required having a real, external ASMap file. We want to benchmark
against a real file, as a smaller test file has significantly faster
lookups.

The benchmarks cover individual IP address lookups of mapped and
unmapped IPv4 and IPv6 addresses along with a multi-IP lookup.
For the IPs we assume to be mapped, we assert that they are mapped.
Updating the embedded ASMap file might change the benchmark results
slightly as some lookups will be a bit faster and others slower.

```
$ ./build/bin/bench_bitcoin --filter=ASMapGetMappedAS.* -min-time=5000

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|              460.41 |        2,171,994.61 |    0.2% |      5.48 | `ASMapGetMappedASCloudflarev4`
|              356.96 |        2,801,460.45 |    0.0% |      5.33 | `ASMapGetMappedASCloudflarev6`
|              476.58 |        2,098,304.01 |    0.1% |      5.51 | `ASMapGetMappedASGooglev4`
|              359.17 |        2,784,224.15 |    0.0% |      5.33 | `ASMapGetMappedASGooglev6`
|              398.82 |        2,507,410.35 |    0.1% |      5.50 | `ASMapGetMappedASMulti`
|              346.11 |        2,889,237.31 |    0.3% |      5.32 | `ASMapGetMappedASQuad9v4`
|              274.21 |        3,646,832.70 |    0.1% |      5.50 | `ASMapGetMappedASQuad9v6`
|                5.32 |      187,875,440.96 |    0.1% |      5.50 | `ASMapGetMappedASUnmappedv4`
|               65.19 |       15,339,680.04 |    0.1% |      5.51 | `ASMapGetMappedASUnmappedv6`
```

Co-authored-by: Fabian Jahr <fjahr@protonmail.com>
Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
2026-05-15 15:11:12 +02:00
takeshikurosawaa
b6c3670442 i2p: clean up SAM error logging
SESSION CREATE requests can contain the I2P private key. Keep using the redacted request text in error messages, and avoid echoing raw SAM replies in the generic reply error path.

This keeps the error useful while avoiding logging either the private-key-bearing request or unescaped router-controlled reply bytes. No network behavior change is intended.
2026-05-15 15:48:33 +03:00
Vasil Dimov
1c500b1709 test: avoid non-loopback network traffic from node_init_tests/init_test
The test calls:
`AppInitMain()` -> `StartMapPort()` -> `StartThreadMapPort()` ->
`ThreadMapPort()` -> `ProcessPCP()` -> `PCPRequestPortMap()` ->
`CreateSock()` and on the returned value from `CreateSock()` it calls
the `Connect()` method.

Thus, change `BasicTestingSetup::BasicTestingSetup()` to set `-natpmp`
to 0. This way `node_init_tests/init_test` or other tests will not do
network activity due to `ThreadMapPort()`.

Also add a comment about `natpmp=0` in
`test/functional/test_framework/util.py`.

Also set `-dnsseed=0` in `BasicTestingSetup::BasicTestingSetup()` to
avoid DNS queries.
2026-05-15 12:14:03 +02:00
merge-script
ddb94fd3e1 Merge bitcoin/bitcoin#35289: fuzz: Fix timeout in txorphan
004a7e3cfb fuzz: Fix txorphan timeout by limiting block weight (marcofleon)

Pull request description:

  The `EraseForBlock` branch in the `txorphan` harness could produce a block with 1000 transactions in it, each with potentially up to 200,000 inputs, resulting in way too many [map lookups](3cab711d69/src/node/txorphanage.cpp (L625)). This was producing inputs that were taking 2 seconds or longer per iteration, which is too long.

  Fix by only adding transactions to the block up to the block weight limit. This matches production behavior, as `EraseForBlock` is only called on a newly [connected block](3cab711d69/src/net_processing.cpp (L2090)).

ACKs for top commit:
  maflcko:
    lgtm ACK 004a7e3cfb
  instagibbs:
    ACK 004a7e3cfb
  sedited:
    ACK 004a7e3cfb

Tree-SHA512: 465504402358e1bed629104b21e05301139f1590884de21e77d566a45e422eef6d4380c5714692f33f5398e4e299b8c9f84b82f58c56a98e410c5c841184aee5
2026-05-14 17:25:50 +02:00
merge-script
3cab711d69 Merge bitcoin/bitcoin#35284: fuzz: use ImmediateBackgroundTaskRunner to silence DEBUG_LOCKORDER
801d36f55b fuzz: use ImmediateBackgroundTaskRunner to silence DEBUG_LOCKORDER (Eugene Siegel)

Pull request description:

  DEBUG_LOCKORDER was reporting a false positive deadlock with the cmpctblock fuzz harness when using ImmediateTaskRunner. Since it is single-threaded, ImmediateTaskRunner callbacks added LockOrders that could never happen outside of a fuzz test.

  First a block would get connected:
  * LOCK(mempool.cs)
  * BlockConnected (fuzz test runs in same thread)
  * LOCK(m_tx_download_mutex)

  Then a later iteration of the LIMITED_WHILE would send a TX:
  * LOCK(m_tx_download_mutex)
  * LOCK(mempool.cs)

  causing a false positive deadlock. Normally, the BlockConnected callback would run in a different thread and no deadlock is reported.

  Fix this by launching a thread that runs the callback and is immediately joined. I compared this PR to another branch (0028847c6b) that uses a ThreadPool and found this PR to be more stable and ~4% quicker.

ACKs for top commit:
  maflcko:
    lgtm ACK 801d36f55b
  sedited:
    ACK 801d36f55b

Tree-SHA512: 5e1f27354c484a90ffd74a1a11e5fed68d7b38d95c06dd39529217f07d535eb9a5b7befb42b2829d79c52b5eb43542bd1079c81d6eb0e56476352ffe98e0177e
2026-05-14 14:21:09 +02:00
marcofleon
004a7e3cfb fuzz: Fix txorphan timeout by limiting block weight 2026-05-14 12:32:04 +01:00
merge-script
cad5f56045 Merge bitcoin/bitcoin#29136: wallet: addhdkey RPC to add just keys to wallets via new unused(KEY) descriptor
a39cc16b43 doc: Release note for addhdkey (Ava Chow)
89b9a01b4e wallet, rpc: Disallow importing unused() to wallets without privkeys (Ava Chow)
35bbee6374 wallet, rpc: Disallow import of unused() if key already exists (Ava Chow)
f3f8bcbd1d wallet: Add addhdkey RPC (Ava Chow)
82bc280de4 test: Simple test for importing unused(KEY) (Ava Chow)
80c29bc6f1 descriptor: Add unused(KEY) descriptor (Ava Chow)

Pull request description:

  It is sometimes useful for the wallet to have keys that it can sign with but are not (initially) involved in any scripts, e.g. for setting up a multisig. Ryanofsky [suggested](https://github.com/bitcoin/bitcoin/pull/26728#issuecomment-1867721948) A `unused(KEY)` descriptor which allows for a key to be specified, but produces no scripts. These can be imported into the wallet, and subsequently retrieved with `gethdkeys`. Additionally, `listdescriptors` will output these descriptors so that they can be easily backed up.

  In order to make it easier for people to add HD keys to their wallet, and to generate a new one if they want to rotate their descriptors, an `addhdkey` RPC is also added. Without arguments, it will generate a new HD key and add it to the wallet via a `unused(KEY)` descriptor. If provided a private key, it will construct the descriptor and add it to the wallet.

  See also: https://github.com/bitcoin/bitcoin/pull/26728#issuecomment-1866961865

  Based on #29130 as `gethdkeys` is useful for testing this.

ACKs for top commit:
  Sjors:
    utACK a39cc16
  rkrux:
    lgtm ACK a39cc16b43

Tree-SHA512: c1288c792ab01ca2eaddd24b0e7d11c259cd59e79042465d0d1eb656fd559c1200dc19750b4d84acc762b5b599935a06df214c18226e662087842ea91ec3011b
2026-05-14 11:40:16 +02:00
Ava Chow
9961229360 Merge bitcoin/bitcoin#31298: rpc: combinerawtransaction now rejects unmergeable transactions
6d86184a8b rpc: combinerawtransaction now rejects unmergeable transactions (Adam Andrews)

Pull request description:

  Previously, combinerawtransaction would silently return the first tx when asked to combine unrelated txs. Now, it will check tx mergeability and throws a descriptive error if tx cannot be merged.

  fixes  #25980

ACKs for top commit:
  nervana21:
    tACK 6d86184a8b
  achow101:
    ACK 6d86184a8b
  rkrux:
    ACK [6d86184](6d86184a8b)

Tree-SHA512: 5caf983c5ab618a000f40b9ad698439d3e6217ec2dc593740443f47d90f8804a895f3054dd29bbcecdb48a61992b0d0afda7ec89591d768a44918648bbb6e20d
2026-05-13 16:07:35 -07:00
Ava Chow
c680cfe343 Merge bitcoin/bitcoin#35123: wallet: remove outdated arguments from chain scanning methods
dc84a31014 wallet: remove fUpdate argument from AddToWalletIfInvolvingMe (rkrux)
94845df073 wallet: remove update_tx argument from SyncTransaction (rkrux)
6e796e1f47 wallet: remove fUpdate argument from ScanForWalletTransactions (rkrux)
54e4c0be8f wallet: remove update argument from RescanFromTime method (rkrux)

Pull request description:

  This caught my attention while going through #32993.

  The corresponding boolean arguments from CWallet methods related to
  updating transactions during the blockchain scanning have been removed
  because effectively these arguments were always passed as true making
  the need for the boolean arguments unnecessary. The only falsy call sites
  were in the unit tests that don't need to test scenarios that never happen
  in actuality.

ACKs for top commit:
  Bicaru20:
    ACK dc84a31014. I also think that makes sense to remove the update argument if it is not used.
  achow101:
    ACK dc84a31014
  sedited:
    ACK dc84a31014
  l0rinc:
    untested code review ACK dc84a31014

Tree-SHA512: dfee793c88cc94d4a5b554e29710133ec4ad5e49455413245c7d7004ef71b618b0b2f821fa085415c34d80aeccd182c98e55223d84afbe8b408f64acac0571bb
2026-05-13 14:34:15 -07:00
Ava Chow
a145fa881a Merge bitcoin/bitcoin#35156: dbwrapper: reuse scratch DataStream buffers
032223f403 dbwrapper: reuse iterator scratch stream (Lőrinc)
7403c0f907 dbwrapper: guard `CDBBatch` scratch streams (Lőrinc)
cb1ab0a716 test: cover repeated dbwrapper stream use (Lőrinc)
31ce729b28 streams: add `ScopedDataStreamUsage` (Lőrinc)

Pull request description:

  ### Problem
  `CDBIterator::GetValue()` cannot use `SpanReader` the same way as `::GetKey()` because values are deobfuscated in place before deserialization, so it still needs an owning mutable buffer.
  However, the current path allocates a fresh `DataStream` for every value read.

  The same local-stream pattern also exists in `CDBIterator::Seek()`, while `CDBBatch` already owns reusable key/value buffers but still manually reserves and clears them on every `Write()` and `Erase()` call.

  ### Fix
  Add `ScopedDataStreamUsage`, a small RAII helper for caller-owned scratch streams.
  It asserts that the stream is empty on entry (making accidental re-entry or concurrent use of the same scratch stream fail fast), and clears it on scope exit.

  Use it to guard the reusable scratch streams in `CDBBatch::Write()`, `::Erase()` and `CDBIterator::Seek()`, `::GetValue()`.
  The const read-side `CDBWrapper` helpers stay unchanged, since they can be called concurrently on the same wrapper and should keep using local streams.

  The production changes are preceded by tests covering repeated reuse on the same owning objects, including a failed iterator value decode followed by a successful read from the same iterator entry.

  ### Context
  Follow-up to #35128, #34483 and #35025.

  ### Reproducer
  `gettxoutsetinfo` gets an additional ~6% speedup on top of the previous iterator-key optimization:

  <details><summary>2026-04-24 | gettxoutsetinfo | i9-ssd | x86_64 | Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz | 16 cores | 62Gi RAM | xfs | SSD</summary>

  ```bash
  COMMITS="2d5ab09f0dca4bfec0b365f5f431def2c0c9d70f 9e5fd595ae8ebeec74678c31a547fbc14f87bf89"; \
  BASE_DIR="/mnt/my_storage"; DATA_DIR="$BASE_DIR/BitcoinData"; LOG_DIR="$BASE_DIR/logs"; \
  mkdir -p "$LOG_DIR" && \
  (echo ""; for c in $COMMITS; do git cat-file -e "$c^{commit}" 2>/dev/null || git fetch -q origin "$c" || exit 1; git log -1 --pretty='%h %s' "$c" || exit 1; done) && \
  (echo "" && echo "$(date -I) | gettxoutsetinfo | $(hostname) | $(uname -m) | $(lscpu | grep 'Model name' | head -1 | cut -d: -f2 | xargs) | $(nproc) cores | $(free -h | awk '/^Mem:/{print $2}') RAM | $(df -T $BASE_DIR | awk 'NR==2{print $2}') | $(lsblk -no ROTA $(df --output=source $BASE_DIR | tail -1) | grep -q 1 && echo HDD || echo SSD)"; echo "") && \
  hyperfine \
    --sort command \
    --runs 3 \
    --export-json "$BASE_DIR/gettxoutsetinfo-$(sed -E 's/([a-f0-9]{8})[a-f0-9]* ?/\1-/g;s/-$//'<<<"$COMMITS")-$(date +%s).json" \
    --parameter-list COMMIT ${COMMITS// /,} \
    --prepare "killall -9 bitcoind 2>/dev/null || true; rm -f $DATA_DIR/debug.log; git clean -fxd && git reset --hard {COMMIT} && \
      cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release && ninja -C build bitcoind bitcoin-cli -j$(nproc) && \
      ./build/bin/bitcoind -datadir=$DATA_DIR -connect=0 -listen=0 -dnsseed=0 -coinstatsindex=0 -txindex=0 -blockfilterindex=0 -daemon -printtoconsole=0; \
      ./build/bin/bitcoin-cli -datadir=$DATA_DIR -rpcwait getblockcount >/dev/null" \
    --conclude "./build/bin/bitcoin-cli -datadir=$DATA_DIR stop 2>/dev/null || true; killall bitcoind 2>/dev/null || true; sleep 10; \
      grep -q 'Done loading' $DATA_DIR/debug.log && grep 'Bitcoin Core version' $DATA_DIR/debug.log | grep -q \"\$(git rev-parse --short=12 {COMMIT})\"; \
      cp $DATA_DIR/debug.log $LOG_DIR/gettxoutsetinfo-{COMMIT}-$(date +%s).log" \
    "./build/bin/bitcoin-cli -datadir=$DATA_DIR -rpcclienttimeout=0 -named gettxoutsetinfo hash_type='none' use_index='false' >/dev/null"

  2d5ab09f0d Merge bitcoin/bitcoin#35124: bench: fix benchmark fixtures and setup checks
  cb63e158d9 walletdb: reuse batch scratch streams

  2026-04-24 | gettxoutsetinfo | i9-ssd | x86_64 | Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz | 16 cores | 62Gi RAM | xfs | SSD

  Benchmark 1: ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/BitcoinData -rpcclienttimeout=0 -named gettxoutsetinfo hash_type='none' use_index='false' >/dev/null (COMMIT = 2d5ab09f0d)
    Time (mean ± σ):     60.063 s ±  1.623 s    [User: 0.001 s, System: 0.002 s]
    Range (min … max):   59.020 s … 61.933 s    3 runs

  Benchmark 2: ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/BitcoinData -rpcclienttimeout=0 -named gettxoutsetinfo hash_type='none' use_index='false' >/dev/null (COMMIT = cb63e158d9ae8276dbe54bba0b0cf8f35378ec71)
    Time (mean ± σ):     56.853 s ±  0.179 s    [User: 0.002 s, System: 0.001 s]
    Range (min … max):   56.675 s … 57.033 s    3 runs

  Relative speed comparison
          1.06 ±  0.03  ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/BitcoinData -rpcclienttimeout=0 -named gettxoutsetinfo hash_type='none' use_index='false' >/dev/null (COMMIT = 2d5ab09f0d)
          1.00          ./build/bin/bitcoin-cli -datadir=/mnt/my_storage/BitcoinData -rpcclienttimeout=0 -named gettxoutsetinfo hash_type='none' use_index='false' >/dev/null (COMMIT = cb63e158d9ae8276dbe54bba0b0cf8f35378ec71)
  ```

  </details>

ACKs for top commit:
  andrewtoth:
    re-ACK 032223f403
  CruzMolina:
    tACK 032223f403
  achow101:
    ACK 032223f403
  optout21:
    ACK 032223f403
  sedited:
    ACK 032223f403

Tree-SHA512: 6ed51d1a492ca216108b10c01668b01f986260641714951da1d282f1dacf87f0df2b312108f24c06151d3b81eaa4ca6eb4e9ab4e2d829346b0e8f07d0c569a1e
2026-05-13 14:27:11 -07:00
merge-script
04003e1fa3 Merge bitcoin/bitcoin#35274: doc: clarify libfuzzer-nosan preset uses build_fuzz_nosan dir
0065f354a7 doc: clarify libfuzzer-nosan preset uses build_fuzz_nosan dir (ImMike)

Pull request description:

  Adds a clarifying note next to the first mention of the `libfuzzer-nosan` preset in the Quickstart, pointing out that it uses a different build directory (`build_fuzz_nosan`, per [`CMakePresets.json` L54](https://github.com/bitcoin/bitcoin/blob/master/CMakePresets.json#L54)).

  A reader following the quickstart with `--preset=libfuzzer-nosan` and then running `cmake --build build_fuzz` as shown would otherwise operate against the wrong (or empty) directory.

  Pure docs; no code changes.

ACKs for top commit:
  l0rinc:
    ACK 0065f354a7
  maflcko:
    lgtm ACK 0065f354a7
  sedited:
    ACK 0065f354a7

Tree-SHA512: d73901112d259cec58746dff50fe3f9409e5b9826f0759f45478fe039bca851eb163036c60bdb215bfc66be79428b790742bbe8bc32b1ceaa2d6f80c17faf6d0
2026-05-13 20:59:12 +02:00
merge-script
5309c90542 Merge bitcoin/bitcoin#35283: doc: mention -DWITH_ZMQ=ON in BSD build guides
ca93ab808c doc: mention -DWITH_ZMQ=ON in BSD build guides (junbyjun1238)

Pull request description:

  The BSD build guides currently state:

  > If the package is installed, support will be compiled in.

  Since `WITH_ZMQ` defaults to `OFF`, this is inaccurate: installing the dependency alone does not enable ZMQ support. Update the wording to mention the required `-DWITH_ZMQ=ON` CMake option, matching `doc/zmq.md`.

  Docs-only change; no tests run.

ACKs for top commit:
  maflcko:
    lgtm ACK ca93ab808c
  sedited:
    ACK ca93ab808c

Tree-SHA512: d07b1b9748d8b6aa555c992608f8659b7e93d6587bbbb2170352342003e90a81592ddfa2abf3a26b8ebf1341142d8628cfc3faba0c4759655a91446afa5fc22a
2026-05-13 20:56:05 +02:00
Sjors Provoost
8544537f41 mining: drop unused include_dummy_extranonce option
The previous commit made CreateNewBlock() ignore the
include_dummy_extranonce flag (OP_0 is now appended only at heights
<= 16 to satisfy bad-cb-length, regardless of caller-supplied options).

Remove the now-unused field from BlockCreateOptions and clean up all
the call sites that still set it (RPC, bench, fuzz, test setups).
2026-05-13 18:27:48 +02:00
Sjors Provoost
58eeab790d mining: only pad with OP_0 at heights <= 16
Drop the include_dummy_extranonce branch from the OP_0 padding
condition in CreateNewBlock(), so that the dummy extraNonce is
only appended when consensus actually requires it (heights <= 16,
where the BIP34 height push alone would yield a 1-byte scriptSig
and trigger bad-cb-length).

The include_dummy_extranonce option struct field is now unused by
the miner and is removed in the next commit. Callers still set it,
so that this commit compiles.

Regenerate the hardcoded coinbase / block hashes throughout the
unit and functional test suites and update the regtest assumeutxo
snapshot in chainparams.

Additional side-effects:

- Without the dummy extranonce, coinbase scriptSigs are 1 byte
  shorter at heights > 16, making every block 1 byte smaller.
  This shifts where block files wrap and therefore where pruning
  boundaries land.

- feature_assumeutxo malleation cases:
  - case 1: error message changes due to UTXO reordering, similar
            to 8f2078af6a
  - case 4: the corruption byte is swapped from \x82 to \x83
            because \x82 happened to be the actual value at that
            offset in the new snapshot.
2026-05-13 18:27:48 +02:00
Sjors Provoost
00d22328b0 mining: pad coinbase to fix createNewBlock at heights <=16
Since #32420, createNewBlock has thrown `bad-cb-length` errors when called at
low block heights because `OP_0` padding stopped being added to coinbase
transactions. (#32420 did add an `include_dummy_extranonce` option which could
bypass this, but it was not exposed to IPC clients.) Fix the problem by padding
coinbase transactions with `OP_0` when necessary to produce valid blocks.

Additionally this commit stops adding `OP_0` padding to the template
`script_sig_prefix` field when `include_dummy_extranonce` is true. This is safe
because non-IPC clients don't use this field, and IPC clients could never set
the option to true, and are expected to add their own nonces in any case.

This also improves documentation about the `script_sig_prefix` field and
`getCoinbaseTx` method.
2026-05-13 18:27:48 +02:00
Eugene Siegel
801d36f55b fuzz: use ImmediateBackgroundTaskRunner to silence DEBUG_LOCKORDER
DEBUG_LOCKORDER was reporting a false positive deadlock with the
cmpctblock fuzz harness when using ImmediateTaskRunner. Since it is
single-threaded, ImmediateTaskRunner callbacks added LockOrders that
could never happen outside of a fuzz test.

First a block would get connected:
* LOCK(mempool.cs)
* BlockConnected (fuzz test runs in same thread)
* LOCK(m_tx_download_mutex)

Then a later iteration of the LIMITED_WHILE would send a TX:
* LOCK(m_tx_download_mutex)
* LOCK(mempool.cs)

causing a false positive deadlock. Normally, the BlockConnected
callback would run in a different thread and no deadlock is reported.

Fix this by launching a thread that runs the callback and is
immediately joined.
2026-05-13 12:00:27 -04:00
junbyjun1238
ca93ab808c doc: mention -DWITH_ZMQ=ON in BSD build guides
The FreeBSD, NetBSD, and OpenBSD build guides state that ZMQ support is compiled in when the package is installed. Since WITH_ZMQ defaults to OFF, update the wording to mention the required CMake option.
2026-05-14 00:30:10 +09:00
Sjors Provoost
605ff37403 test: bad-cb-length for createNewBlock() at low heights
On new regtest / signet chains (heights <= 16), createBlock() fails
internally with bad-cb-length. Since mining.capnp does not expose
include_dummy_extranonce, IPC clients can't work around this.

Add a functional test to illustrate this issue and use RPC to
work around it. The next commit introduces a fix.
2026-05-13 16:44:00 +02:00
Sjors Provoost
1966621b76 test: refactor IPC mining test to use script_BIP34_coinbase_height
Needed in a later commit to correctly derive the BIP34 prefix
for heights <= 16.

Add a padding parameter to script_BIP34_coinbase_height() that
controls whether the OP_0 dummy extranonce is appended for
heights <= 16.

Use this helper with padding=False in the IPC mining test's
build_coinbase_test().
2026-05-13 16:43:31 +02:00
Sebastian Falbesoner
8ba5f68b1d refactor, key: move CreateMuSig2PartialSig to musig.{h,cpp} module
Compared to `CreateMuSig2Nonce`, creating a partial signature
has a stronger link to the secret key used, but for consistency
reasons it still makes sense to move all functionality that call
the secp256k1 musig API functions to the `musig.{h,cpp}` module
for consistency.

Can be reviewed via the git option `--color-moved=dimmed-zebra`.
2026-05-13 16:17:36 +02:00
Sebastian Falbesoner
d087f266fc refactor, key: move CreateMuSig2Nonce to musig.{h,cpp} module
Nonce creation is mainly derived by randomness, and the secret
key merely serves as (optional) additional data for increasing
misuse-resistance, rather than being a central part that would
justify an own CKey method, so move it to the musig.cpp module.

Can be reviewed via the git option `--color-moved=dimmed-zebra`.
2026-05-13 16:17:33 +02:00
w0xlt
f36d89f436 key: add GetSecp256k1SignContext access function
This is needed in order to move the `CreateMuSig2{Nonce,PartialSig}`
functions to the musig.cpp modules, see next two commits.
2026-05-13 16:01:29 +02:00
ImMike
0065f354a7 doc: clarify libfuzzer-nosan preset uses build_fuzz_nosan dir
The fuzzing quickstart documents the libfuzzer preset with build_fuzz
as the build directory, then mentions libfuzzer-nosan as an alternative
without noting that this preset uses a different binary directory
(build_fuzz_nosan, per CMakePresets.json line 54). A reader following
the quickstart with --preset=libfuzzer-nosan and then running
'cmake --build build_fuzz' as shown will operate against the wrong
(or empty) directory.

Add a clarifying note at the first mention in the Quickstart.
2026-05-13 08:49:28 -04:00
rkrux
81348576cc psbt, test: remove address type restrictions in test
Because the corresponding Taproot fields were added in PSBT in PR 22558, so
these restrictions are no longer necessary.
2026-05-13 17:09:09 +05:30
merge-script
82733e61de Merge bitcoin/bitcoin#35277: ci: Enable ruff ambiguous-unicode-character checks
fa9c919678 refactor: Use ignore-list over verbose select-list (MarcoFalke)
fa9b01adec ci: Enable ruff ambiguous-unicode-character checks (MarcoFalke)

Pull request description:

  Ambiguous unicode chars are unused and confusing. Worst, they can lead to bugs.

  So enable the ruff checks to catch them. Can be tested via:

  ```
  echo 'ZGlmZiAtLWdpdCBhL3Rlc3QvZnVuY3Rpb25hbC93YWxsZXRfZGlzYWJsZS5weSBiL3Rlc3QvZnVu
  Y3Rpb25hbC93YWxsZXRfZGlzYWJsZS5weQppbmRleCBkYmNjY2Q0Li4wYjhjNDQ2IDEwMDc1NQot
  LS0gYS90ZXN0L2Z1bmN0aW9uYWwvd2FsbGV0X2Rpc2FibGUucHkKKysrIGIvdGVzdC9mdW5jdGlv
  bmFsL3dhbGxldF9kaXNhYmxlLnB5CkBAIC0yMSwzICsyMSw4IEBAIGNsYXNzIERpc2FibGVXYWxs
  ZXRUZXN0IChCaXRjb2luVGVzdEZyYW1ld29yayk6CiAgICAgZGVmIHJ1bl90ZXN0IChzZWxmKToK
  KyAgICAgICAgIiIiQSBsb3ZlbHkgZG9jc3RyaW5nICh3aXRoIGEgYFUrRkYwOWAgcGFyZW50aGVz
  aXPvvIkuIiIiCiAgICAgICAgICMgTWFrZSBzdXJlIHdhbGxldCBpcyByZWFsbHkgZGlzYWJsZWQK
  KyAgICAgICAgIyBu0L5xYSAgIzwtIGlzIEN5cmlsbGljIChgVSswNDNFYCkKKyAgICAgICAgcHJp
  bnQoIs6XZWxsbywgd29ybGQhIikgICMgPC0gaXMgdGhlIEdyZWVrIGV0YSAoYFUrMDM5N2ApLgor
  ICAgICAgICBleGFtcGxlID0gInjigI8iICogMTAwICAjICAgICLigI94IiBpcyBhc3NpZ25lZAor
  ICAgICAgICBleGFtcGxlPU5vbmUjbm9xYQogICAgICAgICBhc3NlcnRfcmFpc2VzX3JwY19lcnJv
  cigtMzI2MDEsICdNZXRob2Qgbm90IGZvdW5kJywgc2VsZi5ub2Rlc1swXS5nZXR3YWxsZXRpbmZv
  KQo=' | base64 --decode | git apply

  git diff

  ruff check ./test/functional/*.py
  ```

  It should print 4 error types.

ACKs for top commit:
  stickies-v:
    ACK fa9c919678
  willcl-ark:
    ACK fa9c919678

Tree-SHA512: de226ec2feaf65a0a8b15606708cc390296be4492f41221f8a49f034b16e8fb62125342c6993f9d5c76bd4ae2db7343851b252a1b9140e27d6777f19a0b1605e
2026-05-13 12:19:16 +01:00
merge-script
fe2bb43e43 Merge bitcoin/bitcoin#35044: contrib: Fix NameError in signet miner gbt()
701bc2dc02 contrib: Fix NameError in signet miner gbt() (Torkel Rogstad)

Pull request description:

  The logging.warning call referenced `bci["bestblockhash"]`, a variable from the calling scope `do_generate()` that is not available inside the `Generate.gbt()` method. This would crash with a NameError when getblocktemplate returned a template based on an unexpected previous block.

  Use the `bestblockhash` parameter that was already being passed in and used correctly in the comparison on the line above.

  The bug was introduced in 7b31332370 when the gbt logic was extracted into its own method — the if-condition was updated but the logging call was not.

ACKs for top commit:
  kevkevinpal:
    ACK [701bc2d](701bc2dc02)
  sedited:
    ACK 701bc2dc02

Tree-SHA512: 53764db954dd40b68d2f92279fd609732402fdbac4a1838aeee81d366b2b7fbc8da86b07f6f05cee62cb8ecdc514f6e0af1e59c65380eec38cbeaa58ec3c10ed
2026-05-13 12:34:20 +02:00
MarcoFalke
fa9c919678 refactor: Use ignore-list over verbose select-list
This refactor makes the ruff.toml easier to read, because it lists the
ignored checks instead of having to enumerate all checks to select in a
large collection of rules.
2026-05-13 12:24:09 +02:00
MarcoFalke
fa9b01adec ci: Enable ruff ambiguous-unicode-character checks 2026-05-13 10:33:25 +02:00
merge-script
09a9bb3536 Merge bitcoin/bitcoin#34547: lint: modernise lint tooling
2424e52836 lint: doc: detail lint tool install methods (will)
5fefa5a654 Don't pin Python patch version (Sjors Provoost)
fd15b55c2e lint: use requirements.txt (will)
5f4d3383da lint: switch to ruff for formatting and linting (will)
a53b81ce4e lint: switch to uv for python management in linter (will)

Pull request description:

  Modernise our lint tooling by:

  \- Replacing pyenv + pip with [uv](https://docs.astral.sh/uv/) for better Python environment and dependency management
  \- Move uv ruff and ty to install via `COPY --from` multi-stage Docker image imports
  \- Moving ruff lint rules from hardcoded Rust array (in lint_py.rs) into a top-level ruff.toml
  \- Extracting all remaining pip dependencies into dedicated ci/lint/requirements.txt

  Extra rationale:

  `COPY --from` pulls pre-built binaries from upstream images instead of compiling/downloading at runtime. Containerfile layer optimisations reduce rebuild frequency further.

  Pinning tool versions in the dockerfile makes it more excplicit and easier to find.

  The tradeoff we make here is that there is no longer a single install script to install tooling on a local machine. However I think this is OK, as it currently only works for `apt`-based OSes anyway, and I don't think running the linter outside of the container is such a valuable use-case as it is with some of the other CI jobs.

ACKs for top commit:
  maflcko:
    review ACK 2424e52836 🗿
  sedited:
    ACK 2424e52836

Tree-SHA512: 32ef989c1e241cebe5f13da10abd23f6f63306591fd1f81880d688b886082bca17987591dc592c41fbb72278eba57b3cc6e786de7cfa80eb490ab34465d0119b
2026-05-13 10:27:38 +02:00
Ava Chow
10ca73c02c Merge bitcoin/bitcoin#34580: build: Add a compiler minimum feature check
ac1ccc5bd9 build: Add CTAD feature check (Pol Espinasa)
9f273f1c1c build: Add path to doc recommended versions for CLANG, GCC and MSVC (Pol Espinasa)

Pull request description:

  Adds a compiler features check. If failed, it returns a fatal error.
  This early stop at configure time will avoid contributors losing time trying to fix compilation errors because of not fitting the requirements.

  Example of the output for GCC:
  Version requirement satisfied:
  ```
  $ cmake -B build
  -- The CXX compiler identification is GNU 13.3.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  ...
  -- Checking for required C++ features
  -- Checking for required C++ features - done
  ....
  ```
  Compiler feature requirement not satisfied:
  ```
  $ cmake -B build -DCMAKE_C_COMPILER=/usr/bin/gcc-10 -DCMAKE_CXX_COMPILER=/usr/bin/g++-10
  -- The CXX compiler identification is GNU 10.5.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/g++-10 - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Setting build type to "RelWithDebInfo" as none was specified
  -- Performing Test CXX_SUPPORTS__WERROR
  -- Performing Test CXX_SUPPORTS__WERROR - Success
  -- Found SQLite3: /usr/include (found suitable version "3.45.1", minimum required is "3.7.17")
  -- Checking for required C++ features
  CMake Error at cmake/module/CheckCXXFeatures.cmake:32 (message):
    Compiler lacks Class Template Argument Deduction (CTAD) for aggregates.

    This C++ feature is required for src/util/overloaded.h.

    You are probably using an old compiler version

    The recommended compiler versions can be checked in:

      - GCC -> doc/dependencies.md#compiler
      - Clang -> doc/dependencies.md#compiler
      - MSVC -> doc/build-windows-msvc.md

  Call Stack (most recent call first):
    CMakeLists.txt:198 (check_cxx_features)

  -- Configuring incomplete, errors occurred!

  ```

  Example of the output for Clang:
  Compiler feature requirement satisfied:
  ```
  $ cmake -B build -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=clang++-20
  -- The CXX compiler identification is Clang 20.1.2
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/clang++-20 - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  ...
  -- Checking for required C++ features
  -- Checking for required C++ features - done
  ...
  ```

  Compiler feature requirement not satisfied:
  ```
  $ cmake -B build -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16
  -- The CXX compiler identification is Clang 16.0.6
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/clang++-16 - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Setting build type to "RelWithDebInfo" as none was specified
  -- Performing Test CXX_SUPPORTS__WERROR
  -- Performing Test CXX_SUPPORTS__WERROR - Success
  -- Performing Test CXX_SUPPORTS__G3
  -- Performing Test CXX_SUPPORTS__G3 - Success
  -- Performing Test LINKER_SUPPORTS__G3
  -- Performing Test LINKER_SUPPORTS__G3 - Success
  -- Performing Test CXX_SUPPORTS__FTRAPV
  -- Performing Test CXX_SUPPORTS__FTRAPV - Success
  -- Performing Test LINKER_SUPPORTS__FTRAPV
  -- Performing Test LINKER_SUPPORTS__FTRAPV - Success
  -- Found SQLite3: /usr/include (found suitable version "3.45.1", minimum required is "3.7.17")
  -- Checking for required C++ features
  CMake Error at cmake/module/CheckCXXFeatures.cmake:32 (message):
    Compiler lacks Class Template Argument Deduction (CTAD) for aggregates.

    This C++ feature is required for src/util/overloaded.h.

    You are probably using an old compiler version

    The recommended compiler versions can be checked in:

      - GCC -> doc/dependencies.md#compiler
      - Clang -> doc/dependencies.md#compiler
      - MSVC -> doc/build-windows-msvc.md

  Call Stack (most recent call first):
    CMakeLists.txt:198 (check_cxx_features)

  -- Configuring incomplete, errors occurred!
  ```

  Edit: The first version of the PR was to check hardcoded compiler versions. See previous PR description for context here.
  <details>

  Adds a compiler minimum version check. If failed, it returns a fatal error.
  This early stop at configure time will avoid contributors losing time trying to fix compilation errors because of not fitting the requirements.

  Example of the output for GCC:
  Version requirement satisfied:
  ```
  sliv3r@sliv3r-tuxedo:~/Documentos/Projectes/BitcoinCore/bitcoin$ cmake -B BUILD
  -- The CXX compiler identification is GNU 13.3.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  ....
  ```
  Version requirement not satisfied:
  ```
  $ cmake -B build -S .   -DCMAKE_C_COMPILER=/usr/bin/gcc-11   -DCMAKE_CXX_COMPILER=/usr/bin/g++-11
  -- The CXX compiler identification is GNU 11.5.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/g++-11 - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  CMake Error at CMakeLists.txt:91 (message):
    GCC >= 12.1 required.

  -- Configuring incomplete, errors occurred!

  ```

  Example of the output for Clang:
  Version requirement satisfied:
  ```
  sliv3r@sliv3r-tuxedo:~/Documentos/Projectes/BitcoinCore/bitcoin$ cmake -B build
  -- The CXX compiler identification is Clang 18.1.3
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  ...
  ```

  Version requirement not satisfied:
  ```
  $ cmake -B build -DCMAKE_C_COMPILER=clang-16       -DCMAKE_CXX_COMPILER=clang++-16
  -- The CXX compiler identification is Clang 16.0.6
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/clang++-16 - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  CMake Error at CMakeLists.txt:86 (message):
    Clang >= 17.0 required.

  -- Configuring incomplete, errors occurred!
  ```
  <\detail>

ACKs for top commit:
  davidgumberg:
    crACK ac1ccc5bd9
  achow101:
    ACK ac1ccc5bd9
  vasild:
    ACK ac1ccc5bd9
  w0xlt:
    ACK ac1ccc5bd9
  ryanofsky:
    Code review ACK ac1ccc5bd9. Very much agree with all the previous comments to not check specific compiler versions, and glad this PR is in better shape now.

Tree-SHA512: 15a12f56016846427ed8273406c3e9a52a6435bf7033c8fef82bb0e6c9fd75d40a62c79d33f9dd6da8717500f21a629da07620f160b3d43368dd7579f773b4bc
2026-05-11 15:29:35 -07:00
merge-script
1af8e0c4e8 Merge bitcoin/bitcoin#35183: doc: recommend script_flags instead of deployments.taproot
f24a7b5f75 doc: recommend script_flags instead of deployments.taproot (Sjors Provoost)

Pull request description:

  #26201 removed `taproot` from `getdeploymentinfo` (not yet in a release, slated for v32), which it turns out Lnd relies on: https://github.com/lightningnetwork/lnd/pull/10683

  Expand the release doc note to recommend the same solution they used: check for `TAPROOT` in the `script_flags` array. This was added in v31.

ACKs for top commit:
  maflcko:
    Stakeholder-aligned SLA-compliant production-ready enterprise-grade lgtm ACK f24a7b5f75
  sedited:
    ACK f24a7b5f75

Tree-SHA512: 5c21300ce3140eb1dd122e007b2f2cfafa3de83db4fb7c699312d6886d4c8fea56d9602390c1931fc640bf9364b2274dde85b38da4957311ddc07721cbc924a7
2026-05-11 11:52:17 +02:00
Sjors Provoost
f24a7b5f75 doc: recommend script_flags instead of deployments.taproot
Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2026-05-11 11:30:27 +02:00
merge-script
ccbd00ab87 Merge bitcoin/bitcoin#35152: doc: clarify local IWYU workflow and pragmas
d084bc88be doc: clarify IWYU workflow (Lőrinc)
7c7cec4567 ci: update IWYU patch reference (Lőrinc)

Pull request description:

  ### Problem

  This was prompted by https://github.com/bitcoin/bitcoin/pull/34435#discussion_r3123255248, where it was not clear to me how (and where) exceptional IWYU cases should be documented.

  ### Fix
  This PR documents the IWYU CI wrapper as the reproducible local entrypoint.

  The developer notes now recommend reducing suspected IWYU false positives to a minimal upstream reproducer, treat `IWYU pragma` as a narrow workarounds, and ask for nearby rationale comments on non-obvious IWYU pragma use. An example comment was also added.

  The IWYU patch comment is also updated to point at the current `clang_22` include picker reference.

  ### Reproducer
  Create a dummy commit on top that adds an unused include, then run the command from the developer notes.
  Without the dummy commit, the command should pass.

  <details><summary>IWYU demo commit</summary>

  ```diff
  diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp
  --- a/src/kernel/bitcoinkernel.cpp(revision c92b329e7b7d49476b5977d26c24d7c4982c6024)
  +++ b/src/kernel/bitcoinkernel.cpp(revision ad2c5ba2ba69156e77061c1e6c098b725c28f322)
  @@ -43,6 +43,7 @@
   #include <functional>
   #include <list>
   #include <memory>
  +#include <vector>
   #include <span>
   #include <stdexcept>
   #include <string>
  ```

  </details>

  > [!NOTE]
  > After repeated failing runs, `docker container rm -f ci_native_iwyu` may be needed because the local CI wrapper can leave the detached container running when the inner test command fails.

ACKs for top commit:
  hebasto:
    ACK d084bc88be.
  sedited:
    ACK d084bc88be

Tree-SHA512: 0aac42d468a1fdfa9f4a3856372e05fb43ec9f0973aeb3a4194fff948fc61e8e72e3b280cde10e74b8da88b6cff93962b3a7f7390eb042113ef92aa6b51d6d8f
2026-05-10 19:24:58 +02:00
merge-script
88bfe89793 Merge bitcoin/bitcoin#35227: wallet: check the final BDB page LSN during migration
e2b0984f99 wallet: check BDB last page LSN (Lőrinc)

Pull request description:

  ### Problem

  Legacy wallet migration uses the read-only BDB parser to verify that every page LSN is reset before reading records without BDB log files.

  The BDB `last_page` metadata field stores the last valid page number, but the parser treated it like a page count and scanned only `0..<last_page`:
  e2b0984f99/src/wallet/migrate.cpp (L87)
  This skipped the final page, so a database whose last page still depended on BDB logs could be accepted.

  ### Fix

  Scan LSNs through `last_page` inclusively.

ACKs for top commit:
  achow101:
    ACK e2b0984f99
  w0xlt:
    ACK e2b0984f99
  sedited:
    ACK e2b0984f99

Tree-SHA512: 26fade6cdb4747d299b6e620646aa14751cd91fbb7e40ab6e35c1ca796fb589a2340d66108b812611f2924136a8f12c4f911efe6346fffaf04b2d3d288101cda
2026-05-10 12:02:33 +02:00
Hennadii Stepanov
21599ea612 Merge bitcoin/bitcoin#35241: cmake: Set CTEST_NIGHTLY_START_TIME for CDash Nightly pipelines
4defc466a2 cmake: Set `CTEST_NIGHTLY_START_TIME` for CDash Nightly pipelines (Hennadii Stepanov)

Pull request description:

  This PR follows up on https://github.com/bitcoin/bitcoin/pull/35222.

  According to the [CMake documentation](https://cmake.org/cmake/help/latest/variable/CTEST_NIGHTLY_START_TIME.html) for `CTEST_NIGHTLY_START_TIME`:
  > ... this variable must always be set for a nightly build in a dashboard script.

  Examples of nightly build reports utilizing this configuration can be found on the [Bitcoin Core CDash board](https://my.cdash.org/index.php?project=bitcoin-core), based on [this commit](98aad4f72f).

ACKs for top commit:
  ferminquant:
    ACK 4defc466a2
  purpleKarrot:
    ACK 4defc466a2

Tree-SHA512: 7d3f5dc9f9f1336fc03f565d36750c66bdbae5a3916dabf4ab02c3c2584fc7135a8839e94d7fa08bcbb530913cf0eea31fc402dbdc1c22e207402c991dac044d
2026-05-10 10:01:15 +02:00
merge-script
d406cffafd Merge bitcoin/bitcoin#34228: depends: Unset SOURCE_DATE_EPOCH in gen_id script
9f7a2293c4 depends: Unset `SOURCE_DATE_EPOCH` in `gen_id` script (Hennadii Stepanov)

Pull request description:

  When performing Guix builds for `{x86_64,arm64}-apple-darwin` hosts across different commits, all packages in `depends` are rebuilt even if there are no changes in either the  `depends` or `contrib/guix` subdirectories.

  This occurs because the `SOURCE_DATE_EPOCH` environment variable enables Clang's `-source-date-epoch` option, which then appears in the output of `clang -v -E -xc -o /dev/null - < /dev/null`. For example:
  ```
  $ SOURCE_DATE_EPOCH=1767855465 clang -v -E -xc++ -o /dev/null - < /dev/null
  clang version 21.1.7 (Fedora 21.1.7-1.fc43)
  Target: x86_64-redhat-linux-gnu
  Thread model: posix
  InstalledDir: /usr/bin
  Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
  System configuration file directory: /etc/clang/
  Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/14
  Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/15
  Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/15
  Candidate multilib: .;@m64
  Candidate multilib: 32;@m32
  Selected multilib: .;@m64
   (in-process)
   "/usr/bin/clang-21" -cc1 -triple x86_64-redhat-linux-gnu -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/hebasto -v -fcoverage-compilation-dir=/home/hebasto -resource-dir /usr/bin/../lib/clang/21 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15 -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/x86_64-redhat-linux -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/backward -internal-isystem /usr/bin/../lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -source-date-epoch 1767855465 -fdeprecated-macro -ferror-limit 19 -fmessage-length=180 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /dev/null -x c++ -
  clang -cc1 version 21.1.7 based upon LLVM 21.1.7 default target x86_64-redhat-linux-gnu
  ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../x86_64-redhat-linux/include"
  ignoring nonexistent directory "/include"
  #include "..." search starts here:
  #include <...> search starts here:
   /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15
   /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/x86_64-redhat-linux
   /usr/bin/../lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/backward
   /usr/bin/../lib/clang/21/include
   /usr/local/include
   /usr/include
  End of search list.
  ```

  As a result, each package id differs between builds, which causes the script to treat the toolchain as changed and triggers unnecessary rebuilds.

  This PR resolves this issue by [clobbering](https://github.com/bitcoin/bitcoin/pull/34228#issuecomment-4387135450) the `SOURCE_DATE_EPOCH` value in the `gen_id` script.

  ---

  Suggested testing scenario:
  ```
  $ env HOSTS=arm64-apple-darwin ./contrib/guix/guix-build
  $ git commit --allow-empty -m "Trigger rebuild"
  $ env HOSTS=arm64-apple-darwin ./contrib/guix/guix-build
  ````

  The last command will rebuild depends on the master branch, but will successfully use the cached built packages on this PR.

ACKs for top commit:
  maflcko:
    lgtm ACK 9f7a2293c4
  fanquake:
    ACK 9f7a2293c4

Tree-SHA512: d5fa90100edfd88024ad949a9d75c8af274a054c0926ae4ddea6ecf1c38fae833670b360c56c740a7565cf393a92597823749fe75c85a27ae1ebebead4093853
2026-05-08 12:09:10 +02:00
Hennadii Stepanov
4defc466a2 cmake: Set CTEST_NIGHTLY_START_TIME for CDash Nightly pipelines 2026-05-08 11:09:06 +02:00
Ava Chow
1f28ed6b6a Merge bitcoin/bitcoin#35235: contrib: mv verify-commits/pre-push-hook.sh to maintainer tools repo
888857c551 mv contrib/verify-commits/pre-push-hook.sh to maintainer tools repo (MarcoFalke)

Pull request description:

  To https://github.com/bitcoin-core/bitcoin-maintainer-tools/pull/198

ACKs for top commit:
  achow101:
    ACK 888857c551
  kevkevinpal:
    ACK [888857c](888857c551)
  l0rinc:
    code review ACK 888857c551

Tree-SHA512: 9dac8fcaa393d3ff175b30cf53f5f074eeb4d1e51517ba545933282862020db3b00830e03a2c8b27a31f47b91d3f07e47d3aa1aafb8eb42f38eaf73c3c19ff81
2026-05-08 01:36:39 -07:00