Commit Graph

49971 Commits

Author SHA1 Message Date
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
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
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
merge-script
4b322989ac Merge bitcoin/bitcoin#34995: iwyu: Fix warnings in src/common and treat them as errors
50145f62c9 ci, iwyu: Enforce warning-free `src/common` (Hennadii Stepanov)

Pull request description:

  This PR [continues](https://github.com/bitcoin/bitcoin/pull/33725#issuecomment-3466897433) 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 50145f62c9 🌾

Tree-SHA512: c14f97d725429fed0860a608cdb53d9c6c5c36fb710f44357ba276d5507fb9b0d99ba6dac8d9a8b1ac404d9093ebffd9fb07ee5f68b4d276657d087c1f404a63
2026-08-04 10:17:24 +01:00
merge-script
75f024a84e Merge bitcoin/bitcoin#35875: ci: Fix NetBSD SDK download failure, Temp. remove riscv32 from GHA
fa06ea4244 ci: Temporarily remove riscv32 config from GHA matrix (MarcoFalke)
873550bea3 ci: verify cross-build SDK archives (Lőrinc)
2c87337efe ci: update NetBSD cross-build SDK (Lőrinc)

Pull request description:

  Address a few CI failures in three commits:

  * The NetBSD SDK release candidate was removed, so the CI consistently fails. Fix it by bumping to a release.
  * Also, include SDK download hashes to catch stuff like rare bit flips due to cosmic rays.
  * The riscv32 config consistently fails with download errors as well. Temporarily remove it until issue https://github.com/bitcoin/bitcoin/issues/35853 is fixed.

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

Tree-SHA512: 27c728f2a94386e4ef882757e1cc30ca8336c89775965d1a567dcac17681d9dd49547246f700969293ac8798e882489eb5c1b2b5fed4759c83d0f4463a592579
2026-08-04 10:11:01 +01:00
MarcoFalke
fa06ea4244 ci: Temporarily remove riscv32 config from GHA matrix
It fails due to https://github.com/bitcoin/bitcoin/issues/35853.

It can be added back when the issue is addressed.
2026-08-04 07:45:21 +02:00
Lőrinc
873550bea3 ci: verify cross-build SDK archives
The macOS and BSD cross-build jobs extract SDK archives fetched at runtime without checking their content.
Keep each expected digest beside the corresponding SDK version and verify every archive before extraction.
Create the OpenBSD library symlinks once after both archives are extracted, when all link targets are present.
2026-08-03 12:17:47 -07:00
Lőrinc
2c87337efe ci: update NetBSD cross-build SDK
The NetBSD 11.0_RC6 archives are no longer available from cdn.netbsd.org. Update the cross-build SDK to the final 11.0 release.
2026-08-03 12:17:22 -07:00
Lőrinc
6a2de55a0d test: require TryGetTotalRam() detection
RAM detection controls automatic `-dbcache` selection, so fail the test when it is unavailable.
2026-08-03 12:04:10 -07:00
Lőrinc
cd086c16dd node, qt: inline DEFAULT_DB_CACHE
The alias is misleading because automatic selection can also return `HIGH_DEFAULT_DBCACHE`.
2026-08-03 12:03:56 -07:00
Lőrinc
8bd9f46082 kernel: allow setting chainstate dbcache
Add `btck_chainstate_manager_options_set_database_cache_bytes()` so Kernel callers can set the total database cache budget.
Use `uint64_t` for a fixed-width C API, reject values outside the architecture-specific range, and keep `DEFAULT_KERNEL_CACHE` as the fallback.
Apply the selected split to the block tree database and `LoadChainstate()`.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
Co-authored-by: w0xlt <94266259+w0xlt@users.noreply.github.com>
Co-authored-by: stringintech <stringintech@gmail.com>
2026-08-03 12:03:56 -07:00
Lőrinc
8aa21e119b kernel, node: colocate dbcache bounds
Keep the total database cache bounds with `kernel::CacheSizes` so node and Kernel callers validate against the same range.
2026-08-03 12:03:56 -07:00
Lőrinc
7cfa21d60a scripted-diff: use MIN_DBCACHE_BYTES
-BEGIN VERIFY SCRIPT-
git grep -q '\bMIN_DBCACHE_BYTES\b' -- src && echo "Error: renamed dbcache byte constant already exists in src" && exit 1
git grep -l 'MIN_DB_CACHE' -- src | xargs perl -pi -e 's/\bMIN_DB_CACHE\b/MIN_DBCACHE_BYTES/g'
-END VERIFY SCRIPT-

Co-authored-by: optout <13562139+optout21@users.noreply.github.com>
2026-08-03 12:03:56 -07:00
Lőrinc
ab63432576 common: cache total RAM as uint64_t
Detect total RAM once so automatic cache selection and the oversized-cache warning use the same value.
Database cache arithmetic now uses `uint64_t`, so return the byte count directly and remove the 32-bit `size_t` clamp.

Co-authored-by: stringintech <stringintech@gmail.com>
2026-08-03 12:03:56 -07:00
Lőrinc
031fa402c8 scripted-diff: use TryGetTotalRam
Use the `Try` prefix to make failed RAM detection visible at call sites.

-BEGIN VERIFY SCRIPT-
git grep -q 'TryGetTotalRam' -- src && echo "Error: TryGetTotalRam already exists in src" && exit 1
git grep -l 'GetTotalRAM' -- src | xargs perl -pi -e 's/\bGetTotalRAM\b/TryGetTotalRam/g'
-END VERIFY SCRIPT-
2026-08-03 12:03:32 -07:00
Lőrinc
41c44f5588 node, qt: use 1_MiB for dbcache conversions 2026-08-03 11:40:07 -07:00
Hennadii Stepanov
0238aebf61 refactor: Annotate MakeAndPushFeature with [[maybe_unused]]
This is a follow-up to bitcoin/bitcoin#35221. The `MakeAndPushFeature`
member function template has no callers yet, which triggers
`-Wunused-template` now that Clang 23 enables it as part of `-Wall`.
2026-08-03 17:20:08 +01:00
Hennadii Stepanov
1ed14c6122 Merge bitcoin-core/gui#872: Menu action to export a watchonly wallet
6573196e63 doc: Release note for export watchonly wallet gui action (Ava Chow)
cb51f97f6c gui: Menu action for exporting a watchonly wallet (Ava Chow)
5907a5c7dc gui: Add ExceptionSafeConnect that takes a lambda (Ava Chow)

Pull request description:

  Allows a user to export a watchonly version of their wallet to be used in an airgapped setup.

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

ACKs for top commit:
  polespinasa:
    lgtm ACK 6573196e63
  pablomartin4btc:
    ACK 6573196e63
  hebasto:
    ACK 6573196e63.

Tree-SHA512: 30732ecf2ff40dbbd62a8a9974a907fd60f0da89afacce618fb706a02349135dc06d7dfcc11009caba0e020609ab7e586a0ebbeb7cd65940ee2df229d23f0605
2026-08-03 15:53:09 +01:00
fanquake
b75eb938a0 guix: move python-minimal to GUI build 2026-08-03 14:47:39 +01:00
fanquake
101400b28f guix: remove -Werror=dev
Otherwise the build will fail with warnings about missing Python (removed
in the next commit). However the non-gui build does not need Python.

Note that #25573 contains the same change, because the use of -static-pie
causes warnings when combined with our/CMakes own PIE handling.
2026-08-03 13:32:07 +01:00
merge-script
e27c179db2 Merge bitcoin/bitcoin#35869: lint: (re-)add contrib/guix for Python linting
8221d714c7 lint: document CI lief version requirement (fanquake)
594a02c3ae lint: re-add guix scripts to mypy linting (fanquake)

Pull request description:

  These were no-longer being linted after https://github.com/bitcoin/bitcoin/pull/32458.

  suppress `[union-attr]` warning. i.e:
  ```bash
  contrib/guix/symbol-check.py:309: error: Item "None" of "lief.PE.Binary | lief.ELF.Binary | lief.MachO.Binary | lief.COFF.Binary | None" has no attribute "format"  [union-attr]
  contrib/guix/security-check.py:284: error: Item "lief.COFF.Binary" of "lief.PE.Binary | lief.ELF.Binary | lief.MachO.Binary | lief.COFF.Binary | None" has no attribute "abstract"  [union-attr]
  ```

  Add the comment suggested in [#35855.](https://github.com/bitcoin/bitcoin/pull/35855#discussion_r3694954625).

ACKs for top commit:
  maflcko:
    lgtm ACK 8221d714c7 in any case.
  hebasto:
    ACK 8221d714c7, I have reviewed the code and it looks OK.

Tree-SHA512: ec404a8235fd40b212aad71ee3fe3473a3ce6f1ebaed46661d36ef02862b08528e3b6b829e05c5b943c8543380f3876e33da725154ce31d4022ad39ae5ef5ab3
2026-08-03 13:29:58 +01:00
Hennadii Stepanov
50145f62c9 ci, iwyu: Enforce warning-free src/common
Fix all IWYU warnings in `src/common` and treat them as errors in CI.

Additionally, ensure that our drop-in header replacements are used
instead of system headers:
- `<util/check.h>` instead of `<cassert>`
- `<util/time.h>` instead of `<chrono>`
2026-08-03 12:22:58 +01:00
merge-script
30f6b05857 Merge bitcoin/bitcoin#35860: fuzz: Rework rpc fuzz target
fa895bb77a fuzz: Rework rpc fuzz target (MarcoFalke)

Pull request description:

  The `rpc` fuzz target constructs a vector of string args and passes that to `RPCConvertValues`.

  This has many issues:

  * Each of those strings could represent an array itself. E.g. via `range argument` or via `ConsumeArrayRPCArgument`. However, those strings may not be converted to an array via `RPCConvertValues` and just be passed on as string argument. Having a call to `ConsumeArrayRPCArgument` that ends up with a plain json string is confusing.
  * The strings could only represent an object or json null, when a raw string represented such a serialized json and was also converted to one via `RPCConvertValues`. Having a call to `ConsumeScalarRPCArgument` that was intended to give a raw string but ends up with a arbitrary json object is confusing.

  Fix those "stringly-typed" issues by making the fuzz target "type safe":

  * Rename `ConsumeScalarRPCArgument` to `ConsumeBasicRPCArgument` and return a proper `UniValue` from it.
  * The "consume string" case inside that function, which had a "double meaning" is turned into two type-safe cases: One that returns a json string and one that reads an arbitrary json from a string.
  * A new case for json null is added.
  * `ConsumeRPCArgument` is changed to cover both json arrays and json dicts properly.
  * Pass the resulting positional UniValue array directly to the RPC method, avoiding the need for `RPCConvertValues`.

  Making the fuzz target "type safe" is also the first step in making it schema-aware.

ACKs for top commit:
  dergoegge:
    utACK fa895bb77a

Tree-SHA512: ee22310c981be802f4838454be0e7ef2be213704621c08ffe98dbeab2e3d7cc6ff6a37f7a129e1570185f13a740d34fd9e2c6de3a8281e8b8dc1277f673c4a48
2026-08-03 12:17:52 +01:00
merge-script
dcc2ed52b8 Merge bitcoin/bitcoin#35856: fuzz: cover the mempool interface for transaction announcement
dd2561003d fuzz: cover the mempool interface for transaction announcement (Antoine Poinsot)

Pull request description:

  This adds coverage in the existing `tx_pool` harness for the `ExtractBestByMiningScoreWithTopology` method recently added in #34628.

ACKs for top commit:
  dergoegge:
    utACK dd2561003d

Tree-SHA512: 3e2ea6afff080f48f5b519c49cb6ef51a76eb20186bcfcb5d8cf194f67aa99bf5f5683271b58b97c9bc4e521ea3e08a46ee019e0ffc028222db9dbcb383c48fd
2026-08-03 12:08:11 +01:00
fanquake
8221d714c7 lint: document CI lief version requirement 2026-08-03 11:52:17 +01:00
fanquake
594a02c3ae lint: re-add guix scripts to mypy linting
These were no-longer being linted after #32458.

suppress `[union-attr]` warning. i.e:
```bash
contrib/guix/symbol-check.py:309: error: Item "None" of "lief.PE.Binary | lief.ELF.Binary | lief.MachO.Binary | lief.COFF.Binary | None" has no attribute "format"  [union-attr]
contrib/guix/security-check.py:284: error: Item "lief.COFF.Binary" of "lief.PE.Binary | lief.ELF.Binary | lief.MachO.Binary | lief.COFF.Binary | None" has no attribute "abstract"  [union-attr]
```
2026-08-03 11:52:14 +01:00
MarcoFalke
ddddffda3a doc: Add doc/release-notes-35836.md 2026-08-03 10:28:03 +02:00
JP
756afe14b5 test: give each ValidateInputsStandardness case its own scope 2026-08-02 22:07:31 +01:00
JP
5559fa464b test: fix wrong transaction in GetP2SHSigOpCount assertion 2026-08-01 22:21:02 +01:00
merge-script
556988790a Merge bitcoin/bitcoin#35592: http: check rpcallowip immediately after accepting connection
55d3cd51a4 doc: add release note describing change for forbidden clients (Matthew Zipkin)
d1ed2a6e25 http: check rpcallowip immediately after accepting connection (Matthew Zipkin)

Pull request description:

  This is a follow-up to #35182 addressing a review comment from that PR: https://github.com/bitcoin/bitcoin/pull/35182#pullrequestreview-4322490068

  This update to HTTPServer checks the IP subnet allowlist as soon as possible (immediately after receiving a connection from a client) before any data is received. This does not entirely protect the server from the "slow loris" attack or [CWE-400](https://cwe.mitre.org/data/definitions/400.html) but does restrict the attack surface to localhost and clients explicitly allowed by the user.

  If a client is not allowed by the list, we disconnect as soon as possible. This is a behavior change from master branch (and previous release with libevent) where `403 Forbidden` was returned (after a potentially large amount request data was written to memory by the server).

  To facilitate existing unit tests, this commit includes a refactor that moves the subnet allow list and relevant methods into the HTTPServer class instead of static file scope. This is needed because otherwise the allow list would be empty when the unit tests run.

  There is still plenty of refactoring to do in order to modernize `HTTPServer` and de-globalize it, but since this specific issue has a resource allocation guard, I wanted to open it quickly on its own.

ACKs for top commit:
  janb84:
    ACK 55d3cd51a4
  winterrdog:
    ACK 55d3cd51a4
  w0xlt:
    ACK 55d3cd51a4
  fjahr:
    Code review ACK 55d3cd51a4

Tree-SHA512: 545911f2e4d2f97ab8bc854e9e57c39eb896428f8c349d34c8e8025a1f6bfb8cfd436f381e36af8b87592c07df3e16210819f3eef7943e23c6626030e615fdf5
2026-08-01 16:43:57 +01:00
MarcoFalke
fa895bb77a fuzz: Rework rpc fuzz target 2026-08-01 16:40:46 +02:00
furszy
28641fd195 p2p: reject empty getblocktxn requests
A getblocktxn msg is only needed when at least one tx is
missing from a compact block. If no txs are missing, the
block can be reconstructed without sending the request.

This avoids reading the requested block from disk
unnecessarily and also alerts the peer operator about
their node's buggy behavior.
2026-07-31 16:08:08 -04:00
Antoine Poinsot
dd2561003d fuzz: cover the mempool interface for transaction announcement
This adds coverage for the recently-added ExtractBestByMiningScoreWithTopology method.
2026-07-31 15:44:47 -04:00
furszy
9871fb726c p2p: reject filtered block inv early when bloom is disabled
A peer should not request filtered blocks from a node that
does not advertise NODE_BLOOM. Perform this check before
looking up the block to avoid an unnecessary disk read.

Note: currently, the request is ignored only after the
block has been read from disk, in the bloom filter
existence check.
2026-07-31 15:32:14 -04:00