Commit Graph

50008 Commits

Author SHA1 Message Date
pablomartin4btc
4ca182ca40 doc: clarify alternate_wtxids is empty when only one witness variant
When there is only one known witness variant for a transaction,
alternate_wtxids is an empty array, analogous to walletconflicts and
mempoolconflicts.

Suggested-by: polespinasa
2026-08-10 23:03:35 -03:00
pablomartin4btc
fa48b5d28e test: assert listsinceblock "removed" reports current canonical wtxid
When a block is detached, listsinceblock "removed" entries reflect the
wallet's current CWalletTx rather than a snapshot of the variant that
was actually in the detached block. Add assertions to make this
behaviour explicit. A future followup could improve listsinceblock to
track and report the specific witness variant that was in the
disconnected block (requires per-block tracking of which witness variant was included).

Co-authored-by: w0xlt <94266259+w0xlt@users.noreply.github.com>
2026-08-10 23:03:35 -03:00
pablomartin4btc
9b96ee1288 wallet, test: add unit test for variant txid validation in CWalletTx deserializer 2026-08-10 23:03:35 -03:00
pablomartin4btc
9de6543cb5 wallet: post-#35501 cleanup in CWalletTx
- Rename arg_state to new_state in Update() declaration to match implementation
- Replace RecomputeCanonical manual loop with std::ranges::min_element
- Add variant txid validation in the deserialize constructor
- Make Init() private and have it clear all members including m_txs

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2026-08-10 23:03:32 -03:00
Ava Chow
b388674acf Merge bitcoin/bitcoin#35872: rpc: avoid descriptor range counter overflow
264555af3c rpc: avoid descriptor range counter overflow (Lőrinc)
143a13fb2b test: characterize descriptor range endpoint (Lőrinc)

