47449 Commits

Author SHA1 Message Date
merge-script
5b8c204275
Merge bitcoin/bitcoin#34384: Remove epoch logic from mempool
40735450c00b10baa03e3a7f1e2bee439077e356 Remove unused epochguard.h (Suhas Daftuar)
1a8494d16c7b1c21dec384438c18ac08a469bb61 Rework CTxMemPool::GetChildren() to not use epochs (Suhas Daftuar)

Pull request description:

  Since #33591, the epoch-based graph traversal optimization logic is only used for `CTxMempool::GetChildren()`, a function that is only used in RPC code and tests. Rewrite it without epochs, and remove `util/epochguard.h` itself, as that was its last use.

  This allows us to reduce per-transaction memory usage by 8 bytes, for no material loss. With the new TxGraph-based mempool implementation, I also don't foresee future uses for it, as TxGraph can do even better by using BitSet-based traversal tracking.

ACKs for top commit:
  ajtowns:
    ACK 40735450c00b10baa03e3a7f1e2bee439077e356
  instagibbs:
    ACK 40735450c00b10baa03e3a7f1e2bee439077e356
  l0rinc:
    code review ACK 40735450c00b10baa03e3a7f1e2bee439077e356

Tree-SHA512: 7ce7c04835cd2425a71c4fd47f316b6fb7381caa27383de7ecc4aa81100fcf7bc5e062699b307c08e0b853b35f06710d9ac761d6e660af9f9331e708d36f2fe0
2026-01-23 15:10:54 +00:00
merge-script
891030ac8b
Merge bitcoin/bitcoin#33822: kernel: Add block header support and validation
9a9d797ef6ed8e1b3e876fc93cf1a6395ab270e9 kernel: Add support for block headers (yuvicc)
b851ff6cae71934bf2389d109908339d60ec6e5b  kernel: Add Handle/View pattern for BlockValidationState (yuvicc)

Pull request description:

  Adds a new `btck_BlockHeader` type and associated functions to create, access, and validate block headers. Block headers will have their own type (`btck_BlockHeader`) that can be created from raw data, copied, and queried for all the standard header fields (hash, prev hash, timestamp, bits, version, nonce). We can also extract headers from full blocks or block tree entries.

  The first commit here refactors `BlockValidationState` to use Handle/View pattern so external code can own them, which is required for the header processing in the API.

   #### New Block Header API

    - **`btck_BlockHeader` type**: Opaque handle for block headers
    - **Header methods**:
      - `btck_block_header_create()`: Create header from 80-byte serialized data
      - `btck_block_header_copy()`: Copy block headers
      - `btck_block_header_destroy()`: Destroy header object
      - `btck_block_header_get_hash()`: Calculate block hash
      - `btck_block_header_get_prev_hash()`: Get previous block hash
      - `btck_block_header_get_timestamp()`: Get block timestamp
      - `btck_block_header_get_bits()`: Get difficulty target (compact format)
      - `btck_block_header_get_version()`: Get block version
      - `btck_block_header_get_nonce()`: Get proof-of-work nonce

      - `btck_block_get_header()`: Extract header from a full block
      - `btck_block_tree_entry_get_block_header()`: Get header associated with a block tree entry

    - **Header Processing Methods:**
      - **`btck_chainstate_manager_process_block_header()`**: Validates and processes a block header without requiring the full block. This performs proof-of-work verification, timestamp validation, and updates the internal chain state.
      - **`btck_chainstate_manager_get_best_entry()`**: Returns the block tree entry with the most cumulative proof-of-work.

  Why `btck_chainstate_manager_get_best_entry()` is included alongside header validation? Just as we have logic to get the tip for block validation (so you can request more blocks extending your best from your peers), we need the equivalent for header validation. To make header validation worthwhile, knowing what the best current header is seems useful—it tells you what headers to request next from peers.

    ### Testing

    Added tests in `test_kernel.cpp` that cover creating headers from raw data, extracting all header fields, and processing headers through the chainstate manager.

    CC sedited

ACKs for top commit:
  stringintech:
    re-ACK 9a9d797e
  sedited:
    Re-ACK 9a9d797ef6ed8e1b3e876fc93cf1a6395ab270e9
  janb84:
    ACK 9a9d797ef6ed8e1b3e876fc93cf1a6395ab270e9

Tree-SHA512: 1dde9ef860543c906d1bb5e604f0d2956e7382fcbb55090686261b2277270a1fd3826f02ecf1749b2774da66e88f686c7845172b4c68b62259e7a7aee0825fa2
2026-01-23 13:04:05 +00:00
merge-script
0871e104a2
Merge bitcoin/bitcoin#34242: Prepare string and net utils for future HTTP operations
1911db8c6dc6b32c8971b14b2b271ec39d9f3ab9 string: add LineReader (Matthew Zipkin)
ee62405cce2bf3d14117bdb327832f12584968d6 time: implement and test RFC1123 timestamp string (Matthew Zipkin)
eea38787b9be99c3f192cb83fc18358397e4ab52 string: add AsciiCaseInsensitive{KeyEqual, Hash} for unordered map (Matthew Zipkin)
4e300df7123a402aef472aaaac30907b18a10c27 string: add `base` argument for ToIntegral to operate on hexadecimal (Matthew Zipkin)
0b0d9125c19c04c1fc19fb127d7639ed9ea39bec Modernize GetBindAddress() (Matthew Zipkin)
a0ca851d26f8a9d819708db06fec2465e9f6228c Make GetBindAddress() callable from outside net.cpp (Matthew Zipkin)

