Commit Graph

29385 Commits

Author SHA1 Message Date
Ava Chow
1af46cff94 Merge bitcoin/bitcoin#33896: clang-format: Set InsertNewlineAtEOF: true
fa1bf6818f clang-format: Set InsertNewlineAtEOF: true (MarcoFalke)

Pull request description:

  Now that the minimum supported clang version is 17, the `InsertNewlineAtEOF` setting can be set to `true` in the clang-format file. (https://releases.llvm.org/16.0.0/tools/clang/docs/ClangFormatStyleOptions.html#insertnewlineateof)

  This is in line with the already existing newline linter. Can be tested via:

  ```
  truncate --size=-1 src/init.cpp
  git diff

  # Should fail:
  cargo run --manifest-path ./test/lint/test_runner/Cargo.toml -- --lint=trailing_newline

  # Restore newline:
  git diff -U0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v
  ```

ACKs for top commit:
  l0rinc:
    ACK fa1bf6818f
  achow101:
    ACK fa1bf6818f
  hodlinator:
    ACK fa1bf6818f
  stickies-v:
    ACK fa1bf6818f
  hebasto:
    ACK fa1bf6818f.
  janb84:
    ACK fa1bf6818f

Tree-SHA512: 6443f0f9e2710fb31c85e4ece5deb9fa25bf22ef2d5cadad2d54a239194860c3a785ffa5dd97be942e42139336575425499f085aa2e3f29003e529fdc20fce20
2025-11-19 16:23:07 -08:00
Ava Chow
27ac11ea0a Merge bitcoin/bitcoin#33867: kernel: handle null or empty directories in implementation
6657bcbdb4 kernel: allow null data_directory (stickies-v)

Pull request description:

  An empty path may be represented with a `nullptr`. For example, `std::string_view{}.data()` may return nullptr.

  Removes the `BITCOINKERNEL_ARG_NONNULL` attribute for `btck_chainstate_manager_options_create` 's `data_directory` parameter, and instead handles such null arguments in the implementation. [Because an empty path is meaningless](https://github.com/bitcoin/bitcoin/pull/33867#discussion_r2523930442), `btck_chainstate_manager_options_create` now treats both null and empty directories as invalid, tightening the interface.

  Also documents how `BITCOINKERNEL_ARG_NONNULL` should be used.

  Follow-up to https://github.com/bitcoin/bitcoin/pull/33853#pullrequestreview-3454620265

ACKs for top commit:
  stringintech:
    ACK 6657bcb
  maflcko:
    review ACK 6657bcbdb4 🐪
  achow101:
    ACK 6657bcbdb4
  TheCharlatan:
    ACK 6657bcbdb4
  janb84:
    ACK 6657bcbdb4

Tree-SHA512: 11c02b221ff19a5357e94355808e3b503b3a336c16fc5186c9c9137931709e880383ed1f4990fc4cc6b0e23961e2e1e03fc90154a3b546b9490ef66bd63688b7
2025-11-19 16:22:01 -08:00
merge-script
509dc91db1 Merge bitcoin/bitcoin#33026: test, refactor: Embedded ASMap [1/3]: Selected minor preparatory work
7f318e1dd0 test: Add better coverage for Autofile size() (Fabian Jahr)
b7af960eb8 refactor: Add AutoFile::size (Fabian Jahr)
ec0f75862e refactor: Modernize logging in util/asmap.cpp (Fabian Jahr)
606a251e0a tests: add unit test vectors for asmap interpreter (Pieter Wuille)

Pull request description:

  This contains some commits from #28792 that can be easily reviewed and merged independently. I hope splitting this change off can make this part move a bit faster and reduce frequency of needed rebases for #28792.

  The commits in order:
  - Add additional unit test vectors to the asmap interpreter (written by sipa). This helps to ensure that the further refactors in #28792 don't change behavior.
  - Modernizes the logging in `util/asmap.cpp`, I added this while touching the rest of the file all over anyway.
  - Adds an `AutoFile::size` helper function with some additional test coverage in a separate commit

ACKs for top commit:
  maflcko:
    review ACK 7f318e1dd0 🏀
  hodlinator:
    tACK 7f318e1dd0
  laanwj:
    Code review ACK 7f318e1dd0

Tree-SHA512: 45156b74e4bd9278a7ec24521dfdafe4dab1ba3384243c7d589ef17e16ca374ee2af7178c86b7229e80ca262dbe78c4d456d80a6ee742ec31d2ab5243dac8b57
2025-11-19 09:28:44 +00:00
Hennadii Stepanov
b126f98194 Merge bitcoin-core/gui#910: Added test coverage for qt gui#901 console history filter
310e4979b3 qt: Added test coverage for qt gui#901 console history filter (WakeTrainDev)

Pull request description:

  Add test coverage for the QT rpc console updated filtered commands in gui#901

ACKs for top commit:
  pablomartin4btc:
    ACK 310e4979b3
  hebasto:
    ACK 310e4979b3, tested on Fedora 42 by reverting 4e352efa2c.

Tree-SHA512: 45bb8583311f145353d8265d28f220d2a318c701346f147979c5d33b27811276d5e18586bf58f35e455701495d2cb87ec54dd78f4ca8631a0c7bd2c1d7fe640c
2025-11-18 23:24:31 +00:00
Hennadii Stepanov
7d7b829c36 Merge bitcoin-core/gui#908: Remove HD seed reference from blank wallet tooltip
929f69d0ff qt: Remove HD seed reference from blank wallet tooltip (John Moffett)

Pull request description:

  Blank descriptor wallets currently do not have HD seeds and none can be added (or 'set') by the user, so remove the reference in the tooltip.

  As I understand it, descriptor wallets don't have a global HD seed and don't store the HD seeds for keys they generate. Currently, no new HD seeds can be added by the user (even for old wallets since `sethdseed` was removed), though it may be possible in the future, eg -  https://github.com/bitcoin/bitcoin/pull/33043

ACKs for top commit:
  maflcko:
    lgtm ACK 929f69d0ff

Tree-SHA512: 85e9c8e18a92b3da6fd62b70570cef58e03843633300b65aee5789d38c7bcaa46738970f0aea63f4e9b3e8814abb5bf1e1aa93f568a875ad1e0443d4dafb0aab
2025-11-18 23:02:50 +00:00
Ava Chow
53b72372da Merge bitcoin/bitcoin#31734: miniscript: account for all StringType variants in Miniscriptdescriptor::ToString()
28a4fcb03c test: check listdescriptors do not return a mix of hardened derivation marker (pythcoiner)
975783cb79 descriptor: account for all StringType in MiniscriptDescriptor::ToStringHelper() (pythcoiner)

Pull request description:

  In `MiniscriptDescriptor::ToStringHelper()` only the `StringType::Private` variant of the `type` argument was handled. This PR implements serializing w/ all variants of `StringType` & add a functional test for the descriptor triggering the related issue.

  Closes #31694: previously when calling `listdescriptors` RPC on a wallet containing a taproot descriptor w/ a (miniscript) taptree, origins of internal key & taptree were serialized w/ differents hardened derivation markers:
   - origin of the internal key were serialized w/ `StringType::Normalized` type (using `h` as marker)
   - origins of taptree keys were serialized w/ `StringType::Private` type (using `'` as marker)

  Note: Origins in segwit (`wsh()`) miniscript descriptors were also serialized w/ `StringType::Private` type (`'` marker) and are now serialized w/ `StringType::Normalized` type (`h` marker).

ACKs for top commit:
  sipa:
    Code review ACK 28a4fcb03c
  achow101:
    ACK 28a4fcb03c
  rkrux:
    Concept ACK 28a4fcb03c

Tree-SHA512: 15d14000b5951ca69a64a05b9a0b138c48a07b81eaf2fa86b91ac20cc8735533355a787363c64ba88403dd8a56ef5232cba57d34bea80835a0f40774d62fbc2b
2025-11-18 14:32:01 -08:00
Ava Chow
a7f9bbe4c5 Merge bitcoin/bitcoin#32821: rpc: Handle -named argument parsing where '=' character is used
f53dbbc505 test: Add functional tests for named argument parsing (zaidmstrr)
694f04e2bd rpc: Handle -named argument parsing where '=' character is used (zaidmstrr)

Pull request description:

  Addresses [comment](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2091886628) and [this](https://github.com/bitcoin/bitcoin/pull/31375#discussion_r2092039999).

  The [PR #31375](https://github.com/bitcoin/bitcoin/pull/31375) got merged and enables `-named` by default in the `bitcoin rpc` interface; `bitcoin rpc` corresponds to `bitcoin-cli -named` as it's just a wrapper.  Now, the problem arises when we try to parse the positional paramater which might contain "=" character.  This splits the parameter into two parts first, before the "=" character, which treats this as the parameter name, but the other half is mostly passed as an empty string. Here, the first part of the string is an unknown parameter name; thus, an error is thrown. These types of errors are only applicable to those RPCs which might contain the `=` character as a parameter. Some examples are `finalizepsbt`, `decodepsbt`, `verifymessage` etc.

  This is the one example of the error in `finalizepsbt` RPC:
  ```
  ./bitcoin-cli -named -regtest finalizepsbt cHNidP8BAJoCAAAAAqvNEjSrzRI0q80SNKvNEjSrzRI0q80SNKvNEjSrzRI0AAAAAAD9////NBLNqzQSzas0Es2rNBLNqzQSzas0Es2rNBLNqzQSzasBAAAAAP3///8CoIYBAAAAAAAWABQVQBGVs/sqFAmC8HZ8O+g1htqivkANAwAAAAAAFgAUir7MzgyzDnRMjdkVa7d+Dwr07jsAAAAAAAAAAAA=
  error code: -8
  error message:
  Unknown named parameter cHNidP8BAJoCAAAAAqvNEjSrzRI0q80SNKvNEjSrzRI0q80SNKvNEjSrzRI0AAAAAAD9////NBLNqzQSzas0Es2rNBLNqzQSzas0Es2rNBLNqzQSzasBAAAAAP3///8CoIYBAAAAAAAWABQVQBGVs/sqFAmC8HZ8O+g1htqivkANAwAAAAAAFgAUir7MzgyzDnRMjdkVa7d+Dwr07jsAAAAAAAAAAAA
  ```
  This PR fixes this by updating the `vRPCConvertParams` table that identifies parameters that need special handling in `-named` parameter mode. The parser now recognises these parameters and handles strings with "=" char correctly, preventing them from being incorrectly split as parameter assignments.

ACKs for top commit:
  ryanofsky:
    Code review ACK f53dbbc505. Just applied comment & test suggestions since last review
  kannapoix:
    Code review ACK: f53dbbc505
  achow101:
    ACK f53dbbc505

Tree-SHA512: 1b517144efeff45a4c4256c27a39ddf187f1d6189d133402a45171678214a10ff2925c31edcfd556d67f85bd26d42f63c528b941b68c9880eab443f2c883e681
2025-11-18 14:06:54 -08:00
merge-script
2444488f6a Merge bitcoin/bitcoin#33894: net: Remove unused local_socket_bytes variable in CConnman::GetAddresses()
4d893c0f46 net: Remove unused `local_socket_bytes` variable in `CConnman::GetAddresses()` (WakeTrainDev)

Pull request description:

  The local_socket_bytes variable was never used. Removed it to clean up dead code.

ACKs for top commit:
  mzumsande:
    ACK 4d893c0f46
  theStack:
    ACK 4d893c0f46

Tree-SHA512: f423bcf975aa2602464fcb96db323cbd6007a7491ddbe119f1d20e890c883dd351a55976151c5d25f5d26267b0efe1f0836fbd65e540c920dac931ed8d67846a
2025-11-18 09:30:24 +00:00
MarcoFalke
fa1bf6818f clang-format: Set InsertNewlineAtEOF: true 2025-11-18 08:40:03 +01:00
Ava Chow
115d298a9f Merge bitcoin/bitcoin#33872: init: completely remove -maxorphantx option
0aebdac95d init: completely remove `-maxorphantx` option (Sebastian Falbesoner)

Pull request description:

  This is a small follow-up for #32941 (commit 1384dbaf6d), removing the `-maxorphantx` option completely, now that v30 has been released. If removing it for v31 is seen as controversial/premature (I personally don't think it is), the merge can be delayed for a future release.

ACKs for top commit:
  maflcko:
    lgtm ACK 0aebdac95d
  achow101:
    ACK 0aebdac95d
  w0xlt:
    ACK 0aebdac95d
  rkrux:
    lgtm ACK 0aebdac95d
  stickies-v:
    ACK 0aebdac95d

Tree-SHA512: 818633b903174387ae259acb1d1e8ce07f78e158de2c150742ef0950b0f5d62af553e4e35ab962432306e04e07c45b1be11dbae459a8b62c4b9a6b5ef1746d26
2025-11-17 18:17:17 -08:00
Ava Chow
a90f3922ff Merge bitcoin/bitcoin#32419: psbt: clarify PSBT, PSBTInput, PSBTOutput unserialization flows
d31158d364 psbt: clarify PSBT, PSBTInput, PSBTOutput unserialization flows (rkrux)

Pull request description:

  The unserialization flows of the PSBT types work based on few underlying assumptions of functions from `serialize.h` & `stream.h` that takes some to understand when read the first time.

  Add few comments that highlight these assumptions hopefully making it easier to grasp. Also, mention key/value format types as per BIP 174.

ACKs for top commit:
  achow101:
    ACK d31158d364
  theStack:
    ACK d31158d364

Tree-SHA512: 45111ef7f0258ebbc41d058b3ef2a72472774ab2878caf2d71d7b57b27549c46a51ccbeda5fe164bcf4f7ec10627bbae6e7763aa80b1e66912703a2088682817
2025-11-17 14:08:20 -08:00
WakeTrainDev
4d893c0f46 net: Remove unused local_socket_bytes variable in CConnman::GetAddresses() 2025-11-17 23:59:21 +02:00
merge-script
ead849c9f1 Merge bitcoin/bitcoin#33886: test: Remove tests violating hardened std::span
fadb4f63cb test: Remove tests violating hardened std::span (MarcoFalke)

Pull request description:

  Also, add a test for creating a CScript from an empty byte vector.

  To test: `rm -rf ./bld-cmake && cmake -B ./bld-cmake  -DCMAKE_C_COMPILER='clang' -DCMAKE_CXX_COMPILER='clang++;-stdlib=libc++;-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG' -DBUILD_GUI=OFF -DBUILD_FUZZ_BINARY=OFF -DBUILD_BENCH=OFF -DBUILD_KERNEL_LIB=ON -DENABLE_WALLET=OFF -DENABLE_IPC=OFF && cmake --build ./bld-cmake --parallel $( nproc ) && valgrind --tool=none ./bld-cmake/bin/test_kernel --catch_system_error=no`

  Before:

  ```
  /cxx_build/include/c++/v1/span:451: libc++ Hardening assertion __count == 0 || std::to_address(__first) != nullptr failed: passed nullptr with non-zero length in span's constructor (iterator, len)
  ```

  After: (Passes)

ACKs for top commit:
  TheCharlatan:
    ACK fadb4f63cb
  stickies-v:
    ACK fadb4f63cb

Tree-SHA512: 47c2ee975b82978bbb226b47cde337dce5a7e25bc1d70c31f34b9a9ff38477609764c267e47ac5fd71a578fb2b2b135c698bb02dae1777a87bcc4079dcd278ef
2025-11-17 14:00:05 +00:00
MarcoFalke
fadb4f63cb test: Remove tests violating hardened std::span 2025-11-17 13:12:08 +01:00
merge-script
6e21558160 Merge bitcoin/bitcoin#33869: refactor: Avoid -W*-whitespace in git archive
fa95353902 ci: Run macos tasks in a git archive, not git checkout (MarcoFalke)
faf99ae379 refactor: Avoid -W*-whitespace in git archive (MarcoFalke)

Pull request description:

  Otherwise, compilation with GCC-15+ will warn about it:

  ```
  src/clientversion.cpp:33:79: error: trailing whitespace [-Werror=trailing-whitespace=]
     33 | //! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives.
  ```

  Follow-up to https://github.com/bitcoin/bitcoin/pull/32482#issuecomment-3522280482

  Can be tested via `git archive --output=/tmp/a.tar HEAD`

ACKs for top commit:
  fanquake:
    ACK fa95353902

Tree-SHA512: 73940ffc0fd83db557275bd5e993a3c47c5397682a1188447c48e077ead597ba0fc3e5ef9da7b746746ff04a26022ce35ac10768888bbd4707f25b799af43e45
2025-11-17 11:36:47 +00:00
merge-script
c8715aca95 Merge bitcoin/bitcoin#33247: build: Remove CMAKE_SKIP_BUILD_RPATH and SKIP_BUILD_RPATH settings
2594d5a189 build: Remove CMAKE_SKIP_BUILD_RPATH and SKIP_BUILD_RPATH settings (Henry Romp)

Pull request description:

  Remove CMAKE_SKIP_BUILD_RPATH and SKIP_BUILD_RPATH settings that are no longer needed after reordering the Guix build script to perform binary checks after installation.

  This PR also removes the unused CMake maintenance targets (`check-security` and `check-symbols`) and updates the Guix security checks to include binaries in the `libexec/` directory (added in PR #31679).

ACKs for top commit:
  purpleKarrot:
    ACK 2594d5a189
  hebasto:
    ACK 2594d5a189.

Tree-SHA512: ed451a298f5aae05c177b0033b092faaa7536caeaa3d84da9b8b611e2aa905e1dd337e57aef0efd69ce6ce6ac0cf77dc57adf175079b95bf53dd96d5d0c8118b
2025-11-17 11:00:03 +00:00
Hennadii Stepanov
c66e988754 Merge bitcoin/bitcoin#33865: cmake: Specify Windows plugin path in test_bitcoin-qt property
0dd8d5c237 cmake: Specify Windows plugin path in `test_bitcoin-qt` property (Hennadii Stepanov)

Pull request description:

  This PR simplifies testing on Windows by removing the need to set the `QT_PLUGIN_PATH` environment variable for different build configurations. For example, the paths might otherwise be:
  - `C:/Users/hebasto/dev/bitcoin/build/vcpkg_installed/x64-windows/Qt6/plugins/` for "Release"
  - `C:/Users/hebasto/dev/bitcoin/build/vcpkg_installed/x64-windows/debug/Qt6/plugins/` for "Debug"

ACKs for top commit:
  purpleKarrot:
    ACK 0dd8d5c237

Tree-SHA512: 0418b8fa4d74ca500aae9e36e56ebcefb566d2ac04a9d22e17d309400ad38dd5a6e75f0195c680796b761fb145444c33336b64180f15c6b1125fe190d58396b6
2025-11-15 16:19:34 +00:00
Fabian Jahr
7f318e1dd0 test: Add better coverage for Autofile size()
The new test explicitly checks that the function does not change the current position.
2025-11-14 16:37:06 +02:00
Fabian Jahr
b7af960eb8 refactor: Add AutoFile::size 2025-11-14 01:17:38 +02:00
Fabian Jahr
ec0f75862e refactor: Modernize logging in util/asmap.cpp 2025-11-14 01:05:26 +02:00
Pieter Wuille
606a251e0a tests: add unit test vectors for asmap interpreter 2025-11-14 01:04:13 +02:00
stickies-v
6657bcbdb4 kernel: allow null data_directory
An empty path may be represented with a nullptr. For example,
std::string_view::data() may return nullptr.

Removes the BITCOINKERNEL_ARG_NONNULL attribute for data_directory,
and instead handles such null arguments in the implementation.

Also documents how BITCOINKERNEL_ARG_NONNULL should be used.
2025-11-13 18:17:58 +00:00
Sebastian Falbesoner
0aebdac95d init: completely remove -maxorphantx option 2025-11-13 19:02:39 +01:00
merge-script
dfde31f2ec Merge bitcoin/bitcoin#33864: scripted-diff: fix leftover references to policy/fees.h
b0a3887154 scripted-diff: fix leftover references to `policy/fees.h` (ismaelsadeeq)

Pull request description:

  Fixes #33863

  ryanofsky wrote
  > I still see some references to the src/policy/fees.h file removed by this PR:

  ```
  $ git grep -n policy/fees.h
  src/wallet/rpc/spend.cpp:206: * @param[in]     conf_target       UniValue integer; confirmation target in blocks, values between 1 and 1008 are valid per policy/fees.h;
  test/functional/rpc_estimatefee.py:39:        # max value of 1008 per src/policy/fees.h
  test/functional/rpc_psbt.py:604:                assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",  # max value of 1008 per src/policy/fees.h
  test/functional/wallet_basic.py:337:            assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",  # max value of 1008 per src/policy/fees.h
  test/functional/wallet_fundrawtransaction.py:851:                assert_raises_rpc_error(-8, "Invalid conf_target, must be between 1 and 1008",  # max value of 1008 per src/policy/fees.h
  test/functional/wallet_send.py:315:                expect_error=(-8, "Invalid conf_target, must be between 1 and 1008"))  # max value of 1008 per src/policy/fees.h
  ```

  This is fixed in this PR by running a script that searches for what he greps and replaces it with the right reference.

  ```
  git grep -l "policy\/fees\.h" | xargs sed -i "s/policy\/fees.h/policy\/fees\/block_policy_estimator.h/g"
  ```

ACKs for top commit:
  kevkevinpal:
    ACK [b0a3887](b0a3887154)
  janb84:
    ACK b0a3887154
  rkrux:
    lgtm ACK b0a3887154

Tree-SHA512: e24f2aaf18fcfb0ae047a53ed209135a644ff08f5a8bc162c1522be3f99d7d01d550fc2e73d8db5fec7b748902daf68e61e7a5624f5913b9824feba5641fc78c
2025-11-13 09:48:50 +00:00
MarcoFalke
faf99ae379 refactor: Avoid -W*-whitespace in git archive 2025-11-13 09:33:36 +01:00
Henry Romp
2594d5a189 build: Remove CMAKE_SKIP_BUILD_RPATH and SKIP_BUILD_RPATH settings
Remove CMake settings that are no longer needed after reordering Guix build script to perform binary checks after installation.

Also removes unused CMake maintenance targets (check-security and check-symbols) and updates security checks to include libexec/ directory binaries (see PR #31679).
2025-11-12 19:50:11 -05:00
WakeTrainDev
310e4979b3 qt: Added test coverage for qt gui#901 console history filter 2025-11-13 00:45:57 +02:00
Hennadii Stepanov
0dd8d5c237 cmake: Specify Windows plugin path in test_bitcoin-qt property 2025-11-12 19:02:29 +00:00
ismaelsadeeq
b0a3887154 scripted-diff: fix leftover references to policy/fees.h
-BEGIN VERIFY SCRIPT-
git grep -l "policy\/fees\.h" | xargs sed -i "s/policy\/fees.h/policy\/fees\/block_policy_estimator.h/g"
-END VERIFY SCRIPT-
2025-11-12 17:40:47 +00:00
merge-script
48d4b936e0 Merge bitcoin/bitcoin#33511: init: Fix Ctrl-C shutdown hangs during wait calls
c25a5e670b init: Signal m_tip_block_cv on Ctrl-C (Ryan Ofsky)
6a29f79006 test: Test SIGTERM handling during waitforblockheight call (Ryan Ofsky)

Pull request description:

  Signal `m_tip_block_cv` when Ctrl-C is pressed or `SIGTERM` is received, the same way it is currently signaled when the `stop` RPC is called. This lets RPC calls like `waitforblockheight` and IPC calls like `waitTipChanged` be interrupted, instead of waiting for their original timeouts and delaying shutdown.

  This issue was reported by plebhash in #33463. These hangs have been present since #30409. A similar bug was also fixed previously in Qt in #18452 and this PR simplifies that fix.

ACKs for top commit:
  Sjors:
    tACK c25a5e670b
  TheCharlatan:
    ACK c25a5e670b
  enirox001:
    Concept ACK c25a5e6

Tree-SHA512: 320aaa74fd308e826521c48c9a8aca4bd5f5530064cda2303d251d8e93e50c474bcd0db760ce04921928e73abefe4847aff797ac9ca7c89e74e5051bbed061cd
2025-11-12 10:16:29 -05:00
merge-script
3c3c6adb72 Merge bitcoin/bitcoin#33745: mining: check witness commitment in submitBlock
6eaa00fe20 test: clarify submitBlock() mutates the template (Sjors Provoost)
862bd43283 mining: ensure witness commitment check in submitBlock (Sjors Provoost)
00d1b6ef4b doc: clarify UpdateUncommittedBlockStructures (Sjors Provoost)

Pull request description:

  When an IPC client requests a new block template via the Mining interface, we hold on to its `CBlock`. That way when they call `submitSolution()` we can modify it in place, rather than having to reconstruct the full block like the `submitblock` RPC does.

  Before this commit however we forgot to invalidate `m_checked_witness_commitment`, which we should since the client brings a new coinbase.

  This would cause us to accept an invalid chaintip.

  Fix this and add a test to confirm that we now reject such a block. As a sanity check, we add a second node to the test and confirm that will accept our mined block.

  As first noticed in #33374 the IPC code takes the coinbase as provided, unlike the `submitblock` RPC which calls `UpdateUncommittedBlockStructures()` and adds witness commitment to the coinbase if it was missing.

  Although that could have been an alternative fix, we instead document that IPC clients are expected to provide the full coinbase including witness commitment.

  Patch to produce the original issue:

  ```diff
  diff --git a/src/node/miner.cpp b/src/node/miner.cpp
  index b988e28a3f..28e9048a4d 100644
  --- a/src/node/miner.cpp
  +++ b/src/node/miner.cpp
  @@ -450,15 +450,10 @@ void AddMerkleRootAndCoinbase(CBlock& block, CTransactionRef coinbase, uint32_t
       }
       block.nVersion = version;
       block.nTime = timestamp;
       block.nNonce = nonce;
       block.hashMerkleRoot = BlockMerkleRoot(block);
  -
  -    // Reset cached checks
  -    block.m_checked_witness_commitment = false;
  -    block.m_checked_merkle_root = false;
  -    block.fChecked = false;
   }

   std::unique_ptr<CBlockTemplate> WaitAndCreateNewBlock(ChainstateManager& chainman,
                                                         KernelNotifications& kernel_notifications,
                                                         CTxMemPool* mempool,
  diff --git a/test/functional/interface_ipc.py b/test/functional/interface_ipc.py
  index cce56e3294..bf1b7048ab 100755
  --- a/test/functional/interface_ipc.py
  +++ b/test/functional/interface_ipc.py
  @@ -216,22 +216,22 @@ class IPCInterfaceTest(BitcoinTestFramework):
               assert_equal(res.result, True)

               # The remote template block will be mutated, capture the original:
               remote_block_before = await self.parse_and_deserialize_block(template, ctx)

  -            self.log.debug("Submitted coinbase must include witness")
  +            self.log.debug("Submitted coinbase with missing witness is accepted")
               assert_not_equal(coinbase.serialize_without_witness().hex(), coinbase.serialize().hex())
               res = await template.result.submitSolution(ctx, block.nVersion, block.nTime, block.nNonce, coinbase.serialize_without_witness())
  -            assert_equal(res.result, False)
  +            assert_equal(res.result, True)

               self.log.debug("Even a rejected submitBlock() mutates the template's block")
               # Can be used by clients to download and inspect the (rejected)
               # reconstructed block.
               remote_block_after = await self.parse_and_deserialize_block(template, ctx)
               assert_not_equal(remote_block_before.serialize().hex(), remote_block_after.serialize().hex())

  -            self.log.debug("Submit again, with the witness")
  +            self.log.debug("Submit again, with the witness - does not replace the invalid block")
               res = await template.result.submitSolution(ctx, block.nVersion, block.nTime, block.nNonce, coinbase.serialize())
               assert_equal(res.result, True)

               self.log.debug("Block should propagate")
               assert_equal(self.nodes[1].getchaintips()[0]["height"], current_block_height + 1)
  ```

ACKs for top commit:
  ryanofsky:
    Code review ACK 6eaa00fe20. Just documentation updates and test clarifications since last review, also splitting up a commit.
  TheCharlatan:
    Re-ACK 6eaa00fe20
  ismaelsadeeq:
    Code review and tested ACK   6eaa00fe20

Tree-SHA512: 3a6280345b0290fe8300ebc63c13ad4058d24ceb35b7d7a784b974d5f04f420860ac03a9bf2fc6a799ef3fc55552ce033e879fa369298f976b9a01d72bd55d9e
2025-11-12 10:03:48 -05:00
merge-script
3789215f73 Merge bitcoin/bitcoin#33724: refactor: Return uint64_t from GetSerializeSize
fa6c0bedd3 refactor: Return uint64_t from GetSerializeSize (MarcoFalke)
fad0c8680e refactor: Use uint64_t over size_t for serialized-size values (MarcoFalke)
fa4f388fc9 refactor: Use fixed size ints over (un)signed ints for serialized values (MarcoFalke)
fa01f38e53 move-only: Move CBlockFileInfo to kernel namespace (MarcoFalke)
fa2bbc9e4c refactor: [rpc] Remove cast when reporting serialized size (MarcoFalke)
fa364af89b test: Remove outdated comment (MarcoFalke)

Pull request description:

  Consensus code should arrive at the same conclusion, regardless of the architecture it runs on. Using architecture-specific types such as `size_t` can lead to issues, such as the low-severity [CVE-2025-46597](https://bitcoincore.org/en/2025/10/24/disclose-cve-2025-46597/).

  The CVE was already worked around, but it may be good to still fix the underlying issue.

  Fixes https://github.com/bitcoin/bitcoin/issues/33709 with a few refactors to use explicit fixed-sized integer types in serialization-size related code and concluding with a refactor to return `uint64_t` from `GetSerializeSize`. The refactors should not change any behavior, because the CVE was already worked around.

ACKs for top commit:
  Crypt-iQ:
    crACK fa6c0bedd3
  l0rinc:
    ACK fa6c0bedd3
  laanwj:
    Code review ACK fa6c0bedd3

Tree-SHA512: f45057bd86fb46011e4cb3edf0dc607057d72ed869fd6ad636562111ae80fea233b2fc45c34b02256331028359a9c3f4fa73e9b882b225bdc089d00becd0195e
2025-11-12 09:48:10 -05:00
merge-script
47618446a0 Merge bitcoin/bitcoin#33853: kernel: Allow null arguments for serialized data
a3ac59a431 ci: Enable experimental kernel stuff in ASan task (MarcoFalke)
5b89956eeb kernel: Allow null arguments for serialized data (TheCharlatan)

Pull request description:

  An empty span constructed from an empty vector may have a null data pointer depending on the implementation. Remove the BITCOINKERNEL_ARG_NONNULL requirement for these arguments and instead handle such null arguments in the implementation.

  Also cherry-picked from #33845 to show that CI task passing now.

ACKs for top commit:
  yuvicc:
    Code review ACK a3ac59a431
  maflcko:
    review ACK a3ac59a431 🥈
  laanwj:
    code review ACK a3ac59a431

Tree-SHA512: 629e463796f2f057df5be8e8981a45751c578ed0021be731c1d57fe849a539fe38b0a445914b0fc48f32f0408ad6d566984bd7f3a68797fcfdf1c6889e316a08
2025-11-12 14:16:12 +00:00
merge-script
d0da953773 Merge bitcoin/bitcoin#32482: build: add -W*-whitespace
40dcbf580d build: add -Wtrailing-whitespace=any (fanquake)
d7659cd7e6 build: add -Wleading-whitespace=spaces (fanquake)
d86650220a cmake: Disable `-Wtrailing-whitespace` warnings for RCC-generated files (Hennadii Stepanov)
aabc5ca6ed cmake: Switch from AUTORCC to `qt6_add_resources` (Hennadii Stepanov)
25ae14c339 subprocess: replace tab with space (fanquake)
0c2b9dadd5 scripted-diff: remove whitespace in sha256_sse4.cpp (fanquake)
4da084fbc9 scripted-diff: change whitespace to spaces in univalue (fanquake)
e6caf150b3 ci: add moreutils to lint job (fanquake)

Pull request description:

  GCC 15 now has options to turn leading & trailing whitespace into compile failures: https://gcc.gnu.org/gcc-15/changes.html#c-family. Fix the few cases of leading tabs, and trailing whitespace, and then enable `-Wleading-whitespace` and `-Wtrailing-whitespace`.

  We currently get PRs that are opened with various whitespace, i.e #33822, so turning that into compile-time failure where possible, seems useful, to avoid a CI roundtrip.

ACKs for top commit:
  ajtowns:
    utACK 40dcbf580d
  hebasto:
    re-ACK 40dcbf580d.

Tree-SHA512: a128001ab2abb41cd6d249dcf46be4167ebd608d6b0f1452212a3ec9a383747bea623ab0382ec7bc0ac7a232a47cca5174e1cd73d4eda6751aa3cb2365ad2ede
2025-11-12 10:53:42 +00:00
merge-script
f450761f83 Merge bitcoin/bitcoin#33842: build: Bump g++ minimum supported version to 12
fa9f29a4a7 doc: Recommend latest Debian stable or Ubuntu LTS (MarcoFalke)
fa1711ee0d doc: Add GCC-12 min release notes (MarcoFalke)
faa8be75c9 ci: Enable experimental kernel stuff in G++-12 task (previous releases) (MarcoFalke)
fabce97b30 test: Remove gccbug_90348 test case (MarcoFalke)
fa3854e432 test: Remove unused fs::create_directories test (MarcoFalke)
fa9dacdbde util: [refactor] Remove unused create_directories workaround (MarcoFalke)
fa807f78ae build: Bump g++ minimum supported version to 12 (MarcoFalke)

Pull request description:

  All supported operating systems that previously came with at least g++-11, also come with at least g++-12, so bumping the minimum should be fine.

  For reference:

  * https://packages.ubuntu.com/jammy/g++-12
  * https://packages.ubuntu.com/noble/g++ (g++-13)
  * https://packages.debian.org/bookworm/g++ (g++-12)
  * FreeBSD Ports ship a recent GCC
  * RHEL-based 8, and 9 ship with g++-14 via appstream (`dnf install gcc-toolset-14` -> `/opt/rh/gcc-toolset-14/`)
  * RHEL-based 10 ships with g++ (14 by default)
  * OpenSuse Leap and Tumbleweed ship with g++ 15 https://software.opensuse.org/package/gcc15-c++

  Obviously, downloading pre-compiled releases or compiling previous release branches is unaffected by this change.

ACKs for top commit:
  janb84:
    re-ACK fa9f29a4a7
  TheCharlatan:
    Re-ACK fa9f29a4a7
  hebasto:
    ACK fa9f29a4a7.

Tree-SHA512: ce14ecf78ccfe4f221dcbc9147dcfc00c0512b23a6fcda5ba71b62b4f5d39a5139f083d035113f189bfbd396d485e1ebc626a9a16b6fa0b74fd95aed2041c841
2025-11-12 10:49:53 +00:00
MarcoFalke
fabce97b30 test: Remove gccbug_90348 test case
The test case no longer detects this specific issue for GCC versions
12.1+, as explained in the
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348 thread and in this
compiler-explorer playground:
https://godbolt.org/z/Y48osrjM8

So remove the test case and update the -fstack-reuse=none cmake
docstring with the underlying affected GCC versions, and the bug URL.
2025-11-11 22:44:01 +01:00
MarcoFalke
fa3854e432 test: Remove unused fs::create_directories test
The test was added in commit ddb75c2e87.
After the create_directories wrapper removal, the test is redundant with
the unit test in the upstream stdlib. Also, there is a Bitcoin Core
functional test that covers this behavior in
test/functional/feature_dirsymlinks.py

So remove this unit test.

Finally, I could not find a real system that still ships a buggy stdlib
(v11.2) in their package manager. A stand-alone test is also available
in compiler-explorer under https://godbolt.org/z/aeMKraYrT.
2025-11-11 22:28:27 +01:00
MarcoFalke
fa9dacdbde util: [refactor] Remove unused create_directories workaround
This was added in commit 1f46b6e46e, but
is no longer needed after g++-12 is the minimum required.
2025-11-11 22:28:09 +01:00
merge-script
1c3d5c8ffd Merge bitcoin/bitcoin#33840: test: [refactor] Use reference over ptr to chainman
7a4901c902 test, refactor: Fix `-Warray-bounds` warning (Hennadii Stepanov)
faf2759c8c test: [refactor] Use reference over ptr to chainman (MarcoFalke)

Pull request description:

  Just some minor test-only refactor commits to fix GCC false positive warnings, along with making the test code easier to read and understand:

  * First change requested in https://github.com/bitcoin/bitcoin/pull/33785#discussion_r2510727269
  * Second change requested in commit 3b135a8fc4451c93b3ea50b3f4621e0d19f35daf

  Those changes are required in a bunch of pulls touching the CI system, so merging them allows to drop them in all pulls.

ACKs for top commit:
  l0rinc:
    ACK 7a4901c902
  hebasto:
    ACK 7a4901c902, I have reviewed the code and it looks OK.

Tree-SHA512: 64dca52ec7b25078bf489e2d8b43e449f4968fbac14a09c66a60cdc75b513588403665f248368820694a6f72c4f7f465589d9306355239cffe35c38111929eff
2025-11-11 13:50:57 +00:00
TheCharlatan
5b89956eeb kernel: Allow null arguments for serialized data
An empty span constructed from an empty vector may have a null data
pointer depending on the implementation. Remove the
BITCOINKERNEL_ARG_NONNULL requirement for these arguments and instead
handle such null arguments in the implementation.
2025-11-11 12:35:15 +01:00
Hennadii Stepanov
d86650220a cmake: Disable -Wtrailing-whitespace warnings for RCC-generated files
See: https://bugreports.qt.io/browse/QTBUG-141858.
2025-11-11 11:12:50 +00:00
Hennadii Stepanov
aabc5ca6ed cmake: Switch from AUTORCC to qt6_add_resources
This change provides finer control over the compilation of RCC-generated
files.
2025-11-11 11:12:50 +00:00
fanquake
25ae14c339 subprocess: replace tab with space
See: https://github.com/arun11299/cpp-subprocess/pull/121.
2025-11-11 11:12:50 +00:00
fanquake
0c2b9dadd5 scripted-diff: remove whitespace in sha256_sse4.cpp
-BEGIN VERIFY SCRIPT-
expand -t4 src/crypto/sha256_sse4.cpp | sed 's/  *$//' | sponge src/crypto/sha256_sse4.cpp
-END VERIFY SCRIPT-

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2025-11-11 11:12:50 +00:00
fanquake
4da084fbc9 scripted-diff: change whitespace to spaces in univalue
-BEGIN VERIFY SCRIPT-
sed -i 's/^\t/    /' src/univalue/include/univalue_escapes.h
-END VERIFY SCRIPT-

Co-authored-by: Anthony Towns <aj@erisian.com.au>
2025-11-11 11:12:50 +00:00
merge-script
b354d1ce5c Merge bitcoin/bitcoin#33820: kernel: trim Chain interface
66978a1a95 kernel: remove btck_chain_get_tip (stickies-v)
4dd7e6dc48 kernel: remove btck_chain_get_genesis (stickies-v)

Pull request description:

  Removes `btck_chain_get_genesis` and `btck_chain_get_tip`.

  They are trivially replaced with `btck_chain_get_by_height` (as indicated in the updated `bitcoinkernel_wrapper.h`), so I think it makes sense to trim the interface.

  For `btck_chain_get_tip`: on `master` we don't provide any guarantees that the returned block index still corresponds to the actual tip, so the extra call doesn't seem like a regression to me.

ACKs for top commit:
  TheCharlatan:
    ACK 66978a1a95
  janb84:
    ACK 66978a1a95

Tree-SHA512: f583fbb7f2e3f8f23afb57732b2cbe9e1d550bfc43c9a2619895ee30c27f5f3c5cd9e4ecb7e05b1f6ab9e11c368596ec9b733d67e06cfafb12326d88e8e4dd7d
2025-11-11 09:52:26 +00:00
Ava Chow
a4e96cae7d Merge bitcoin/bitcoin#33042: refactor: inline constant return values from dbwrapper write methods
743abbcbde refactor: inline constant return value of `BlockTreeDB::WriteBatchSync` and `BlockManager::WriteBlockIndexDB` and `BlockTreeDB::WriteFlag` (Lőrinc)
e030240e90 refactor: inline constant return value of `CDBWrapper::Erase` and `BlockTreeDB::WriteReindexing` (Lőrinc)
cdab9480e9 refactor: inline constant return value of `CDBWrapper::Write` (Lőrinc)
d1847cf5b5 refactor: inline constant return value of `TxIndex::DB::WriteTxs` (Lőrinc)
50b63a5698 refactor: inline constant return value of `CDBWrapper::WriteBatch` (Lőrinc)

Pull request description:

  Related to https://github.com/bitcoin/bitcoin/pull/31144#discussion_r2223587480

  ### Summary
  `WriteBatch` always returns `true` - the errors are handled by throwing `dbwrapper_error` instead.

  ### Context
  This boolean return value of the `Write` methods is confusing because it's inconsistent with `CDBWrapper::Read`, which catches exceptions and returns a boolean to indicate success/failure. It's bad that `Read` returns and `Write` throws - but it's a lot worse that `Write` advertises a return value when it actually communicates errors through exceptions.

  ### Solution
  This PR removes the constant return values from write methods and inlines `true` at their call sites. Many upstream methods had boolean return values only because they were propagating these constants - those have been cleaned up as well.

  Methods that returned a constant `true` value that now return `void`:
  - `CDBWrapper::WriteBatch`, `CDBWrapper::Write`, `CDBWrapper::Erase`
  - `TxIndex::DB::WriteTxs`
  - `BlockTreeDB::WriteReindexing`, `BlockTreeDB::WriteBatchSync`, `BlockTreeDB::WriteFlag`
  - `BlockManager::WriteBlockIndexDB`

  ### Note
  `CCoinsView::BatchWrite` (and transitively `CCoinsViewCache::Flush` & `CCoinsViewCache::Sync`) were intentionally not changed here. While all implementations return `true`, the base `CCoinsView::BatchWrite` returns `false`. Changing this would cause `coins_view` tests to fail with:
  > terminating due to uncaught exception of type std::logic_error: Not all unspent flagged entries were cleared

  We can fix that in a follow-up PR.

ACKs for top commit:
  achow101:
    ACK 743abbcbde
  janb84:
    ACK 743abbcbde
  TheCharlatan:
    ACK 743abbcbde
  sipa:
    ACK 743abbcbde

Tree-SHA512: b2a550bff066216f1958d2dd9a7ef6a9949de518cc636f8ab9c670e0b7a330c1eb8c838e458a8629acb8ac980cea6616955cd84436a7b8ab9096f6d648073b1e
2025-11-10 09:15:24 -08:00
Ava Chow
8c2710b041 Merge bitcoin/bitcoin#32517: rpc: add "ischange: true" to decoded tx outputs in wallet gettransaction response
060bb55508 rpc: add decoded tx details to gettransaction with extra wallet fields (Matthew Zipkin)
ad1c3bdba5 [move only] move DecodeTxDoc() to a common util file for sharing (Matthew Zipkin)
d633db5416 rpc: add "ischange: true" in wallet gettransaction decoded tx output (Matthew Zipkin)

Pull request description:

  This change is motivated by external RBF clients like https://github.com/CardCoins/additive-rbf-batcher/. It saves the user a redundant re-looping of tx outputs, calling `getaddressinfo` on each one, looking for the change output in order to adjust the fee.

  The field `"ischange"` only appears when `gettransaction` is called on a wallet, and is either `true` or not present at all. I chose not to include `ischange: false` because it is confusing to see that on *received* transactions.

  Example of the new field:

  ```
      "vout": [
        {
          "value": 1.00000000,
          "n": 0,
          "scriptPubKey": {
            "asm": "0 5483235e05c76273b3b50af62519738781aff021",
            "desc": "addr(bcrt1q2jpjxhs9ca388va4ptmz2xtns7q6lupppkw7wu)#d42g84j6",
            "hex": "00145483235e05c76273b3b50af62519738781aff021",
            "address": "bcrt1q2jpjxhs9ca388va4ptmz2xtns7q6lupppkw7wu",
            "type": "witness_v0_keyhash"
          }
        },
        {
          "value": 198.99859000,
          "n": 1,
          "scriptPubKey": {
            "asm": "0 870ab1ab58632b05a417d5295f4038500e407592",
            "desc": "addr(bcrt1qsu9tr26cvv4stfqh65547spc2q8yqavj7fnlju)#tgapemkv",
            "hex": "0014870ab1ab58632b05a417d5295f4038500e407592",
            "address": "bcrt1qsu9tr26cvv4stfqh65547spc2q8yqavj7fnlju",
            "type": "witness_v0_keyhash"
          },
          "ischange": true
        }
      ]

  ```

ACKs for top commit:
  furszy:
    ACK [060bb55](060bb55508)
  maflcko:
    review ACK 060bb55508 🌛
  achow101:
    ACK 060bb55508
  rkrux:
    lgtm ACK 060bb55508

Tree-SHA512: aae4854d2bb4e9a7bc1152691ea90e594e8da8a63c9c7fda72a504fb6a7e54ae274ed5fa98d35d270e0829cc8f8d2fd35a5fc9735c252a10aa42cc22828930e7
2025-11-10 08:58:34 -08:00
Ava Chow
1fe851a478 Merge bitcoin/bitcoin#32180: p2p: Advance pindexLastCommonBlock early after connecting blocks
01cc20f330 test: improve coverage for a resolved stalling situation (Martin Zumsande)
9af6daf07e test: remove magic number when checking for blocks that have arrived (Martin Zumsande)
3069d66dca p2p: During block download, adjust pindexLastCommonBlock better (Martin Zumsande)

Pull request description:

  As described in #32179, `pindexLastCommonBlock` is updated later than necessary
  in master.
  In case of a linear chain with no forks, it can be moved forward at the beginning of
  `FindNextBlocksToDownload`, so that the updated value can be used to better estimate `nWindowEnd`.
  This helps the node to request all blocks from peers within the correct 1024-block-window and avoids peers being incorrectly marked as stallers.

  I also changed `p2p_ibd_stalling.py` to cover the situation after a resolved situation, making sure that no additional peers are marked for stalling.

  Fixes #32179

ACKs for top commit:
  Crypt-iQ:
    crACK 01cc20f330
  stringintech:
    re-ACK 01cc20f
  achow101:
    ACK 01cc20f330
  sipa:
    utACK 01cc20f330

Tree-SHA512: a97f7a7ef5ded538ee35576e04b3fbcdd46a6d0189c7ba3abacc6e0d81e800aac5b0c2d2565d0462ef6fd4acc751989f577fd6adfd450171a7d6ab26f437df32
2025-11-10 08:48:49 -08:00
Ava Chow
5f0303b93f Merge bitcoin/bitcoin#33443: log: reduce excessive "rolling back/forward" messages during block replay
1fc7a81f1f log: reduce excessive messages during block replay (Lőrinc)

Pull request description:

  ### Summary
  After an incomplete reindex the blocks will need to be replayed.
  This results in excessive `Rolling back` and `Rolling forward` messages which quickly triggers the recently introduced log rate limiter.

  Change the logging strategy to:
  - Add single `LogInfo` messages showing the full range being replayed for both rollback and roll forward;
  - Log progress at `LogInfo` level only every 10,000 blocks to track the long operations.

  ### Reproducer:
  * Start a normal ibd, stop after some progress
  * Do a reindex, stop before it finishes
  * Restart the node normally without specifying the reindex parameter
  It should start rolling the blocks forward.

  Before this change the excessive logging would show:
  ```
  [*] Rolling forward 000000002f4f55aecfccc911076dc3f73ac0288c83dc1d79db0a026441031d40 (46245)
  [*] Rolling forward 0000000017ffcf34c8eac010c529670ba6745ea59cf1edf7b820928e3b40acf6 (46246)
  ```

  After the change it shows:
  ```
  Replaying blocks
  Rolling forward to 00000000000000001034012d7e4facaf16ca747ea94b8ea66743086cfe298ef8 (326223 to 340991)
  Rolling forward 00000000000000000faabab19f17c0178c754dbed023e6c871dcaf74159c5f02 (330000)
  Rolling forward 00000000000000000d9b2508615d569e18f00c034d71474fc44a43af8d4a5003 (340000)
  ...
  Rolled forward to 00000000000000001034012d7e4facaf16ca747ea94b8ea66743086cfe298ef8
  ```
  (similarly to rolling back)

ACKs for top commit:
  Crypt-iQ:
    crACK 1fc7a81f1f
  stickies-v:
    ACK 1fc7a81f1f
  achow101:
    ACK 1fc7a81f1f
  vasild:
    ACK 1fc7a81f1f
  hodlinator:
    Concept ACK 1fc7a81f1f

Tree-SHA512: 44ed1da8336de5a3d937e11a13e6f1789064e23eb70640a1c406fbb0074255344268f6eb6b06f036ca8d22bfeb4bdea319c3085a2139d848f6d36a4f8352b76a
2025-11-10 08:27:40 -08:00