Pull request description:

  **Problem:** The authenticated `scantxoutset`, `scanblocks`, `getdescriptoractivity`, `utxoupdatepsbt`, and `descriptorprocesspsbt` RPCs share a descriptor expansion helper that iterates inclusive `int64_t` ranges with an `int` counter.
  A ranged descriptor with an explicit `[begin, end]` range ending at `2^31 - 1` expands that valid position, then overflows when advancing the counter to exit the loop.
  Trap-enabled builds terminate, while other builds invoke undefined behavior.

  **Fix:** Use `int64_t` for loop control so the one-past-the-end value is representable and every position passed to `Descriptor::Expand()` remains within its existing `int` range.

  Related: [#26275](https://github.com/bitcoin/bitcoin/pull/26275) fixed the same endpoint overflow in `deriveaddresses`.

ACKs for top commit:
  achow101:
    ACK 264555af3c
  polespinasa:
    ACK 264555af3c
  sedited:
    ACK 264555af3c

Tree-SHA512: 4326182b5897b6f6672e5f7c7296eafdbb6e3b5ed901d61e8fa2cff9b19d372bb8adb88902368dc520ed400e12dd5264ea68677d9ce0feec76fa2ef55fa0d2f4
2026-08-06 13:07:06 -07:00
merge-script
c36ffd870e Merge bitcoin/bitcoin#35842: rpc: Properly make RPCResult::Type::ANY non-test-only
fac4b06e99 refactor: Use CLIENT_NAME in buildOpenRPCDoc (MarcoFalke)
fa3aadbc32 refactor: Use self.Arg<bool> in getopenrpcinfo (MarcoFalke)
fa1871a528 refactor: Remove stale NOLINTNEXTLINE above GetAddressInfoBaseFields (MarcoFalke)
fa22647914 rpc: Properly make RPCResult::Type::ANY non-test-only (MarcoFalke)
fa1242dcc0 refactor: Use std::visit in ApplyArgFallback (MarcoFalke)

Pull request description:

  Commit 6a1a66c180 attempted to properly render RPC results of the type `ANY`.

  However, the commit is incomplete.

  Fix it, by properly rendering all `ANY` types.

  Moreover, a few trivial refactors after https://github.com/bitcoin/bitcoin/pull/34683 are included here.

ACKs for top commit:
  sedited:
    ACK fac4b06e99
  willcl-ark:
    ACK fac4b06e99

Tree-SHA512: b77f1956e4feb9afb93d38245491eec190c4538aec7ac57c327fb2efd86c7da6ee8a1406f81fc18fac06bae77a7d38845a537ca0b8f4ae2d94c38eefd8e88dc1
2026-08-06 16:14:28 +01:00
merge-script
7cb9aaaee8 Merge bitcoin/bitcoin#35759: fuzz: check http_request body matches framing
7502b9ddba fuzz: check http_request body matches framing (ameen-alam)

Pull request description:

  The http_request target asserted that ReadBody() returns an empty string. That held for the libevent-based http_libevent::HTTPRequest, where the harness only parsed the request line and headers and never populated a body. Commit 9c20859b5f (PR #35182) replaced libevent with http_bitcoin::HTTPRequest, and the target was switched over in e427c227fa; its LoadBody() now decodes Content-Length and chunked bodies per RFC 9112, so any fully-parsed request carrying a body trips the stale assertion (e.g. "POST / HTTP/1.1\r\nContent-Length: 3\r\n\r\nabc").

  Replace the emptiness check with a framing-consistency check that mirrors LoadBody()'s own branch logic: a chunked body is bounded by MAX_BODY_SIZE, a Content-Length body is exactly that many bytes, and a request with neither framing header has no body. This strengthens the target instead of dropping the assertion.

  **Steps to reproduce (old assertion):**
  Build the fuzz binary and pass this input as a file to the `http_request` target:
  `POST / HTTP/1.1\r\nContent-Length: 3\r\n\r\nabc`
  → `test/fuzz/http_request.cpp:49: Assertion 'body.empty()' failed`

  **Testing the fix:**
  Ran the updated target ~16 min under libFuzzer with ASAN/UBSAN
  (14.2M execs, no crashes), plus targeted inputs for each branch:
  Content-Length body, chunked, `Transfer-Encoding: identity` + Content-Length,
  no framing headers, and `Content-Length: 0`. Happy to contribute the repro
  input to qa-assets as a follow-up.

ACKs for top commit:
  pinheadmz:
    ACK 7502b9ddba
  marcofleon:
    tACK 7502b9ddba

Tree-SHA512: 4f2eb6bdb3a4556866a84fe0f1d0d8cf506e2efd1b1c7493a99f67ca452b31a140034d418c4064142b1a66c3a6c34b97df0e2b12c21ea86cd4019ffc7cff3b27
2026-08-06 15:18:54 +01:00
merge-script
5b008514db Merge bitcoin/bitcoin#35878: net_processing: process unique tx INVs only
1278a5970d net_processing: process unique tx INVs only (Gregory Sanders)

Pull request description:

  There is no reason we should process conflicting
  advertisements for transactions, as they cannot be both accepted into our mempool.

  Avoid processing these and doing spurious work.

  Should be no change in observable behavior.

ACKs for top commit:
  ajtowns:
    ACK 1278a5970d
  fjahr:
    ACK 1278a5970d
  l0rinc:
    ACK 1278a5970d

Tree-SHA512: c62ceed2cc634c8c99509a8495e5f9bb6d4d8d050942f709a6539ae4dfe1ec628ce7ab0ec1392656809e0d827d1fecf2e8fb9bb4600d13a5bf9a34c9e9e3ad6e
2026-08-06 14:33:10 +01:00
Hennadii Stepanov
a061b011b7 Merge bitcoin/bitcoin#35912: doc: fix stale bitcoin_en.xlf reference
e98ffd4bd8 doc: fix stale bitcoin_en.xlf reference (cyb3ralbert)

Pull request description:

  `doc/release-process.md` still instructs users to create the Transifex resource from `src/qt/locale/bitcoin_en.xlf`, even though that file no longer exists.

  It was removed in #34808, which switched the Transifex source to the native Qt `.ts` file. That PR updated the other references to `.xlf` in this document, but this one was missed. The last step in the same list already refers to `bitcoin_en.ts`, as does `.tx/config`.

  This patch updates the remaining outdated reference.

  Docs-only change. No tests run.

ACKs for top commit:
  hebasto:
    ACK e98ffd4bd8. This was overlooked in https://github.com/bitcoin/bitcoin/pull/34808.

Tree-SHA512: fc6a295aae8a58e72e3324f52849255fe5c49bc53af71733de44489dd8a5dea86e3dfeaaf01cb47c506e717019a390de97a71505babcb1c98626f5c2fd98274f
2026-08-06 14:11:23 +01:00
merge-script
950b1c0922 Merge bitcoin/bitcoin#34927: test: Check that RPCs do not time out, even under load
fa7bc26d12 test: Check that RPCs do not time out, even under load (MarcoFalke)
fa2bd96cc0 test: Map cli CalledProcessError on server error to JSONRPCException (MarcoFalke)

Pull request description:

  It turns out there is no test currently to check that the RPC server does not time out under load. With "load" I mean a flood of trivial payloads. That is, the only work needed is JSON encoding and decoding of (let's say) a block of data of 2 MB or so. This may take a few milliseconds, but should never take more than a few seconds.

  So add a test for this.

ACKs for top commit:
  enirox001:
    ACK fa7bc26d12
  sedited:
    ACK fa7bc26d12

Tree-SHA512: c60646981b7449c757e9fad499e1cd71030376ffb2ae687c8136c6f70accd0a2d76a4cbfc7dd1bc6626ea3a5310a33616a36cd682cc5c4371ec86aa2c8641aeb
2026-08-06 15:10:28 +02:00
merge-script
bd01e66f0a Merge bitcoin/bitcoin#35885: ci: switch to a sourceware mirror for riscv
81fcecfe45 Revert "ci: Temporarily remove riscv32 config from GHA matrix" (will)
b283e1751c ci: use mirror for riscv submodules (will)

Pull request description:

  The https transport is rate-limited to block AI scrapers.

  Switch to a live mirror on fish.foo to re-enable the riscv job.

ACKs for top commit:
  maflcko:
    lgtm ACK 81fcecfe45
  sedited:
    ACK 81fcecfe45

Tree-SHA512: 1891046d9847b904a3e4be25b7f313fc2413ad1cc0b2c09b2300f81a2f1f691dad816fa5fcfeeae263f8d5f868d229aca5a7ab3f227ce650d359068488bc1e21
2026-08-06 13:50:38 +01:00
will
81fcecfe45 Revert "ci: Temporarily remove riscv32 config from GHA matrix"
This reverts commit fa06ea4244.
2026-08-06 12:56:33 +01:00
will
b283e1751c ci: use mirror for riscv submodules
sourceware is blocking/rate-limiting http(s) git requests to combat AI
scrapers.

Switch to a live mirror hosted at fish.foo

Use exported GIT_CONFIG_* to avoid setting `git config --global` which
could clobber a user running on bare host, but still propagate to child
git processes spawned by `make`.
2026-08-06 12:56:28 +01:00
MarcoFalke
fa7bc26d12 test: Check that RPCs do not time out, even under load
Also, modify send_cli, so that the test can be run under --usecli
2026-08-06 13:36:23 +02:00
MarcoFalke
fa2bd96cc0 test: Map cli CalledProcessError on server error to JSONRPCException
Like authproxy.py, so that tests can work without having to think whether the cli was used or not.
2026-08-06 13:35:48 +02:00
merge-script
4df077d7cd Merge bitcoin/bitcoin#35910: refactor: Remove unused newFeeRate var in ReplacementChecks
fa9a9a82ac refactor: Remove unused newFeeRate var in ReplacementChecks (MarcoFalke)

Pull request description:

  This is unused since cluster-mempool, so it seems confusing to keep around. See the commit that forgot to remove it:

  ```sh
  $ git show 216e693729 -U99999 | grep newFeeRate
       CFeeRate newFeeRate(ws.m_modified_fees, ws.m_vsize);
  -    if (const auto err_string{PaysMoreThanConflicts(ws.m_iters_conflicting, newFeeRate, hash)}) {
  ```

ACKs for top commit:
  sedited:
    ACK fa9a9a82ac

Tree-SHA512: f8804109c59dfe37da754cb1924cc16abbc792fbb3619249a1edbc005f66fd88357c4810926625a375415c5be4ff056d68af3029f8075590252289c1d753a2fd
2026-08-06 13:04:08 +02:00
cyb3ralbert
e98ffd4bd8 doc: fix stale bitcoin_en.xlf reference 2026-08-06 13:18:02 +03:00
MarcoFalke
fa9a9a82ac refactor: Remove unused newFeeRate var in ReplacementChecks
This is unused since cluster-mempool. See the commit that forgot to
remove it:

```sh
$ git show 216e693729 -U99999 | grep newFeeRate
     CFeeRate newFeeRate(ws.m_modified_fees, ws.m_vsize);
-    if (const auto err_string{PaysMoreThanConflicts(ws.m_iters_conflicting, newFeeRate, hash)}) {
```
2026-08-06 11:19:41 +02:00
Gregory Sanders
1278a5970d net_processing: process unique tx INVs only
There is no reason we should process conflicting
advertisements for transactions, as they cannot be both
accepted into our mempool.

Avoid processing these and doing spurious work.
2026-08-05 21:20:22 -04:00
merge-script
c4fbd3c721 Merge bitcoin/bitcoin#35895: refactor: Enable clang-tidy rule to reject anon namespace in header
fa93132d6d refactor: Enable misc-definitions-in-headers (MarcoFalke)
fa5ca877b6 refactor: Enable clang-tidy rule to reject anon namespace in header (MarcoFalke)
fafe5042bd refactor: Use C++20 std::identity over IntIdentity (MarcoFalke)

Pull request description:

  This avoids issues like https://github.com/bitcoin/bitcoin/pull/35737 from passing CI in the first place.

  Also, the rule can help to avoid ODR issues, according to https://clang.llvm.org/extra/clang-tidy/checks/fuchsia/header-anon-namespaces.html

  This follows https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf21-dont-use-an-unnamed-anonymous-namespace-in-a-header

ACKs for top commit:
  sedited:
    ACK fa93132d6d

Tree-SHA512: c1a9d573aed9f295a9fb1931e96e37a9c39e2339392af79d0a3441ebd29282812c2614eab13a01e0d508802f66b73e8f2387ffcbb7dd28676b4fa43f81f9a680
2026-08-05 15:06:19 +01:00
merge-script
465196d015 Merge bitcoin/bitcoin#35630: test: Add importdescriptors rpc error test coverage
3ac8b806a6 test: test the result order of a multiple import request is correct (Pol Espinasa)
e4732bf018 test: test invalid or missing timestamp throws importdescriptors (Pol Espinasa)
07fb58b9ef test: Test a locked wallet rejects an empty importdescriptors request (Pol Espinasa)

Pull request description:

  In addition to #35179 (already merged) this adds more missing test coverage that was detected while rebasing #34861.

  The three tests added checks:
  - Locked wallet throws because of being locked if giving an empty importdescriptors request.
  - Invalid or missing timestamp throws as a top level RPC error and not a per-item error.
  - The order of the requests and the response is the same, even if failing or succeeding.

ACKs for top commit:
  nebula-21:
    ACK 3ac8b806a6
  Bicaru20:
    re-ACK 3ac8b806a6
  brunoerg:
    reACK 3ac8b806a6

Tree-SHA512: b6ba9e16bbdbefcab2529f49f9aab0ae8885bd2d381c6eec36ae442dea1aa2361e6fb339ab5bc2c51c3bef6216d8d939db53e57ec577f05fe54c07fc46f8f255
2026-08-05 14:00:33 +02:00
merge-script
c940fd7514 Merge bitcoin/bitcoin#35180: coins: group private cache helpers
c9cedebfff coins: group private cache helpers (Lőrinc)

Pull request description:

  **Problem:** `CCoinsViewCache::ReallocateCache()` is public even though only `Flush()` uses it.
  The private helper declarations are also split between the start and end of the class.

  **Fix:** Move `ReallocateCache()` and `FetchCoin()` into the existing private section.

ACKs for top commit:
  optout21:
    reACK c9cedebfff
  sedited:
    ACK c9cedebfff

Tree-SHA512: d06062daa9976d767375cd272b3c4ddd838e83fc8b3ac57f6b89a4d8d8837277211786cdd66a794b1a84a39cf6b38f2b9a01699d16e0a648d27b1b93cd0f33b5
2026-08-05 13:30:29 +02:00
merge-script
3db96eb5fd Merge bitcoin/bitcoin#35582: rpc: reject null for optional parameters
aeca061086 rpc: reject null for optional parameters (Ruslan Kasheparov)

Pull request description:

  Treat explicitly passed `null` as missing for optional RPC parameters that are required in certain contexts.

ACKs for top commit:
  achow101:
    ACK aeca061086
  maflcko:
    review ACK aeca061086 🥚
  sedited:
    ACK aeca061086

Tree-SHA512: 60f146085fd20e532ba3cbefdb76d430938168621706a20b2b62a34318499fd72a8c934b08f690f9b72d19ed26581094517a0986586f95bc4b23fa8743b24d11
2026-08-05 12:31:38 +02:00
MarcoFalke
fa93132d6d refactor: Enable misc-definitions-in-headers 2026-08-05 11:51:29 +02:00
MarcoFalke
fa5ca877b6 refactor: Enable clang-tidy rule to reject anon namespace in header
The rule is named misc-anonymous-namespace-in-header in clang-tidy-22,
but use fuchsia-header-anon-namespaces for compat with clang-tidy-21.
2026-08-05 11:22:53 +02:00
MarcoFalke
fafe5042bd refactor: Use C++20 std::identity over IntIdentity 2026-08-05 11:22:34 +02:00
merge-script
28257111ac Merge bitcoin/bitcoin#35737: test: Move cluster_linearize.h contents into cluster_linearize namespace
21b4b790e4 test: Move cluster_linearize.h contents into cluster_linearize namespace (Hennadii Stepanov)

Pull request description:

  Clang recently enabled `-Wunused-template` under `-Wall` (see https://github.com/llvm/llvm-project/pull/206123, https://github.com/llvm/llvm-project/pull/207848, https://github.com/llvm/llvm-project/pull/208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings.

  This PR:
  1. Avoids Clang's `-Wunused-template` warnings in `src/test/util/cluster_linearize.h` when building the `bench_bitcoin` and `fuzz` targets.

  2. Follows the C++ Core Guidelines: "[SF.21: Don't use an unnamed (anonymous) namespace in a header](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#sf21-dont-use-an-unnamed-anonymous-namespace-in-a-header)".

  3. Drops `[[maybe_unused]]` annotations, which are no longer needed after changing the linkage from internal to external.

  Along with https://github.com/bitcoin/bitcoin/pull/35679, this resolves all instances of this warning in the test/bench/fuzz code.

  Another related change: https://github.com/bitcoin-core/minisketch/pull/102.

  ---

  Steps to reproduce on the master branch @ 70d9ec7f3d:
  ```console
  $ CXXFLAGS="-Wunused-template" cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DBUILD_BENCH=ON
  $ cmake --build build -t test_bitcoin
  $ cmake --build build -t bench_bitcoin
  [19/62] Building CXX object src/bench/CMakeFiles/bench_bitcoin.dir/cluster_linearize.cpp.o
  In file included from /home/hebasto/dev/bitcoin/src/bench/cluster_linearize.cpp:9:
  /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:122:17: warning: unused function template 'Ser' [-Wunused-template]
    122 |     static void Ser(Stream& s, const DepGraph<SetType>& depgraph)
        |                 ^~~
  /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:286:6: warning: unused function template 'SanityCheck' [-Wunused-template]
    286 | void SanityCheck(const DepGraph<SetType>& depgraph)
        |      ^~~~~~~~~~~
  /home/hebasto/dev/bitcoin/src/test/util/cluster_linearize.h:383:6: warning: unused function template 'SanityCheck' [-Wunused-template]
    383 | void SanityCheck(const DepGraph<SetType>& depgraph, std::span<const DepGraphIndex> linearization)
        |      ^~~~~~~~~~~
  3 warnings generated.
  [62/62] Linking CXX executable bin/bench_bitcoin
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 21b4b790e4
  sedited:
    ACK 21b4b790e4

Tree-SHA512: 893082c2dc3295b68738c438094656b3568f85b95e0e2f9b0b9dd178d0613e4cb50cd2300a9595e390b9d0a4c650ca78d2772dd1010c178756cefbeef6e2ed94
2026-08-05 11:21:09 +02:00
MarcoFalke
fac4b06e99 refactor: Use CLIENT_NAME in buildOpenRPCDoc
This refactor follow other uses of CLIENT_NAME, such as in RPCMethod stop().
2026-08-05 11:05:03 +02:00
MarcoFalke
fa3aadbc32 refactor: Use self.Arg<bool> in getopenrpcinfo
This is clearer, because it does not encode the default value in the
source code syntax. Also, using named args is clearer than positional
args.

Also, run clang-format on the new code.
2026-08-05 11:04:23 +02:00
MarcoFalke
fa1871a528 refactor: Remove stale NOLINTNEXTLINE above GetAddressInfoBaseFields
There is no recursion.
2026-08-05 11:04:17 +02:00
MarcoFalke
fa22647914 rpc: Properly make RPCResult::Type::ANY non-test-only
This will render all ANY results.

However, the one in the help RPC should still be hidden. This is done by
applying HelpElisionSkip and also skipping over empty result sections in
ToDescriptionString.

Also, run clang-format. Can be reviewed via --ignore-all-space
2026-08-05 11:03:37 +02:00
MarcoFalke
fa1242dcc0 refactor: Use std::visit in ApplyArgFallback
This is more explicit and comes with compile-time checks to ensure all default types are covered.
2026-08-05 11:03:36 +02:00
merge-script
27b6b5a458 Merge bitcoin/bitcoin#35836: rpc: Remove meaningless bool fallback in FundTransaction
ddddffda3a doc: Add doc/release-notes-35836.md (MarcoFalke)
fa7fe798c6 wallet: Remove meaningless bool fallback in FundTransaction (MarcoFalke)

Pull request description:

  This mostly removes a no-op and meaningless bool fallback in the `fundrawtransaction` RPC.

  This allows to remove a `skip_type_check`. This makes validating the JSON schema from https://github.com/bitcoin/bitcoin/pull/34683 more consistent.

  Adding the type check here is useful, because:

  * The fallback was added in af4fe7fd12 (more than a decade ago). Retaining backwards compat with more than 10-year old clients seems purely theoretical. There were other breaking RPC changes on shorter notice in the meantime. If someone really forgot to update this over the last 10 years, I don't see a downside of notifying them.
  * The compat only works for positional args, which seems another small reason to drop it.
  * The compat is now fully irrelevant and a no-op, given that watch-only wallet is not a concept
  anymore after commit 1337c72198.
  * Keeping the compat means that openrpc spec users do not get any type checks at all here.

ACKs for top commit:
  polespinasa:
    ACK ddddffda3a
  sedited:
    ACK ddddffda3a

Tree-SHA512: aa5113bd74159ae5a3bf189edc48d011761db98beaf701cd144ba94eac9f525bec2b8eeb53e588b2f20dc9965ebabef2c5ce55a732b8cef2874a95f398ecae8f
2026-08-05 10:56:00 +02:00
Pol Espinasa
3ac8b806a6 test: test the result order of a multiple import request is correct
Co-Authored-By: Bicaru20 <bicaru2@gmail.com>
2026-08-05 10:25:41 +02:00
Pol Espinasa
e4732bf018 test: test invalid or missing timestamp throws importdescriptors
Also adds global_error to test_importdesc to make it able to test per-item errors or global RPC errors
2026-08-05 10:25:05 +02:00
merge-script
324c231efe Merge bitcoin/bitcoin#35881: iwyu: Fix warnings in src/consensus and treat them as errors
13b53f8bf6 iwyu: Fix warnings in `src/consensus` and treat them as errors (Hennadii Stepanov)

Pull request description:

  This PR continues the ongoing effort to enforce IWYU warnings.

  See [Developer Notes](https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#using-iwyu).

ACKs for top commit:
  maflcko:
    review ACK 13b53f8bf6 🖐
  sedited:
    ACK 13b53f8bf6

Tree-SHA512: c5ec24aec2b618abe9b2046b8ffafa4f3eb61edf8fc9c73a2b6f4e6858797ec214d9cd28c546fbfae1a8f3324d7d6f1c9b6afd4050a1e7fd6075217f7abdfd32
2026-08-05 10:17:47 +02:00
merge-script
75183f4464 Merge bitcoin/bitcoin#35880: fuzz: don't connman.ReceiveMsgFrom oversized msg
bb19f1da19 fuzz: don't connman.ReceiveMsgFrom oversized msg (Greg Sanders)

Pull request description:

  Got a report that tripped it. As this will never happen in p2p, avoid it.

  ```
  INFO: Running with entropic power schedule (0xFF, 100).
  INFO: Seed: 4207564465
  INFO: Loaded 1 modules   (531453 inline 8-bit counters): 531453 [0x5ae1af7ab4c0, 0x5ae1af82d0bd),
  INFO: Loaded 1 PC tables (531453 PCs): 531453 [0x5ae1af82d0c0,0x5ae1b0049090),
  /mnt/scratch0/clusterfuzz/bot/builds/clusterfuzz-builds_bitcoin-core_fcaf00df4dbc83b967efedfb94c0da52db5f507f/revisions/p2p_private_broadcast: Running 1 inputs 100 time(s) each.
  Running: /mnt/scratch0/clusterfuzz/bot/inputs/fuzzer-testcases/crash-7374a74f5b473b761282ebac8029bef22b32b1cd
  p2p_private_broadcast: test/util/net.cpp:93: void ConnmanTestMsg::NodeReceiveMsgBytes(CNode &, std::span<const uint8_t>, bool &) const: Assertion `node.ReceiveMsgBytes(msg_bytes, complete)' failed.
  ==251== ERROR: libFuzzer: deadly signal
      #0 0x5ae1adc5adf4 in __sanitizer_print_stack_trace /src/llvm-project/compiler-rt/lib/ubsan/ubsan_diag_standalone.cpp:31:3
      #1 0x5ae1adbceff8 in fuzzer::PrintStackTrace() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerUtil.cpp:210:5
      #2 0x5ae1adbb1b45 in fuzzer::Fuzzer::CrashCallback() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:231:3
      #3 0x7e8bc7ef741f in libpthread.so.0
      #4 0x7e8bc7ceb00a in __libc_signal_restore_set /build/glibc-B3wQXB/glibc-2.31/sysdeps/unix/sysv/linux/internal-signals.h:86:3
      #5 0x7e8bc7ceb00a in raise /build/glibc-B3wQXB/glibc-2.31/sysdeps/unix/sysv/linux/raise.c:48:3
      #6 0x7e8bc7cca858 in abort /build/glibc-B3wQXB/glibc-2.31/stdlib/abort.c:79:7
      #7 0x7e8bc7cca728 in __assert_fail_base /build/glibc-B3wQXB/glibc-2.31/assert/assert.c:94:3
      #8 0x7e8bc7cdbfd5 in __assert_fail /build/glibc-B3wQXB/glibc-2.31/assert/assert.c:103:3
      #9 0x5ae1ae9bd015 in NodeReceiveMsgBytes bitcoin-core/src/test/util/net.cpp:93:5
      #10 0x5ae1ae9bd015 in ConnmanTestMsg::ReceiveMsgFrom(CNode&, CSerializedNetMsg&&) const bitcoin-core/src/test/util/net.cpp:119:9
      #11 0x5ae1adfff8f7 in p2p_private_broadcast_fuzz_target(std::__1::span<unsigned char const, 18446744073709551615ul>) bitcoin-core/src/test/fuzz/p2p_private_broadcast.cpp:235:27
      #12 0x5ae1ae263e23 in operator() /usr/local/include/c++/v1/__functional/function.h:274:12
      #13 0x5ae1ae263e23 in operator() /usr/local/include/c++/v1/__functional/function.h:772:10
      #14 0x5ae1ae263e23 in test_one_input bitcoin-core/src/test/fuzz/fuzz.cpp:86:5
      #15 0x5ae1ae263e23 in LLVMFuzzerTestOneInput bitcoin-core/src/test/fuzz/fuzz.cpp:214:5
      #16 0x5ae1adbb322d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:619:13
      #17 0x5ae1adb9cf42 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:329:6
      #18 0x5ae1adba2e10 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:865:9
      #19 0x5ae1adbcf9a2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
      #20 0x7e8bc7ccc082 in __libc_start_main /build/glibc-B3wQXB/glibc-2.31/csu/libc-start.c:308:16
      #21 0x5ae1adb9602d in _start
  ```

ACKs for top commit:
  maflcko:
    review ACK bb19f1da19 🔱
  sedited:
    ACK bb19f1da19
  w0xlt:
    ACK bb19f1da19

Tree-SHA512: 8ea61fa04ec02ffd42a1bbd6e8089a4753c43f0c790054cd3f8d7939f1e09972c3d2d0d0f5839055a4d66b632b77de1b5259ea994fdd0298fcd1eaef7518b1e9
2026-08-05 08:54:01 +01:00
merge-script
d3cfd02bd7 Merge bitcoin/bitcoin#35501: wallet: store all witness variants of a transaction
fa5cbb8909 uint256: Workaround GCC-14 stringop-overread bug in Compare (Ava Chow)
6c9d76d589 doc: release note for alternate_wtxids in gettransaction (Ava Chow)
99bdcb064c test: compat, ensure downgrade preserves tx witness variants (furszy)
ef2afc6a0a test: Test for wallet txs with alternate wtxids (Ava Chow)
2d55c7a74d wallet: Show alternate wtxids in gettransaction (Ava Chow)
0b1af01bd4 wallet: Replace CWalletTx::SetTx with Update (Ava Chow)
56cf27db4d wallet: Store all witness variants of a transaction (furszy)
798ba6d04f wallet: Make CWalletTx::tx private and use CWalletTx::GetTx to access (Ava Chow)
72ebdd6364 wallet: Remove unused CWalletTx CopyFrom and copy constructor (Ava Chow)
19af439bdf wallet: Deserialize directly in CWalletTx's ctor (Ava Chow)

Pull request description:

  When the wallet is presented with a transaction that has the same txid as one already known to the wallet, but has a different witness, instead of ignoring the transaction, store it alongside the known tx. This enables the wallet to be aware of all wtxid variants of its transactions. This also allows for the wallet to be able to calculate fees for replacements better as txs with different witnesses may have different feerates.

  Specifically, the wallet stores these alternates in `CWalletTx` and extends the existing `tx` record type to essentially have a vector of transactions appended to the record. In `CWalletTx`, the single transaction is replaced with a map of wtxid to transaction so that all witness variants can still be represented by a single `CWalletTx`. For all of the various things that need the tx from a `CWalletTx`, a single witness variant is chosen to be the canonical tx and returned by `GetTx()`. This canonical tx is written into the same place as the previous single tx was written to in the `tx` record so that wallets can be loaded into previous versions.

  To choose the canonical transaction, if any of the variants is confirmed, then that is the canonical one. Otherwise, the witness variant with the least weight is chosen.

  An additional change I've included is to make `CWalletTx` RAII. This simplifies some of the implementation and enforces the assumption that a `CWalletTx` always has a transaction.

  Lastly, `gettransaction` and `listtransaction` have a new field `alternate_wtxids` to inform users of the wtxids of the witness variants for a transaction, and of course, a test.

  Closes #11240

ACKs for top commit:
  furszy:
    ACK fa5cbb8909
  ajtowns:
    ACK fa5cbb8909
  w0xlt:
    ACK fa5cbb8909

Tree-SHA512: ee303b395ab7a0843969f9491f876f4472c6301e968d9db87312edf44f7447245e707dd544356371d5f32fe6a619ee6937c24f3b7899f7a8108090b425f22d8e
2026-08-04 23:04:06 +02:00
merge-script
0b8ffd01cd Merge bitcoin/bitcoin#35790: fuzz: populate wallet TXO index in wallet_create_transaction
1eac6a728b fuzz: populate wallet TXO index in wallet_create_transaction (frankomosh)

Pull request description:

  A refactor in #27286 seemingly caused a regression in this harness. Rewiring to `m_txos` from `mapWallet` makes the setup loop in `wallet_create_transaction`, which uses raw `mapWallet.emplace()`, to no longer see coins. Therefore, `GetTXO`/`GetTXOs` probably return empty. To make coin selection possible, this fix calls `RefreshTXOsFromTx` after each insertion.

  <details>
  <summary>Coverage diff on select functions</summary>

  `diff spend_cov_before.txt spend_cov_after.txt` on `src/wallet/spend.cpp`:

  ```diff
  -  748|      0|  if (auto bnb_result{SelectCoinsBnB(...)}) {
  +  748|  2.14k|  if (auto bnb_result{SelectCoinsBnB(...)}) {

  -  761|      0|  if (auto knapsack_result{KnapsackSolver(...)}) {
  +  761|  4.46k|  if (auto knapsack_result{KnapsackSolver(...)}) {

  -  766|      0|  if (auto cg_result{CoinGrinder(...)}) {
  +  766|  2.88k|  if (auto cg_result{CoinGrinder(...)}) {

  -  774|      0|  if (auto srd_result{SelectCoinsSRD(...)}) {
  +  774|  4.46k|  if (auto srd_result{SelectCoinsSRD(...)}) {

  -  845|      0|  auto op_selection_result = AutomaticCoinSelection(...);
  +  845|  1.27k|  auto op_selection_result = AutomaticCoinSelection(...);

  -  960|      0|  if (auto res{AttemptSelection(...)}) {
  +  960|  1.36k|  if (auto res{AttemptSelection(...)}) {

  - 1484|      0|  auto txr_grouped = CreateTransactionInternal(...);
  + 1484|    380|  auto txr_grouped = CreateTransactionInternal(...);
  ```

  </details>

ACKs for top commit:
  brunoerg:
    code review ACK 1eac6a728b
  sedited:
    tACK 1eac6a728b

Tree-SHA512: 9680332e7fca634af8c1526efb7f63c188be25dd40d3a3fdc1c2a54d982267fc2a3ddfd7a081225ffbfe51ce0281272998e6616a64d23e4d98a8e9005d19457f
2026-08-04 22:52:29 +02:00
Hennadii Stepanov
2f52c2e8c0 Merge bitcoin/bitcoin#35886: refactor: Remove unused #include in common/system
fa7304f3a5 refactor: Remove unused #include in common/system (MarcoFalke)

Pull request description:

  (See commit msg)

  This should also fix CI issues, such as https://github.com/bitcoin/bitcoin/pull/35885#issuecomment-5184108518

ACKs for top commit:
  hebasto:
    ACK fa7304f3a5.

Tree-SHA512: 726aad3b79224ffc22c7db1bb7247d7a669eff5b43335c0d33c835848c2e6525e68759242d4f7cfd3c42734ce571e453d071064c6ae7b6c1d047538d0495de58
2026-08-04 21:42:53 +01:00
MarcoFalke
fa7304f3a5 refactor: Remove unused #include in common/system
Now that clamping to std::numeric_limits<size_t>::max() is removed, the limits include is no longer needed.

Similarly after changing size_t -> u64, the cstddef include needs to be replaced by cstdint.
2026-08-04 22:22:56 +02:00
merge-script
e7eb159a86 Merge bitcoin/bitcoin#35773: test: Suppress implicit-unsigned-integer-truncation:SaltedCoinsCacheHasher::operator()
fa7f553781 test: Suppress implicit-unsigned-integer-truncation:SaltedCoinsCacheHasher::operator() (MarcoFalke)

Pull request description:

  The truncation of u64 to size_t is intentional here, but it would be nice to document that for ubsan.

  Otherwise, ubsan will print warnings about this. E.g. on 32-bit platforms:

  ```
  /ci_container_base/src/coins.h:255:16: runtime error: implicit conversion from type 'uint64_t' (aka 'unsigned long long') of value 18400304222395891501 (64-bit, unsigned) to type 'size_t' (aka 'unsigned int') changed the value to 2265382701 (32-bit, unsigned)
  ```

  This is a bit tedious to test on 64-bit platforms, but one can use a diff like:

  ```diff
  diff --git a/src/coins.h b/src/coins.h
  index c854893bcb..906be9efae 100644
  --- a/src/coins.h
  +++ b/src/coins.h
  @@ -246,3 +246,3 @@ public:
       /** Hash a transaction ID, itself a cryptographic hash, as one jumbo block. */
  -    size_t operator()(const Txid& id) const noexcept
  +    uint32_t operator()(const Txid& id) const noexcept
       {
  @@ -252,3 +252,3 @@ public:
       /** Hash an outpoint as its txid jumbo block followed by the zero-extended index as one normal block. */
  -    size_t operator()(const COutPoint& id) const noexcept
  +    uint32_t operator()(const COutPoint& id) const noexcept
       {
  ```

  and:

  ```
  $ UBSAN_OPTIONS="suppressions=$(pwd)/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" ./bld-cmake/bin/test_bitcoin

  ./src/coins.h:255:16: runtime error: implicit conversion from type 'uint64_t' (aka 'unsigned long') of value 17092028281225243117 (64-bit, unsigned) to type 'uint32_t' (aka 'unsigned int') changed the value to 291269101 (32-bit, unsigned)

ACKs for top commit:
  l0rinc:
    ACK fa7f553781
  sedited:
    ACK fa7f553781

Tree-SHA512: 0798e09a1291c7e7e2799c586f416b9e92ddf3ad64af3888a01726f338935f735c4e36716a7c38426e75ddbbdc2854949c3f553ab67758a053a2e3ba6a3c3ec1
2026-08-04 22:07:37 +02:00
merge-script
c6ef42d7db Merge bitcoin/bitcoin#35205: kernel,node: add dbcache setter and clarify defaults
6a2de55a0d test: require `TryGetTotalRam()` detection (Lőrinc)
cd086c16dd node, qt: inline `DEFAULT_DB_CACHE` (Lőrinc)
8bd9f46082 kernel: allow setting chainstate `dbcache` (Lőrinc)
8aa21e119b kernel, node: colocate dbcache bounds (Lőrinc)
7cfa21d60a scripted-diff: use `MIN_DBCACHE_BYTES` (Lőrinc)
ab63432576 common: cache total RAM as `uint64_t` (Lőrinc)
031fa402c8 scripted-diff: use `TryGetTotalRam` (Lőrinc)
41c44f5588 node, qt: use `1_MiB` for dbcache conversions (Lőrinc)

Pull request description:

  **Problem:** Since #34692, the node chooses a `450 MiB` or `1 GiB` database cache from detected RAM, while Kernel always uses `450 MiB`.
  The shared names obscure the difference between the node's automatic policy and Kernel's fixed fallback, and Kernel callers cannot set their own cache budget.

  **Fix:** Cache RAM detection as `uint64_t`, keep the node's two-tier default unchanged, and make the fixed Kernel fallback explicit.
  Add a chainstate-manager option setter that accepts a total database cache budget and applies the shared bounds and cache split.

ACKs for top commit:
  maflcko:
    review ACK 6a2de55a0d 🚵
  stringintech:
    re-ACK 6a2de55a
  sedited:
    ACK 6a2de55a0d

Tree-SHA512: 4c92267647a757efb79e8396015de89290eed56c6ff109d9e81495f33ea68ccf90b77cb4b65412cd7825c29b6bf5384ac4ec77fc6c50fbf3e31ee82cf0b552f0
2026-08-04 21:46:08 +02:00
merge-script
17c5e33e9c Merge bitcoin/bitcoin#35216: qa: Improve functional test support on illumos and *BSD
f4a6d079c4 qa: Support `get_bind_addrs` and `feature_bind_extra` on illumos (Hennadii Stepanov)
5e96a8fd5a doc: Add `lsof` to Test Suite Dependencies on NetBSD (Hennadii Stepanov)
5d01aa4772 qa: Ignore `lsof` warnings on NetBSD (Hennadii Stepanov)
70352fda03 qa: Strip prefix length from NetBSD `ifconfig` output (Hennadii Stepanov)
1c1735567e doc: Add `lsof` to Test Suite Dependencies on FreeBSD (Hennadii Stepanov)
4cb7f39c2c qa: Drop OpenBSD from supported platforms in `get_bind_addrs` function (Hennadii Stepanov)
8a982eea85 qa: Add `skip_if_no_lsof_on_nonlinux` helper and use it where needed (Hennadii Stepanov)

Pull request description:

  This PR is a follow-up to #34256. It extends functional test support to illumos-based OSes and fixes several related issues on the *BSDs.

  Changes:
  - Make `lsof` an optional functional test dependency via a new `skip_if_no_lsof` helper, consistent with other optional test deps.
  - Strip the CIDR prefix length from NetBSD `ifconfig` output (no-op on other platforms).
  - Suppress spurious `lsof` warnings on NetBSD.
  - Drop OpenBSD from the platforms supported by `get_bind_addrs`.
  - Document the `lsof` Test Suite Dependency for FreeBSD and NetBSD.
  - Add support for `get_bind_addrs` and `feature_bind_extra` on illumos.

  CI runs: https://github.com/hebasto/bitcoin-core-nightly/pull/280.

  Addresses https://github.com/bitcoin/bitcoin/pull/34256#issuecomment-4361855749.

ACKs for top commit:
  l0rinc:
    Lightly tested code review ACK f4a6d079c4
  sedited:
    utACK f4a6d079c4

Tree-SHA512: 24d943d059f5fa3f5626017eff744836177a41724544355f34b3a31fdf287bd1916bc6e903b598c1c55b61da2ff0f931b4455542d9cff6cf399ef7963096dff4
2026-08-04 17:23:26 +02:00
Hennadii Stepanov
13b53f8bf6 iwyu: Fix warnings in src/consensus and treat them as errors 2026-08-04 15:02:39 +01:00
Greg Sanders
bb19f1da19 fuzz: don't connman.ReceiveMsgFrom oversized msg 2026-08-04 09:32:04 -04:00
merge-script
8a4bab8e97 Merge bitcoin/bitcoin#35863: test: fix wrong transaction in GetP2SHSigOpCount assertion
756afe14b5 test: give each ValidateInputsStandardness case its own scope (JP)
5559fa464b test: fix wrong transaction in GetP2SHSigOpCount assertion (JP)

Pull request description:

  While reading through `script_p2sh_tests.cpp` I noticed one of the assertions in `ValidateInputsStandardness` checks the wrong transaction.

  The test builds `txToNonStd2_no_scriptSig` (which spends a P2SH prevout with an empty scriptSig) and checks its standardness result ("input 0 P2SH redeemscript missing"), but the `GetP2SHSigOpCount` assertion right after it re-checks the previous transaction: line 433 is byte-identical to line 419. Looks like a copy-paste slip from 248c175e3d, which added a `GetP2SHSigOpCount` check after each constructed transaction.

  This PR points the assertion at `txToNonStd2_no_scriptSig` and expects 0 sigops. With an empty scriptSig there's no redeemScript push, so `GetSigOpCount(scriptSig)` ends up counting an empty subscript and returns 0. This case wasn't asserted anywhere before. The line above covers the other side, where the same prevout spent with the actual redeemScript counts 20.

  To make sure the fix isn't vacuous I also ran the assertion expecting 20, and it fails with `[0 != 20]`.

  Tested with:

  ```
  cmake --build build --target test_bitcoin
  build/bin/test_bitcoin --run_test=script_p2sh_tests
  ```

ACKs for top commit:
  l0rinc:
    ACK 756afe14b5
  sedited:
    ACK 756afe14b5

Tree-SHA512: 463eda7bb8790fb55619b36a6bedcd437f5c3d753e8c0abaa57dde3154421cde8c36f04293eb712ddf2745d525b5e254e8a1ab898f4f68538520dd80d873dba3
2026-08-04 13:28:38 +02:00
merge-script
975a314667 Merge bitcoin/bitcoin#35832: p2p: avoid block disk reads on unnecessary requests
28641fd195 p2p: reject empty getblocktxn requests (furszy)
9871fb726c p2p: reject filtered block inv early when bloom is disabled (furszy)
aaf9412026 refactor: split p2p_getdata.py in sub-cases (furszy)

Pull request description:

  Reject requests that make the node read blocks from disk unnecessarily:

  * `getblocktxn` is meant to request the txs a peer is missing. When a
    peer sends a `getblocktxn` with an empty index vector, it isn't missing
    anything, so it shouldn't have sent the message in the first place.

  * The peer should not request a filtered block when the node does not
    advertise the `NODE_BLOOM` service. Filtered blocks are built from
    the bloom filter, which can be loaded only when the `NODE_BLOOM`
    service is offered.

  Both are disconnected now.

  Note: can be split in two PRs if preferred.

ACKs for top commit:
  151henry151:
    ACK 28641fd195
  l0rinc:
    lightly tested ACK 28641fd195
  mzumsande:
    Code Review ACK 28641fd195
  winterrdog:
    tested ACK 28641fd195
  sedited:
    ACK 28641fd195

Tree-SHA512: 787ee0741fb797ea0898daab1bf3d7b3a21d91c9d940fc833e893806e95843e9d5a7a79a55ba67ac0f1550c08f2b6cee5ab2b625c082f56885ae795958cc608c
2026-08-04 11:50:22 +02:00
merge-script
d24610fa2c Merge bitcoin/bitcoin#35870: guix: move python-minimal to Linux GUI build
b75eb938a0 guix: move python-minimal to GUI build (fanquake)
101400b28f guix: remove -Werror=dev (fanquake)

Pull request description:

  Somewhat of a followup to #35537.

ACKs for top commit:
  maflcko:
    lgtm ACK b75eb938a0
  janb84:
    ACK b75eb938a0

Tree-SHA512: 6bd22b6294019692bd6fe42818589f8ee05513a0102c6f5164d1abe988477d88c2e387f39ddd2dbd45a21e12634c59cea21f3f0a0664b3674f67c772fcc7a886
2026-08-04 10:23:08 +01:00
merge-script
b33a5b5767 Merge bitcoin/bitcoin#35871: refactor: Annotate MakeAndPushFeature with [[maybe_unused]]
0238aebf61 refactor: Annotate `MakeAndPushFeature` with `[[maybe_unused]]` (Hennadii Stepanov)

Pull request description:

  This is a follow-up to bitcoin/bitcoin#35221. The `MakeAndPushFeature` member function template has no callers yet, which [triggers](https://my.cdash.org/builds/3851810/build) `-Wunused-template` now that Clang 23 [enables](https://github.com/llvm/llvm-project/pull/208001) it as part of `-Wall`.

  Related PRs:
   - https://github.com/bitcoin/bitcoin/pull/35679
   - https://github.com/bitcoin/bitcoin/pull/35737
   - https://github.com/bitcoin-core/minisketch/pull/102

ACKs for top commit:
  maflcko:
    lgtm ACK 0238aebf61
  sedited:
    ACK 0238aebf61

Tree-SHA512: c8b639055d34ea431d5d5f4c85815b4c19b31d6ea7e4a0c05c8420a328503028eca465fb0803eff3d4bab2c782cb8038844d3f89680928791832488494bd95d4
2026-08-04 10:21:08 +01:00