Pull request description:

  This is a component of [removing libevent as a dependency of the project](https://github.com/bitcoin/bitcoin/issues/31194). It is the first six commits of #32061 and provides a string-parsing utility (`LineReader`) that is also consumed by #34158.

  These are the functions that are added / updated for HTTP and Torcontrol:

  - `GetBindAddress()`: Given a socket, provides the bound address as a CService. Currently used by p2p but moved from `net` to `netbase` so other modules can call it.
  - `ToIntegral()`: Already used to parse numbers from strings, added new argument `base = 10` so it can also be used to parse hexadecimal integers. HTTP chunked transfer-encoding uses hex-encoded integers to specify payload size: https://datatracker.ietf.org/doc/html/rfc7230.html#section-4.1
  - `AsciiCaseInsensitive` comparators: Needed to store HTTP headers in an `unordered_map`. Headers are key-value pairs that are parsed with case-insensitive keys: https://httpwg.org/specs/rfc9110.html#rfc.section.5.1
  - `FormatRFC1123DateTime()`: The required datetime format for HTTP headers (e.g. `Fri, 31 May 2024 19:18:04 GMT`)
  - `LineReader`: Fields in HTTP requests are newline-terminated. This struct is given an input buffer and provides methods to read lines as strings.

ACKs for top commit:
  maflcko:
    review ACK 1911db8c6dc6b32c8971b14b2b271ec39d9f3ab9 👲
  furszy:
    utACK 1911db8c6dc6b32c8971b14b2b271ec39d9f3ab9
  sedited:
    ACK 1911db8c6dc6b32c8971b14b2b271ec39d9f3ab9

Tree-SHA512: bb8d3b7b18f158386fd391df6d377c9f5b181051dc258efbf2a896c42e20417a1b0b0d4637671ebd2829f6bc371daa15775625af989c19ef8aee76118660deff
2026-01-23 13:25:42 +01:00
merge-script
1b079becf1
Merge bitcoin/bitcoin#34317: fuzz: Exclude too expensive inputs in descriptor_parse targets
fab2f3df4beb230eef63bdcf5042b6417c0012dc fuzz: Exclude too expensive inputs in descriptor_parse targets (MarcoFalke)

Pull request description:

  Accepting "expensive" fuzz inputs which have no real use-case is problematic, because it prevents the fuzz engine from spending time on the next useful fuzz input.

  For example, those will take several seconds (!) and the flamegraph shows that base58 encoding is the cause:

  ```
  curl -fLO 'f5abf41608'
  curl -fLO '78cb317546'

  FUZZ=mocked_descriptor_parse ./bld-cmake/bin/fuzz ./f5abf41608addcef3538da61d8096c2050235032
  FUZZ=descriptor_parse ./bld-cmake/bin/fuzz ./78cb3175467f53b467b949883ee6072e92dbb267
  ```

  This will also break 32-bit fuzzing, see https://github.com/bitcoin/bitcoin/issues/34110#issuecomment-3759461248.

  Fix all issues by checking for `HasTooLargeLeafSize`.

  Sorry for creating several pull requests to fix this class of issue, but I think this one should be the last one. 😅

ACKs for top commit:
  brunoerg:
    reACK fab2f3df4beb230eef63bdcf5042b6417c0012dc
  frankomosh:
    re-ACK fab2f3df4beb230eef63bdcf5042b6417c0012dc

Tree-SHA512: 4ecf98ec4adc39f6e014370945fb1598cdd3ceba60f7209b00789ac1164b6d20e82a69d71f8419d9a40d57ee3fea36ef593c47fe48b584b6e8344c44f20a15c1
2026-01-23 09:54:22 +00:00
merge-script
cdb42a8df8
Merge bitcoin/bitcoin#34380: test: Fix P2PK script test
c9ce1c7c4a12b54ada7d48f100ec3a141ae99f86 test: Fix P2PK script test (billymcbip)

Pull request description:

  I found another script_tests case that isn't behaving the way it was meant to. It's a P2PK spend where we add an `OP_NOP8` to the scriptSig to make it non-push-only. The test should check that [`scriptSig.IsPushOnly()`](691dc830c6/src/script/interpreter.cpp (L2055)) is only enforced in P2SH mode when the scriptPubKey actually matches the P2SH pattern. To test this, we need to **turn on the P2SH flag**.

ACKs for top commit:
  sipa:
    ACK c9ce1c7c4a12b54ada7d48f100ec3a141ae99f86
  darosior:
    utACK c9ce1c7c4a12b54ada7d48f100ec3a141ae99f86

Tree-SHA512: 0af1d7b4651478349abc97cf0c009488cf5af5f97135382f7dd37cef0ef9b563192244330899a54ee7e0296bf03ba702e37a7aa15248c5c0ab4745095efc2402
2026-01-23 09:31:29 +00:00
Suhas Daftuar
40735450c0 Remove unused epochguard.h 2026-01-22 21:51:13 -05:00
Suhas Daftuar
1a8494d16c Rework CTxMemPool::GetChildren() to not use epochs
This is likely slightly slower, but this was the last place we were using
epochs instead of sets to deduplicate, and this is only used by the RPC code
and in tests, and should not be CPU-performance critical. Eliminating this
allows us to save 8 bytes in CTxMemPoolEntry.

Co-Authored-By: Pieter Wuille <bitcoin-dev@wuille.net>
2026-01-22 21:51:13 -05:00
Ava Chow
7b48b09b7f
Merge bitcoin/bitcoin#34376: bench/test: clarify merkle bench and witness test intent
8b9d30e3facff0cd132dc3faf6282d75b1f9b532 bench/test: clarify merkle bench and witness test intent (Lőrinc)

Pull request description:

  Follow-up to #32497.

  Clarify why the witness merkle test uses an odd leaf count (it exercises leaf duplication in `ComputeMerkleRoot()`), and make the coinbase witness hash initialization explicit.

  Also simplify the leaf-copy loop in the `MerkleRoot` benchmark for readability.

  No production code is changed in this follow-up, for simplicity and safety.

ACKs for top commit:
  optout21:
    ACK 8b9d30e3facff0cd132dc3faf6282d75b1f9b532
  maflcko:
    lgtm ACK 8b9d30e3facff0cd132dc3faf6282d75b1f9b532
  achow101:
    ACK 8b9d30e3facff0cd132dc3faf6282d75b1f9b532
  w0xlt:
    ACK 8b9d30e3fa
  danielabrozzoni:
    tACK 8b9d30e3facff0cd132dc3faf6282d75b1f9b532

Tree-SHA512: 6efca7c19ebf96bb8d0def4217ed30d3b74b58a7be15566967e98aba9b03aaddd0e0ebb3b8f43130b5f397a7d9eed0470a48a55438f440e0bceefb87edd16b27
2026-01-22 13:49:33 -08:00
MarcoFalke
fab2f3df4b
fuzz: Exclude too expensive inputs in descriptor_parse targets
Also, fixup iwyu warnings in the util module.

Also, fixup a typo.

The moved part can be reviewed with the git option:
--color-moved=dimmed-zebra
2026-01-22 21:01:55 +01:00
Matthew Zipkin
1911db8c6d
string: add LineReader
This is a helper struct to parse HTTP messages from data in buffers
from sockets. HTTP messages begin with headers which are
CRLF-terminated lines (\n or \r\n) followed by an arbitrary amount of
body data. Whitespace is trimmed from the field lines but not the body.

https://httpwg.org/specs/rfc9110.html#rfc.section.5
2026-01-22 12:10:33 -05:00
Matthew Zipkin
ee62405cce
time: implement and test RFC1123 timestamp string
HTTP 1.1 responses require a timestamp header with a format
specified (currently) by:
https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.7

This specific format is defined in RFC1123:
https://www.rfc-editor.org/rfc/rfc1123#page-55

The libevent implementation can be referenced in evutil_time.c
evutil_date_rfc1123()
2026-01-22 11:33:23 -05:00
Matthew Zipkin
eea38787b9
string: add AsciiCaseInsensitive{KeyEqual, Hash} for unordered map
https://httpwg.org/specs/rfc9110.html#rfc.section.5.1
Field names in HTTP headers are case-insensitive. These
structs will be used in the headers map to search by key.

In libevent field names are also converted to lowercase for comparison:
  evhttp_find_header()
  evutil_ascii_strcasecmp()
  EVUTIL_TOLOWER_()
2026-01-22 11:32:27 -05:00
merge-script
1d8cb78d5b
Merge bitcoin/bitcoin#34309: guix: stop passing depends sources to codesigning
d94d7b1a4b70cc93296c19fd221f8b8ac8ab90ee guix: stop passing depends sources to codesigning (fanquake)

Pull request description:

  I think this is just a copy-pasta from the build container (which has existed since this file was introduced in 38eb91eb0616ed6dbe34c23e11588d130fef07f8). I don't see why we'd need the depends sources available when performing codesigning.

ACKs for top commit:
  hebasto:
    ACK d94d7b1a4b70cc93296c19fd221f8b8ac8ab90ee, I have reviewed the code and it looks OK.
  willcl-ark:
    ACK d94d7b1a4b70cc93296c19fd221f8b8ac8ab90ee
  sedited:
    tACK d94d7b1a4b70cc93296c19fd221f8b8ac8ab90ee

Tree-SHA512: 972b15aa022b79602f40c198187a54d85ceeee0014fd2232ca967bb52e4624cbb85b3ef1cdeac3ccd8c7b337a13c3be9c90291141495c8136a8e72ad2cd4ec4a
2026-01-22 17:20:43 +01:00
Matthew Zipkin
4e300df712
string: add base argument for ToIntegral to operate on hexadecimal 2026-01-22 10:44:38 -05:00
Matthew Zipkin
0b0d9125c1
Modernize GetBindAddress()
Replace the C-style casting with C++ reinterpret_cast
2026-01-22 10:35:14 -05:00
merge-script
7041648ee5
Merge bitcoin/bitcoin#34375: doc: mempool: fix removeUnchecked incorrect comment
1137debb85306063f1660bc15850979e7db88fb8 doc: mempool: fix  `removeUnchecked` incorrect comment (ismaelsadeeq)

Pull request description:

  `CTxMemPool::removeUnchecked` description comment is stale and incorrect; the behaviour being described no longer applies in the post-cluster world.  This PR is a simple fix that attempts to correctly describe what is being done in removeUnchecked.

ACKs for top commit:
  instagibbs:
    ACK 1137debb85306063f1660bc15850979e7db88fb8
  sipa:
    ACK 1137debb85306063f1660bc15850979e7db88fb8

Tree-SHA512: e410be57a83df50df01fcd6d7b07d08f0fe5a2abd229974f1ad269bb2e301608fd0d3912af349e2971f9a8abdbaa8e90c46d4832ec7b6858639642742b31a618
2026-01-22 14:45:16 +00:00
yuvicc
9a9d797ef6
kernel: Add support for block headers
Introduces btck_BlockHeader type with accessor methods and btck_chainstate_manager_process_block_header() for validating headers without full blocks. Also, adds btck_chainstate_manager_get_best_entry() to query the header with most cumulative proof-of-work.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2026-01-22 20:06:27 +05:30
ismaelsadeeq
1137debb85
doc: mempool: fix removeUnchecked incorrect comment
- CTxMemPool::removeUnchecked description comment is stale and incorrect
  after cluster mempool.
  This commit fixes the issue by deleting the stale comment and describing
  only the implicit behaviour triggered by the method.
2026-01-22 14:09:50 +00:00
billymcbip
c9ce1c7c4a test: Fix P2PK script test 2026-01-22 13:14:00 +01:00
merge-script
691dc830c6
Merge bitcoin/bitcoin#34377: test: Rename wallet in restore attempt in wallet_assumeutxo
e1dc4afeeb6b3da4b7d9b0ca31ab21dda0a84478 test: Rename wallet name in restore attempt in wallet_assumeutxo (Fabian Jahr)

Pull request description:

  I hope this fixes #34354

  Based on this error from the logs `filesystem error: cannot remove: The process cannot access the file because it is being used by another process` it looks like there still exists a wallet file by the same name from the previous test case hasn't been cleaned up yet by it's process fully. This should be fixed by giving the failing `restorewallet` case a different wallet name and this shouldn't have any further effects on the rest of the test because is expected to fail anyway. The following (successful) call already uses a different wallet name.

ACKs for top commit:
  achow101:
    ACK e1dc4afeeb6b3da4b7d9b0ca31ab21dda0a84478
  w0xlt:
    ACK e1dc4afeeb6b3da4b7d9b0ca31ab21dda0a84478
  rkrux:
    ACK e1dc4afeeb6b3da4b7d9b0ca31ab21dda0a84478

Tree-SHA512: b5c53252a3b71fde150b29cc90cfd80a8678e3d7a39bcd6038e6722f2ac50d0a0db480e0a8ad43e39d4738971c39280415822e4d64c02895cbb6bd05ff3fc02e
2026-01-22 12:59:37 +01:00
merge-script
d7fd8c6952
Merge bitcoin/bitcoin#34090: net: Fix -Wmissing-braces
f46e3ec0f9567a19ad9c111f264d395341327e4a net: Fix `-Wmissing-braces` (Hennadii Stepanov)

Pull request description:

  On some non-POSIX platforms, Clang emits `-Wmissing-braces` warnings for the `IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` macros. For example, on OpenIndiana / illumos:
  ```
  $ uname -srv
  SunOS 5.11 illumos-325e0fc8bb
  $ clang --version
  clang version 21.1.7 (https://github.com/OpenIndiana/oi-userland.git 36a81bf5e5d307d4e85893422600678d46328010)
  Target: x86_64-pc-solaris2.11
  Thread model: posix
  InstalledDir: /usr/clang/21/bin
  $ cmake -B build -DCMAKE_GENERATOR=Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_IPC=OFF -DAPPEND_CXXFLAGS='-Wno-unused-command-line-argument'
  $ cmake --build build
  [284/573] Building CXX object src/CMakeFiles/bitcoin_node.dir/net.cpp.o
  /export/home/hebasto/dev/bitcoin/src/net.cpp:3309:42: warning: suggest braces around initialization of subobject [-Wmissing-braces]
   3309 |         const CService ipv6_any{in6_addr(IN6ADDR_ANY_INIT), GetListenPort()}; // ::
        |                                          ^~~~~~~~~~~~~~~~
  /usr/include/netinet/in.h:479:32: note: expanded from macro 'IN6ADDR_ANY_INIT'
    479 | #define IN6ADDR_ANY_INIT            {   0, 0, 0, 0,     \
        |                                         ^~~~~~~~~~~~~~~~~
    480 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    481 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    482 |                                         0, 0, 0, 0 }
        |                                         ~~~~~~~~~~
  1 warning generated.
  [467/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/i2p_tests.cpp.o
  /export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:116:34: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    116 |     const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656};
        |                                  ^~~~~~~~~~~~~~~~~~~~~
  /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
        |                                         ^~~~~~~~~~~~~~~~~
    485 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    486 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    487 |                                         0, 0, 0, 0x1U }
        |                                         ~~~~~~~~~~~~~
  /export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:159:38: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    159 |         const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656};
        |                                      ^~~~~~~~~~~~~~~~~~~~~
  /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
        |                                         ^~~~~~~~~~~~~~~~~
    485 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    486 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    487 |                                         0, 0, 0, 0x1U }
        |                                         ~~~~~~~~~~~~~
  2 warnings generated.
  [483/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/netbase_tests.cpp.o
  /export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:505:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    505 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0 /* port */),
        |                                    ^~~~~~~~~~~~~~~~~~~~~
  /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
        |                                         ^~~~~~~~~~~~~~~~~
    485 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    486 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    487 |                                         0, 0, 0, 0x1U }
        |                                         ~~~~~~~~~~~~~
  /export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:510:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    510 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0x00f1 /* port */),
        |                                    ^~~~~~~~~~~~~~~~~~~~~
  /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
        |                                         ^~~~~~~~~~~~~~~~~
    485 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    486 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    487 |                                         0, 0, 0, 0x1U }
        |                                         ~~~~~~~~~~~~~
  /export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:515:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
    515 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0xf1f2 /* port */),
        |                                    ^~~~~~~~~~~~~~~~~~~~~
  /usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
    484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
        |                                         ^~~~~~~~~~~~~~~~~
    485 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    486 |                                         0, 0, 0, 0,     \
        |                                         ~~~~~~~~~~~~~~~~~
    487 |                                         0, 0, 0, 0x1U }
        |                                         ~~~~~~~~~~~~~
  3 warnings generated.
  [573/573] Linking CXX executable bin/test_bitcoin
  ```

  The same issue is observed on Windows. For further details, see https://github.com/bitcoin/bitcoin/pull/31507.

ACKs for top commit:
  bensig:
    ACK f46e3ec0f9567a19ad9c111f264d395341327e4a
  maflcko:
    review ACK  f46e3ec0f9567a19ad9c111f264d395341327e4a 👭
  vasild:
    ACK f46e3ec0f9567a19ad9c111f264d395341327e4a
  sedited:
    utACK f46e3ec0f9567a19ad9c111f264d395341327e4a

Tree-SHA512: 9ad597d393ba04537b3aa728070ea7bbe1fc8796f6d8f3d90eb511242e5a61b0ab18123a6be3cca89aaa20ba7fb4dbe682c4d1c6bd3f6d883c459133e0c2861f
2026-01-22 12:39:52 +01:00
Hennadii Stepanov
1fbbdd20cd
Merge bitcoin/bitcoin#34355: doc: Fix wrong code in WITH_LOCK doxygen comment
fa61fadad1c3df0274c3ddd351b8d68a0c4fe644 doc: Fix wrong code in WITH_LOCK doxygen comment (MarcoFalke)

Pull request description:

  The typo is harmless, but a bit confusing every time i read it

ACKs for top commit:
  hebasto:
    re-ACK fa61fadad1c3df0274c3ddd351b8d68a0c4fe644.
  l0rinc:
    ACK fa61fadad1c3df0274c3ddd351b8d68a0c4fe644

Tree-SHA512: 302a284198178954512267e8c0a5708738d77aac1cf609d8cbb386bee78d705f7e0df42a7bd8300afc18d42fa271c7f4cda932b1cbea33385622b3760bb95fad
2026-01-22 11:22:39 +00:00
merge-script
9016858282
Merge bitcoin/bitcoin#34297: p2p: add validation checks for initial self-announcement
6a8dbf9b9352db48580cd81c8dac027f3138fedf p2p: add validation check for initial self-announcement (frankomosh)

Pull request description:

  This is a follow up to #34146 . Adds validation check to the initial self-announcement code path. `IsAddrCompatible()` check can prevent sending non-routable addresses to peers that don't support addrv2.

ACKs for top commit:
  fjahr:
    utACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf
  Crypt-iQ:
    crACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf
  stratospher:
    ACK 6a8dbf9. preserves the existing behaviour. also learnt that Addr-fetch ADDR processing logic allows receiving a self-announcement with 1 address [without disconnecting](b6c5d1e450) and won't be affected.
  sedited:
    ACK 6a8dbf9b9352db48580cd81c8dac027f3138fedf

Tree-SHA512: 988110d72fd698634111eb68c0204f42457b9b9b3d7b6ca3e11815cc702f6921266ae8f27f27aa31c3672efdb99478870fc4d1e8f5fa63aceae6f81521b31d8b
2026-01-22 12:01:36 +01:00
Fabian Jahr
e1dc4afeeb
test: Rename wallet name in restore attempt in wallet_assumeutxo
This prevents potential intermittend failures on windows when the wallet by the same name from the previous test case hasn't been cleaned up yet by it's process.
2026-01-22 00:24:43 +01:00
Lőrinc
8b9d30e3fa
bench/test: clarify merkle bench and witness test intent
Follow-up to bitcoin/bitcoin#32497.

Clarify why the witness merkle test uses an odd leaf count (it exercises leaf duplication in `ComputeMerkleRoot()`), and make the coinbase witness hash initialization explicit.

Also simplify the leaf-copy loop in the MerkleRoot benchmark for readability.

No production code is changed in this follow-up, for simplicity and safety.

Co-authored-by: w0xlt <94266259+w0xlt@users.noreply.github.com>
2026-01-21 23:29:46 +01:00
merge-script
5715748333
Merge bitcoin/bitcoin#34366: test: switch order of error code and message check
0aba464ce76522f1be3bb9e471b45438738de492 test: switch order of error code and message check (rkrux)

Pull request description:

  I feel it'd be easier to debug intermittent test failures if the error message is present in the logs instead of error code. So, switching order of error code and message in the `try_rpc` function to aid error debugging.

  Should help in debugging #34354 IMO. It's an intermittent failure on Windows that I can't reproduce and it's more difficult to figure out what could have gone wrong only by seeing the error code like below in the CI logs. Given that the functional tests pass, I don't see a harm in checking for error message first and throwing it in case of a mismatch.

  ```python
  AssertionError: Unexpected JSONRPC error code -1
  ```

  <!--
  *** Please remove the following help text before submitting: ***

  Pull requests without a rationale and clear improvement may be closed
  immediately.

  GUI-related pull requests should be opened against
  https://github.com/bitcoin-core/gui
  first. See CONTRIBUTING.md
  -->

  <!--
  Please provide clear motivation for your patch and explain how it improves
  Bitcoin Core user experience or Bitcoin Core developer experience
  significantly:

  * Any test improvements or new tests that improve coverage are always welcome.
  * All other changes should have accompanying unit tests (see `src/test/`) or
    functional tests (see `test/`). Contributors should note which tests cover
    modified code. If no tests exist for a region of modified code, new tests
    should accompany the change.
  * Bug fixes are most welcome when they come with steps to reproduce or an
    explanation of the potential issue as well as reasoning for the way the bug
    was fixed.
  * Features are welcome, but might be rejected due to design or scope issues.
    If a feature is based on a lot of dependencies, contributors should first
    consider building the system outside of Bitcoin Core, if possible.
  * Refactoring changes are only accepted if they are required for a feature or
    bug fix or otherwise improve developer experience significantly. For example,
    most "code style" refactoring changes require a thorough explanation why they
    are useful, what downsides they have and why they *significantly* improve
    developer experience or avoid serious programming bugs. Note that code style
    is often a subjective matter. Unless they are explicitly mentioned to be
    preferred in the [developer notes](/doc/developer-notes.md), stylistic code
    changes are usually rejected.
  -->

  <!--
  Bitcoin Core has a thorough review process and even the most trivial change
  needs to pass a lot of eyes and requires non-zero or even substantial time
  effort to review. There is a huge lack of active reviewers on the project, so
  patches often sit for a long time.
  -->

ACKs for top commit:
  maflcko:
    lgtm ACK 0aba464ce76522f1be3bb9e471b45438738de492
  polespinasa:
    lgtm ACK 0aba464ce76522f1be3bb9e471b45438738de492
  fjahr:
    utACK 0aba464ce76522f1be3bb9e471b45438738de492
  brunoerg:
    code review ACK 0aba464ce76522f1be3bb9e471b45438738de492
  sedited:
    ACK 0aba464ce76522f1be3bb9e471b45438738de492

Tree-SHA512: b09ba4b5d13a2c93a4a28a5c1b06af44a91295974236bb8326b74a988878c431e9ce0e19ec14bb98ac2b002da877abaa7da6a9851424453bcb494c0317b57227
2026-01-21 23:09:30 +01:00
merge-script
2a1234001c
Merge bitcoin/bitcoin#34269: wallet: disallow creating new or restoring to an unnamed (default) wallet
75b704df9d5ccb262d19ffe95b7ca6d1a934f3fb wallettool: Disallow creating new unnamed wallets (Ava Chow)
5875a9c502632eb5c74df07e41af38582da6e884 wallet: disallow unnamed wallets in createwallet and restorewallet (Ava Chow)
d30ad4a9129da04e249e3938f643dc47bf060e7e wallet, rpc: Use HandleWalletError in createwallet (Ava Chow)

Pull request description:

  We've been moving in the direction that all wallets must have a name. Therefore, we shouldn't allow creating new unnamed wallets. `createwallet`, `restorewallet`, and the wallet tool's `create` and `createfromdump` all now require the user to provide a non-empty wallet name when creating/restoring a wallet.

  The GUI is already enforcing this, but we were not enforcing it for RPCs or in the underlying `CreateWallet` and `RestoreWallet` functions.

  Wallet migration does still need to be able to restore unnamed wallets, so there is a new argument to `RestoreWallet` to explicitly allow that behavior for migration only.

ACKs for top commit:
  rkrux:
    lgtm ACK 75b704df9d5ccb262d19ffe95b7ca6d1a934f3fb
  polespinasa:
    re ACK 75b704df9d5ccb262d19ffe95b7ca6d1a934f3fb

Tree-SHA512: 8bde76d0b091e9276788c69412934af3426da2a7a69a00f94072d36c1a075cd41744ecdd5fef2b72870c1351b76aae061f124f716bb23f4839be20c464fc5ebd
2026-01-21 22:56:59 +01:00
Hennadii Stepanov
3ea2b6fe18
Merge bitcoin/bitcoin#34369: test: Scale NetworkThread close timeout with timeout_factor
fab055c907f1ab9ecac49e3d72909289a3b08c2d test: Scale NetworkThread close timeout with timeout_factor (MarcoFalke)

Pull request description:

  Not sure if this fixes https://github.com/bitcoin/bitcoin/issues/34248, but scaling here probably makes sense, considering some CI setups run in nested VMs with a different arch system-qemu.

ACKs for top commit:
  hebasto:
    ACK fab055c907f1ab9ecac49e3d72909289a3b08c2d, the diff looks reasonable.

Tree-SHA512: 98f9b0bdc3b02b692a14129f88c05f2df0d1e11e4167ff5d0cc6a3a6efd8994a743e969e83c71cb534537f134e07ba9a5cba3eb2010a6b6cf69bec959faf2c43
2026-01-21 16:41:52 +00:00
MarcoFalke
fab055c907
test: Scale NetworkThread close timeout with timeout_factor 2026-01-21 16:18:07 +01:00
merge-script
e324925d19
Merge bitcoin/bitcoin#34363: Update libmultiprocess subtree to avoid occasional rpc_misc.py timeout
7562e2aeed95b0dc627e8e3a849941992f0189bb Squashed 'src/ipc/libmultiprocess/' changes from a4f92969649..1fc65008f7d (Ryan Ofsky)

Pull request description:

  Includes:

  - https://github.com/bitcoin-core/libmultiprocess/pull/229
  - https://github.com/bitcoin-core/libmultiprocess/pull/223
  - https://github.com/bitcoin-core/libmultiprocess/pull/225
  - https://github.com/bitcoin-core/libmultiprocess/pull/228
  - https://github.com/bitcoin-core/libmultiprocess/pull/230
  - https://github.com/bitcoin-core/libmultiprocess/pull/236
  - https://github.com/bitcoin-core/libmultiprocess/pull/234
  - https://github.com/bitcoin-core/libmultiprocess/pull/196
  - https://github.com/bitcoin-core/libmultiprocess/pull/237

  The last change https://github.com/bitcoin-core/libmultiprocess/pull/237 is expected to fix issue #34187 occasional `rpc_misc.py` test hang. The other changes are just documentation & ci updates.

  The changes can be verified by running `test/lint/git-subtree-check.sh src/ipc/libmultiprocess` as described in [developer notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#subtrees) and [lint instructions](https://github.com/bitcoin/bitcoin/tree/master/test/lint#git-subtree-checksh)

ACKs for top commit:
  sedited:
    ACK 73d0fe62d3db175cfd233d8be47b09d8626cdab2

Tree-SHA512: 82fb2973b8fb5e792dcff1adde0b158ac67cc6a9aeef4465e0bbdfbef88e41d44d9bad53b1d467be47bf594befa02bd8e7829c0a0bc67aaaeb4ca1e09b672a32
2026-01-21 15:07:23 +00:00
merge-script
fa267551c4
Merge bitcoin/bitcoin#34353: refactor: Use std::bind_front over std::bind
faa18dceba1dd69703a252f751c233d227164689 refactor: Use std::bind_front over std::bind (MarcoFalke)

Pull request description:

  `std::bind` has many issues:

  * It is verbosely listing all placeholders, but in a meaningless way, because it doesn't name the args or their types.
  * It silently ignores args passed to it, when one arg is overridden. For example [1] compiles fine on current master.
  * Accidentally duplicated placeholders compile fine as well.
  * Usually the placeholders aren't even needed.
  * This makes it hard to review, understand, and maintain.

  Fix all issues by using `std::bind_front` from C++20, which allows to drop the brittle `_1, _2, ...` placeholders. The replacement should be correct, if the trailing placeholders are ordered.

  Introducing the same silent bug on top of this pull request [2] will now lead to a compile failure.

  ----

  [1]

  ```diff
  diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
  index 694fb535b5..7661dd361e 100644
  --- a/src/qt/walletmodel.cpp
  +++ b/src/qt/walletmodel.cpp
  @@ -412,3 +412,3 @@ void WalletModel::subscribeToCoreSignals()
       m_handler_status_changed = m_wallet->handleStatusChanged(std::bind(&NotifyKeyStoreStatusChanged, this));
  -    m_handler_address_book_changed = m_wallet->handleAddressBookChanged(std::bind(NotifyAddressBookChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
  +    m_handler_address_book_changed = m_wallet->handleAddressBookChanged(std::bind(NotifyAddressBookChanged, this, CTxDestination{}, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
       m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2));
  ```

  [2]

  ```diff
  diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
  index 578713c0ab..84cced741c 100644
  --- a/src/qt/walletmodel.cpp
  +++ b/src/qt/walletmodel.cpp
  @@ -412,3 +412,3 @@ void WalletModel::subscribeToCoreSignals()
       m_handler_status_changed = m_wallet->handleStatusChanged(std::bind_front(&NotifyKeyStoreStatusChanged, this));
  -    m_handler_address_book_changed = m_wallet->handleAddressBookChanged(std::bind_front(NotifyAddressBookChanged, this));
  +    m_handler_address_book_changed = m_wallet->handleAddressBookChanged(std::bind_front(NotifyAddressBookChanged, this, CTxDestination{}));
       m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind_front(NotifyTransactionChanged, this));

ACKs for top commit:
  janb84:
    cr ACK faa18dceba1dd69703a252f751c233d227164689
  fjahr:
    Code review ACK faa18dceba1dd69703a252f751c233d227164689
  hebasto:
    ACK faa18dceba1dd69703a252f751c233d227164689, I have reviewed the code and it looks OK.

Tree-SHA512: 9dd13f49527e143a2beafbaae80b1358981f07a2ce20d25cffb1853089a32ff71639e6d718d1d193754522f9ac04e3e168ba017d5fc67a11a5918e79a92b3461
2026-01-21 14:59:31 +00:00
yuvicc
b851ff6cae
kernel: Add Handle/View pattern for BlockValidationState
Add C API functions for managing BlockValidationState lifecycle:
  - btck_block_validation_state_create()
  - btck_block_validation_state_copy()
  - btck_block_validation_state_destroy()

Introduce BlockValidationStateApi<> template to share common getter methods between BlockValidationState (Handle) and BlockValidationStateView (View) classes in the C++ wrapper. This enables external code to create and own BlockValidationState objects needed for the new process_block_header() API.

Co-authored-by: TheCharlatan <seb.kung@gmail.com>
2026-01-21 19:40:25 +05:30
MarcoFalke
fa61fadad1
doc: Fix wrong code in WITH_LOCK doxygen comment 2026-01-21 14:51:12 +01:00
merge-script
52096de212
Merge bitcoin/bitcoin#34032: util: Add some more Unexpected and Expected methods
faa59b367985648df901bdd7b5bba69ef898ea08 util: Add Expected::swap() (MarcoFalke)
fabb47e4e3dba7c03f9242440cb55eb37b493a7a util: Implement Expected::operator*()&& (MarcoFalke)
fab9721430aa83ddb266aca029e270aec81c021d util: Implement Expected::value()&& and Expected::error()&& (MarcoFalke)
fac48009598611d28b6583559af513c337166aeb util: Add Expected<void, E> specialization (MarcoFalke)
fa6575d6c2d27d173162888226df669fb8aeea47 util: Make Expected::value() throw (MarcoFalke)
fa1de1103fe5d97ddddc9e45286e32751151f859 util: Add Unexpected::error() (MarcoFalke)
faa109f8be7fca125c55ca84e6c0baf414c59ae6 test: refactor: Use BOOST_CHECK_EQUAL over BOOST_CHECK == (MarcoFalke)
fad4a9fe2b8d3a3aa09eca4f47e1741912328785 Set bugprone-unused-return-value.AllowCastToVoid (MarcoFalke)

Pull request description:

  Reviewers requested more member functions In https://github.com/bitcoin/bitcoin/pull/34006.

  They are currently unused, but bring the port closer to the original `std::expected` implementation:

  * Make `Expected::value()` throw when no value exists
  * Add `Unexpected::error()` methods
  * Add `Expected<void, E>` specialization
  * Add `Expected::value()&&` and `Expected::error()&&` methods
  * Add `Expected::swap()`

  Also, include a tiny tidy fixup:

  * tidy: Set `AllowCastToVoid` in the `bugprone-unused-return-value` check

ACKs for top commit:
  stickies-v:
    re-ACK faa59b367985648df901bdd7b5bba69ef898ea08
  ryanofsky:
    Code review ACK faa59b367985648df901bdd7b5bba69ef898ea08. Thanks for the update. The commit I objected to is fixed now and the rest of the implementation seems good enough for code that's probably temporary.
  hodlinator:
    re-ACK faa59b367985648df901bdd7b5bba69ef898ea08

Tree-SHA512: b6ac28c1e7241837d9db83fe7534d713ca1283c20a77d2273743157d329f041ec0b503658d14b2f4425211808b61a88fed115d77149e0546825acd3bd9198edf
2026-01-21 13:23:43 +01:00
rkrux
0aba464ce7
test: switch order of error code and message check
I feel it'd be easier to debug intermittent test failures if the
error message is present in the logs instead of error code. So,
switching order of error code and message in the `try_rpc` function
to aid error debugging.
2026-01-21 17:23:30 +05:30
Ava Chow
8c07800b19
Merge bitcoin/bitcoin#32497: merkle: pre‑reserve leaves to prevent reallocs with odd vtx count
3dd815f048c80c9a35f01972e0537eb42531aec7 validation: pre-reserve leaves to prevent reallocs with odd vtx count (Lőrinc)
7fd47e0e56087cd3b5fd76a532bdc3ac331e832e bench: make `MerkleRoot` benchmark more representative (Lőrinc)
f0a21831087410687c4ca31ac00e44f380b859be test: adjust `ComputeMerkleRoot` tests (Lőrinc)

Pull request description:

  #### Summary

  `ComputeMerkleRoot` [duplicates the last hash](39b6c139bd/src/consensus/merkle.cpp (L54-L56)) when the input size is odd. If the caller provides a `std::vector` whose capacity equals its size, that extra `push_back` forces a reallocation, doubling its capacity (causing peak memory usage of 3x the necessary size).

  This affects roughly half of the created blocks (those with odd transaction counts), causing unnecessary memory fragmentation during every block validation.

  #### Fix

  * Pre-reserves vector capacity to account for the odd-count duplication using `(size + 1) & ~1ULL`.
      * This syntax produces [optimal assembly](https://github.com/bitcoin/bitcoin/pull/32497#discussion_r2553107836) across x86/ARM and 32/64-bit platforms for GCC & Clang.
  * Eliminates default construction of `uint256` objects that are immediately overwritten by switching from `resize` to `reserve` + `push_back`.

  #### Memory Impact

  [Memory profiling](https://github.com/bitcoin/bitcoin/pull/32497#issuecomment-3563724551) shows **50% reduction in peak allocation** (576KB → 288KB) and elimination of reallocation overhead.

  #### Validation

  The benchmark was updated to use an odd leaf count to demonstrate the real-world scenario where the reallocation occurs.

  A full `-reindex-chainstate` up to block **896 408** ran without triggering the asserts.

  <details>
  <summary>Validation asserts</summary>

  Temporary asserts (not included in this PR) confirm that `push_back` never reallocates and that the coinbase witness hash remains null:
  ```cpp
  if (hashes.size() & 1) {
      assert(hashes.size() < hashes.capacity()); // TODO remove
      hashes.push_back(hashes.back());
  }

  leaves.reserve((block.vtx.size() + 1) & ~1ULL); // capacity rounded up to even
  leaves.emplace_back();
  assert(leaves.back().IsNull()); // TODO remove
  ```

  </details>

  #### Benchmark Performance

  While the main purpose is to improve predictability, the reduced memory operations also improve hashing throughput slightly.

ACKs for top commit:
  achow101:
    ACK 3dd815f048c80c9a35f01972e0537eb42531aec7
  optout21:
    reACK 3dd815f048c80c9a35f01972e0537eb42531aec7
  hodlinator:
    re-ACK 3dd815f048c80c9a35f01972e0537eb42531aec7
  vasild:
    ACK 3dd815f048c80c9a35f01972e0537eb42531aec7
  w0xlt:
    ACK 3dd815f048c80c9a35f01972e0537eb42531aec7 with minor nits.
  danielabrozzoni:
    Code review ACK 3dd815f048

Tree-SHA512: e7b578f9deadc0de7d61c062c7f65c5e1d347548ead4a4bb74b056396ad7df3f1c564327edc219670e6e2b2cb51f4e1ccfd4f58dd414aeadf2008d427065c11f
2026-01-20 15:47:17 -08:00
Ava Chow
a365c9fe1f
Merge bitcoin/bitcoin#33738: log: avoid collecting GetSerializeSize data when compact block logging is disabled
969c840db52da796c319f84c9a9a20b1de902ccf log,blocks: avoid `ComputeTotalSize` and `GetHash` work when logging is disabled (Lőrinc)
babfda332b6aa41143eb694193358ef2c76ebefe log,net: avoid `ComputeTotalSize` when logging is disabled (Lőrinc)
1658b8f82b99f9ba3b42a50ba1f72b19a38c8e75 refactor: rename `CTransaction::GetTotalSize` to signal that it's not cached (Lőrinc)

Pull request description:

  ### Context

  The new accounting options introduced in https://github.com/bitcoin/bitcoin/pull/32582 can be quite heavy, and are not needed when debug logging is disabled.

  ### Problem
  `PartiallyDownloadedBlock::FillBlock()` and `PeerManagerImpl::SendBlockTransactions()` accumulate transaction sizes for debug logging by calling `ComputeTotalSize()` in loops, which invokes expensive `GetSerializeSize()` serializations.
  The block header hash is also only computed for the debug log.

  ### Fixes

  Guard the size and hash calculations with `LogAcceptCategory()` checks so the serialization and hashing work only occurs when compact block debug logging is enabled.

  Also modernized the surrounding code a bit since the change is quite trivial.

  ### Reproducer

  You can test the change by starting an up-to-date `bitcoind` node with `-debug=cmpctblock` and observing compact block log lines such as:

  > [cmpctblock] Successfully reconstructed block 00000000000000000001061eaa6c0fe79258e7f79606e67ac495765cb121a520 with 1 txn prefilled, 3122 txn from mempool (incl at least 3 from extra pool) and 641 txn (352126 bytes) requested

  <details>
  <summary>Test patch</summary>

  ```patch
  diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp
  index 58620c93cc..f16eb38fa5 100644
  --- a/src/blockencodings.cpp
  +++ b/src/blockencodings.cpp
  @@ -186,6 +186,7 @@ bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const

   ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing, bool segwit_active)
   {
  +    LogInfo("PartiallyDownloadedBlock::FillBlock called");
       if (header.IsNull()) return READ_STATUS_INVALID;

       block = header;
  @@ -218,6 +219,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
       }

       if (LogAcceptCategory(BCLog::CMPCTBLOCK, BCLog::Level::Debug)) {
  +        LogInfo("debug log enabled");
           const uint256 hash{block.GetHash()}; // avoid cleared header
           uint32_t tx_missing_size{0};
           for (const auto& tx : vtx_missing) tx_missing_size += tx->ComputeTotalSize(); // avoid cleared txn_available
  diff --git a/src/net_processing.cpp b/src/net_processing.cpp
  index 5600c8d389..c081825f77 100644
  --- a/src/net_processing.cpp
  +++ b/src/net_processing.cpp
  @@ -2470,6 +2470,7 @@ uint32_t PeerManagerImpl::GetFetchFlags(const Peer& peer) const

   void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, Peer& peer, const CBlock& block, const BlockTransactionsRequest& req)
   {
  +    LogInfo("PeerManagerImpl::SendBlockTransactions called");
       BlockTransactions resp(req);
       for (size_t i = 0; i < req.indexes.size(); i++) {
           if (req.indexes[i] >= block.vtx.size()) {
  @@ -2480,6 +2481,7 @@ void PeerManagerImpl::SendBlockTransactions(CNode& pfrom, Peer& peer, const CBlo
       }

       if (LogAcceptCategory(BCLog::CMPCTBLOCK, BCLog::Level::Debug)) {
  +        LogInfo("debug log enabled");
           uint32_t tx_requested_size{0};
           for (const auto i : req.indexes) tx_requested_size += block.vtx[i]->ComputeTotalSize();
           LogDebug(BCLog::CMPCTBLOCK, "Peer %d sent us a GETBLOCKTXN for block %s, sending a BLOCKTXN with %u txns. (%u bytes)\n", pfrom.GetId(), block.GetHash().ToString(), resp.txn.size(), tx_requested_size);
  ```

  </details>

ACKs for top commit:
  davidgumberg:
    reACK 969c840db5
  achow101:
    ACK 969c840db52da796c319f84c9a9a20b1de902ccf
  hodlinator:
    re-ACK 969c840db52da796c319f84c9a9a20b1de902ccf
  sedited:
    Re-ACK 969c840db52da796c319f84c9a9a20b1de902ccf
  danielabrozzoni:
    reACK 969c840db52da796c319f84c9a9a20b1de902ccf

Tree-SHA512: 9780102d29778165144e3602d934ed4cb96660fd7b9ff2581b223c619e419139b8348e60f226af448702ae527736a1806d169b44342c5a82795590f664e16efe
2026-01-20 15:41:30 -08:00
Ava Chow
bc3c4cd8b2
Merge bitcoin/bitcoin#32724: Musig2 tests
a3c71c720158fd024d072ad32e78a3b353de0723 [test] Add BIP 328 test vectors for Musig2 (w0xlt)

Pull request description:

  Built on https://github.com/bitcoin/bitcoin/pull/31244

  This PR adds explicit tests for Bitcoin Core's MuSig2 interface.

  Any issues in musig2.{cpp,h} will likely also be caught by the descriptor tests, but having more detailed tests for the MuSig2 class itself improves test reporting/coverage.

  It uses BIP 328 test vectors.

ACKs for top commit:
  achow101:
    ACK a3c71c720158fd024d072ad32e78a3b353de0723
  rkrux:
    lgtm ACK a3c71c7

Tree-SHA512: fc13beb5445c292cd7c75a47810fb1c4032ee2e3c1800dc44089b95959ccce8330291084bf788457e1d55c02d706ef04be7044badfee134149e004c44b19ec32
2026-01-20 15:23:54 -08:00
Ava Chow
f7e88e298a
Merge bitcoin/bitcoin#32471: wallet/rpc: fix listdescriptors RPC fails to return descriptors with private key information when wallet contains descriptors missing any key
9c7e4771b13d4729fd20ea08b7e2e3209b134fff test: Test listdescs with priv works even with missing priv keys (Novo)
ed945a685473712c1a822379effa42fd49223515 walletrpc: reject listdes with priv key on w-only wallets (Novo)
9e5e9824f11b1b0f9e2a4e28124edbb1616af519 descriptor: ToPrivateString() pass if  at least 1 priv key exists (Novo)
5c4db25b61d417a567f152169f4ab21a491afb95 descriptor: refactor ToPrivateString for providers (Novo)
2dc74e3f4e5e6f01c8810359b91041bc6865f1c7 wallet/migration: use HavePrivateKeys in place of ToPrivateString (Novo)
e842eb90bb6db39076a43b010c0c7898d50b8d92 descriptors: add HavePrivateKeys() (Novo)

Pull request description:

  _TLDR:
  Currently, `listdescriptors [private=true]` will fail for a non-watch-only wallet if any descriptor has a missing private key(e.g `tr()`, `multi()`, etc.). This PR changes that while making sure `listdescriptors [private=true]` still fails if there no private keys. Closes #32078_

  In non-watch-only wallets, it's possible to import descriptors as long as at least one private key is included. It's important that users can still view these descriptors when they need to create a backup—even if some private keys are missing ([#32078 (comment)](https://github.com/bitcoin/bitcoin/issues/32078#issuecomment-2781428475)). This change makes it possible to do so.

  This change also helps prevent `listdescriptors true` from failing completely, because one descriptor is missing some private keys.

  ### Notes
  - The new behaviour is applied to all descriptors including miniscript descriptors
  - `listdescriptors true` still fails for watch-only wallets to preserve existing behaviour https://github.com/bitcoin/bitcoin/pull/24361#discussion_r920801352
  - Wallet migration logic previously used `Descriptor::ToPrivateString()` to determine which descriptor was watchonly. This means that modifying the `ToPrivateString()` behaviour caused descriptors that were previously recognized as "watchonly" to be "non-watchonly". **In order to keep the scope of this PR limited to the RPC behaviour, this PR uses a different method to determine `watchonly` descriptors for the purpose of wallet migration.** A follow-up PR can be opened to update migration logic to exclude descriptors with some private keys from the `watchonly` migration wallet.

  ### Relevant PRs
  https://github.com/bitcoin/bitcoin/pull/24361
  https://github.com/bitcoin/bitcoin/pull/32186

  ### Testing
  Functional tests were added to test the new behaviour

  EDIT
  **`listdescriptors [private=true]` will still fail when there are no private keys because non-watchonly wallets must have private keys and calling `listdescriptors [private=true]` for watchonly wallet returns an error**

ACKs for top commit:
  Sjors:
    ACK 9c7e4771b13d4729fd20ea08b7e2e3209b134fff
  achow101:
    ACK 9c7e4771b13d4729fd20ea08b7e2e3209b134fff
  w0xlt:
    reACK 9c7e4771b1 with minor nits
  rkrux:
    re-ACK 9c7e4771b13d4729fd20ea08b7e2e3209b134fff

Tree-SHA512: f9b3b2c3e5425a26e158882e39e82e15b7cb13ffbfb6a5fa2868c79526e9b178fcc3cd88d3e2e286f64819d041f687353780bbcf5a355c63a136fb8179698b60
2026-01-20 12:17:19 -08:00
merge-script
7f5ebef56a
Merge bitcoin/bitcoin#34302: fuzz: Restore SendMessages coverage in process_message(s) fuzz targets
fabf8d1c5bdb6a944762792cdc762caa6c1a760b fuzz: Restore SendMessages coverage in process_message(s) fuzz targets (MarcoFalke)
fac7fed397f0fa3924600c1806a46d235a62ee5f refactor: Use std::reference_wrapper<AddrMan> in Connman (MarcoFalke)

Pull request description:

  *Found and reported by Crypt-iQ (thanks!)*

  Currently the process_message(s) fuzz targets do not have any meaningful `SendMessages` code coverage. This is not ideal.

  Fix the problem by adding back the coverage, and by hardening the code here, so that the problem hopefully does not happen again in the future.

  ### Historic context for this regression

  The regression was introduced in commit fa11eea4059a608f591db4469c07a341fd33a031, which built a new deterministic peerman object. However, the patch was incomplete, because it was missing one hunk to replace `g_setup->m_node.peerman->SendMessages(&p2p_node);` with `peerman->SendMessages(&p2p_node);`.

  This means the stale and empty peerman from the node context and not the freshly created and deterministic peerman was used.

  A simple fix would be to just submit the missing patch hunk. However, this still leaves the risk that the issue is re-introduced at any time in the future. So instead, I think the stale and empty peerman should be de-constructed, so that any call to it will lead to a hard sanitizer error and fuzz failure.

  Doing that also uncovered another issue: The connman was holding on to a reference to a stale and empty addrman.

  So fix all issues by:

  * Allowing the addrman reference in connman to be re-seatable
  * Clearing all stale objects, before creating new objects, and then using references to the new objects in all code

ACKs for top commit:
  Crypt-iQ:
    crACK fabf8d1c5bdb6a944762792cdc762caa6c1a760b
  frankomosh:
    ACK fabf8d1c5bdb6a944762792cdc762caa6c1a760b
  marcofleon:
    code review ACK fabf8d1c5bdb6a944762792cdc762caa6c1a760b
  sedited:
    ACK fabf8d1c5bdb6a944762792cdc762caa6c1a760b

Tree-SHA512: 2e478102b3e928dc7505f00c08d4b9e4f8368407b100bc88f3eb3b82aa6fea5a45bae736c211f5af1551ca0de1a5ffd4a5d196d9473d4c3b87cfed57c9a0b69d
2026-01-20 16:45:18 +01:00
merge-script
a6e8cd306e
Merge bitcoin/bitcoin#34310: iwyu: Add missed line to IWYU patch
de509c6df97910cc11c5025d5f80fb05b9a88e80 iwyu: Add missed line to IWYU patch (Hennadii Stepanov)

Pull request description:

  This PR makes IWYU suggest `<cassert>` over `<assert.h>`.

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

ACKs for top commit:
  maflcko:
    lgtm ACK de509c6df97910cc11c5025d5f80fb05b9a88e80

Tree-SHA512: edba91eaf36992f684be2920f5da8c13a25ba6d79b879b92193e2af106cd454a64d7c4cf9dabc25675490df9edbccff1fd54c9f393e984a3a7a628b1c65f6c53
2026-01-20 14:57:09 +00:00
merge-script
f4413706f9
Merge bitcoin/bitcoin#34344: ci: update GitHub Actions versions
9482f00df0b05e8ef710a7f0fac3262855ce335f chore: Update outdated GitHub Actions versions (Padraic Slattery)

Pull request description:

  This PR updates outdated GitHub Action versions to ensure compatibility and improve functionality. The following changes are made to the GitHub Actions:
  - `actions/upload-artifact` updated from v4 to v6
  - `actions/cache` updated from v4 to v5
  - `actions/download-artifact` updated from v5 to v7

  The updates are necessary to support newer environments and features, and ensure consistent behavior across different workflows. The changes will be tested in the CI pipeline of the pull request.

ACKs for top commit:
  fanquake:
    ACK 9482f00df0b05e8ef710a7f0fac3262855ce335f

Tree-SHA512: 248e79162c5b2748e1a367d87a360d62eb961c24b4f8060bb932ef99a79ef10cab3e65175c092226c90140f31686fb9424911e6609729cb186b304b598a9af44
2026-01-20 14:49:38 +00:00
MarcoFalke
faa18dceba
refactor: Use std::bind_front over std::bind 2026-01-20 15:30:46 +01:00
merge-script
c84c752506
Merge bitcoin/bitcoin#34319: Drop some IWYU pragma: export and document IWYU usage
d938947b3a89a61784a72c533df623f9eb2fec49 doc: Add "Using IWYU" to Developer Notes (Hennadii Stepanov)
e1a90bcecc823a4abaa2a57f393cad675a2ccbc0 iwyu: Do not export `crypto/hex_base.h` header (Hennadii Stepanov)
19a2edde50c38412712306bf527faad6cbf81c2c iwyu: Do not export C++ headers in most cases (Hennadii Stepanov)

Pull request description:

  First two commits address comments from discussion in https://github.com/bitcoin/bitcoin/pull/33779:
  - https://github.com/bitcoin/bitcoin/pull/33779#discussion_r2697579248
  - https://github.com/bitcoin/bitcoin/pull/33779#discussion_r2697707343

  The last commit adds a new section to the Developer Notes to document IWYU usage.

ACKs for top commit:
  maflcko:
    re-ACK d938947b3a89a61784a72c533df623f9eb2fec49 🚀

Tree-SHA512: 8d6c63e9d2fd190815211d80e654cb7379d16b6611b8851444f49bbbaa0fbc93557675fbcc558afd9a1cdf643570fba5eff9c1aecb5530f978797387b10b9a11
2026-01-20 10:29:09 +00:00
merge-script
38f951f828
Merge bitcoin/bitcoin#34308: doc: Document IWYU workaround
03f363d37884fe68d2f84a3def3fd6fe7bf4a506 doc: Document IWYU workaround (Hennadii Stepanov)

Pull request description:

  This PR addresses the following comments:
  - https://github.com/bitcoin/bitcoin/pull/34079#discussion_r2640003086:
    > it would be good to reduce and report this bug upstream. Otherwise, wide-spread use of iwyu in this code-base seems risky.

  - https://github.com/bitcoin/bitcoin/pull/34079#discussion_r2640035350:
    > Would have been good if it was documented, rather than adding undocumented workarounds for buggy tools.

ACKs for top commit:
  maflcko:
    lgtm ACK 03f363d37884fe68d2f84a3def3fd6fe7bf4a506
  sedited:
    ACK 03f363d37884fe68d2f84a3def3fd6fe7bf4a506

Tree-SHA512: 160a963c07f853995c8b4741a6ccca1d8431a576c760fca082116cebde4d133f7c8ec51f09e8f85f54428f86bad2635e1bd708177eecf71feb0bf1489f1e2b3e
2026-01-20 09:51:42 +00:00
merge-script
ab80588f52
Merge bitcoin/bitcoin#34345: clang-format: use AngleBracket for main includes
0dafc0d83c3e4c48c0ab2efad4b160d1b8c6d252 clang-format: use AngleBracket for main includes (stickies-v)

Pull request description:

  This project uses angle brackets instead of quotes for project-specific headers. Setting [`MainIncludeChar`](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#mainincludechar) enables `clang-format` to automatically detect the main header, so it can be kept as the top group of includes.

  For example, without this change, `clang-format` would demote `<signet.h>` from being the main header in `src/signet.cpp`. With this change, the order is preserved.

  On 5e49f5d63c74512c8f46fe7de7deb0341f13244a:
  ```
  % clang-format src/signet.cpp | head -n 15
  // Copyright (c) 2019-present The Bitcoin Core developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.

  #include <consensus/merkle.h>
  #include <consensus/params.h>
  #include <consensus/validation.h>
  #include <logging.h>
  #include <primitives/block.h>
  #include <primitives/transaction.h>
  #include <script/interpreter.h>
  #include <script/script.h>
  #include <signet.h>
  #include <streams.h>
  #include <uint256.h>

  ```

  With this PR:
  ```
  % clang-format src/signet.cpp | head -n 10
  // Copyright (c) 2019-present The Bitcoin Core developers
  // Distributed under the MIT software license, see the accompanying
  // file COPYING or http://www.opensource.org/licenses/mit-license.php.

  #include <signet.h>

  #include <consensus/merkle.h>
  #include <consensus/params.h>
  #include <consensus/validation.h>
  #include <logging.h>

  ```

  Note: `AngleBracket` `requires clang-format 19`, and will cause older versions (including our current minimum llvm version `17`) to fail

ACKs for top commit:
  maflcko:
    review ACK 0dafc0d83c3e4c48c0ab2efad4b160d1b8c6d252
  sedited:
    Nice, ACK 0dafc0d83c3e4c48c0ab2efad4b160d1b8c6d252
  hebasto:
    ACK 0dafc0d83c3e4c48c0ab2efad4b160d1b8c6d252, tested on Ubuntu 25.10.

Tree-SHA512: c0876f505ec188f76e435af0731c411c66266b83e4c08528d0637263abcd84b3968ee6fbfa72630192f1a0cd2728af873d3d6c32f93ab8b228222fad16f232be
2026-01-20 09:39:24 +00:00
Ava Chow
977be171f2
Merge bitcoin/bitcoin#34188: test: Add multiple transactions and error handling tests for getreceivedbyaddress
d45ec3fba905e8d2b77d61514632ec70e02ad431 test: Add getreceivedbyaddress coverage to wallet_listreceivedby (b-l-u-e)

Pull request description:

  This PR adds comprehensive functional test coverage for the `getreceivedbyaddress` RPC method.

ACKs for top commit:
  maflcko:
    lgtm ACK d45ec3fba905e8d2b77d61514632ec70e02ad431
  fjahr:
    reACK d45ec3fba905e8d2b77d61514632ec70e02ad431
  achow101:
    ACK d45ec3fba905e8d2b77d61514632ec70e02ad431
  rkrux:
    lgtm ACK d45ec3fba905e8d2b77d61514632ec70e02ad431

Tree-SHA512: e7f024297c18b2e11da108d9588bbf96089dce24e2fdee255dbd2f754f21ec63cb3cefa6d92b621b5ab66d18fe29523b87d14ceba38a83afa4c85eb5944a0fb3
2026-01-19 17:04:00 -08:00
Ava Chow
347840164f
Merge bitcoin/bitcoin#32143: Fix 11-year-old mis-categorized error code in OP_IF evaluation
a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43 Fix 11-year-old mis-categorized error code in OP_IF evaluation (Calin Culianu)

Pull request description:

  This was introduced by commit ab9edbd6b6eb3efbca11f16fa467c3c0ef905708.

  It appears the original author may have gotten tired and pasted the wrong error code into this 1 place. Every other situation where the value stack lacks the required number of arguments for the op-code, SCRIPT_ERR_INVALID_STACK_OPERATION is reported. Not so here.

  This commit fixes the situation.

  EDIT: Note this turns out to be a dupe of the abandoned #30359 .

ACKs for top commit:
  billymcbip:
    tACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43
  achow101:
    ACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43
  darosior:
    utACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43
  sedited:
    ACK a7b581423e44c51fb7d177c5a15fe2cc2ab8aa43

Tree-SHA512: e8c01a3e2448b5d49b76a0cab3f38a2d0249b71beeb7d9d05d5ecc3812bd91d0bd1d0f78b809b6f4ccb73186fa119cb1ed3779a73284b83a67ae219ef378fa6c
2026-01-19 16:39:45 -08:00
Lőrinc
969c840db5
log,blocks: avoid ComputeTotalSize and GetHash work when logging is disabled
`PartiallyDownloadedBlock::FillBlock()` computed the block header hash and summed missing transaction sizes for debug logging unconditionally, including when cmpctblock debug logging is disabled.

Guard the debug-only hash and size computations with `LogAcceptCategory`.
Since `txn_available` is invalidated after the first loop (needed for efficient moving), we compute `tx_missing_size` by iterating `vtx_missing` directly. This is safe because the later `tx_missing_offset` check guarantees `vtx_missing` was fully consumed during reconstruction.

Use `block.GetHash()` instead of `header.GetHash()`, since header is cleared before logging.

No behavior change when debug logging is enabled: the reported counts, hashes, and byte totals remain the same.
2026-01-19 20:20:13 +01:00
Lőrinc
babfda332b
log,net: avoid ComputeTotalSize when logging is disabled
`PeerManagerImpl::SendBlockTransactions()` computed the total byte size of requested transactions for a debug log line by calling `ComputeTotalSize()` in a tight loop, triggering serialization even when debug logging is off.

Guard the size accumulation with `LogAcceptCategory` so the serialization work only happens when the log line can be emitted.

No behavior change when debug logging is enabled: the reported block hash, transaction count, and byte totals are the same.
The bounds checks still run unconditionally; the debug-only loop iterates the already-validated response contents.

Separating debug-only work from the critical path reduces risk and favors the performance-critical non-debug case.
This also narrows the racy scope of when logging is toggled from another thread.
2026-01-19 20:20:13 +01:00