Commit Graph

50182 Commits

Author SHA1 Message Date
w0xlt
bbe21ac29f doc: document REST cache-control defaults
Co-authored-by: willcl-ark <will@256k1.dev>
2026-08-05 16:40:59 -07:00
w0xlt
862a179556 http: add no-store to dispatcher-generated error responses
REST error responses normally go through RESTERR(), which sets
Cache-Control: no-store. Some errors are returned directly by the
generic HTTP dispatcher and bypass RESTERR(), including unmatched
paths, queue exhaustion, handler exceptions, and shutdown rejection.

Use a shared reply helper to set no-store on dispatcher-generated
error responses. This avoids caching transient errors and keeps the
behavior consistent across REST and RPC requests.

Test the work-queue rejection path by checking that its HTTP 503
response includes the header.
2026-08-05 16:38:06 -07:00
Hennadii Stepanov
f32685315c doc: Install pkgconf to find capnproto on NetBSD
On NetBSD, `pkgconf` is necessary to find `capnproto`. For example, see
https://github.com/bitcoin-core/libmultiprocess/pull/325.
2026-08-05 22:48:03 +01:00
Hennadii Stepanov
5964c7229f doc: Switch pkg-config package to modern pkgconf on NetBSD 2026-08-05 21:53:05 +01:00
Hennadii Stepanov
9b85c9814d doc: Drop GCC upgrade instructions for NetBSD
NetBSD 11.0, the latest release, ships GCC 12.5.0 as the base
system compiler, which meets the minimum version requirement in
`doc/dependencies.md`.
2026-08-05 21:48:03 +01:00
w0xlt
ea59f17220 test: cover v0.14.3 wallet migration
Test migratewallet on v0.14.3 non-HD and single-chain HD wallets in both
unencrypted and encrypted configurations.

Verify balances, transaction history, address ownership, descriptor
structure, encryption enforcement, backup creation, and the absence of
rescans or unexpected auxiliary wallets.

Run the test with an ASCII-only temporary directory in the Windows
cross-build job because the v0.14.3 binary cannot handle the Unicode
runner path.
2026-08-05 12:50:22 -07:00
w0xlt
18b8afd093 test: support v0.14.x in dumb_sync_blocks
The getblock RPC used a boolean verbose argument before v0.15. Use the
legacy named argument so the helper can synchronize blocks from v0.14.x
nodes while remaining compatible with current nodes.
2026-08-05 12:49:53 -07:00
MarcoFalke
faec059dfe refactor: Add uint256::operator<=>()
There is already a non-standard and internally used Compare() function,
and an standard operator<().

Also, there is already transaction_identifier::operator<=>().

It seems more consistent to remove the internal Compare() and have a
single standard C++20 <=> operator.
2026-08-05 21:41:49 +02:00
Hao Xu
b9d573e4a9 fees: Return false for incompatible fee estimates
policy_estimator_io deliberately reuses a CBlockPolicyEstimator because
constructing one for every fuzz input severely reduces throughput.
However, Read() returns true for an incompatible old fee estimates file
without replacing the estimator state. The target then calls Write()
with state loaded by a previous input, making coverage depend on corpus
order.

Return false for incompatible files so the target skips Write() when no
state was loaded. This keeps the estimator reuse optimization instead of
resetting the expensive object before every fuzz input.

For the in-tree production caller, incompatible files remain non-fatal
and the estimator still starts from its default state. Read() now
reports failure, so startup emits one additional non-fatal warning.
Node startup and estimator state are unchanged, as is RPC behavior.

Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
2026-08-05 22:16:46 +08:00
Musa Haruna
a3ebf8ab60 rpc: fix mempool entry vsize docs 2026-08-05 15:11:25 +01: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
MarcoFalke
fa6df14c23 refactor: uint256::operator==() = default
This is standard C++20, and may allow a compiler to optimize a bit more.
2026-08-05 13:46:44 +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
Pol Espinasa
6ed7e05e20 gui: fix add .dat file extension automatically when exporting watchonly 2026-08-05 10:03:54 +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
MarcoFalke
fab74a0e92 refactor: Use C++14 digit separator for large int literals
Suggested by l0rinc.

Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2026-08-05 08:35:41 +02:00
MarcoFalke
fae759be79 scripted-diff: Use inline constexpr over plain constexpr
Both are identical since C++17 and this refactor shouldn't change any
behavior. The benefits are consistency and to be explicit, to avoid
confusion with the C++11/14 constexpr.

Co-Authored-By: l0rinc <pap.lorinc@gmail.com>

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's/^constexpr \S+ \w+(\[\])? ?[={]/inline &/' $( \
     git grep -l '^constexpr ' -- \
       '*.h' \
       ':(exclude)src/minisketch' \
 )
-END VERIFY SCRIPT-
2026-08-05 08:35:30 +02:00
MarcoFalke
fa74f58a26 scripted-diff: Use inline const over (static) const
Both are fine and this refactor shouldn't change any behavior.

However, inline const will ensure each symbol has a single address
across all TU, making the release binary smaller.

-BEGIN VERIFY SCRIPT-

 # Replace `static const`
 sed -i "s/^static const /inline const /" $( \
   git grep -l "^static const " -- \
     '*.h' \
     ':(exclude)src/leveldb' \
     ':(exclude)src/secp256k1' \
 )

 # Replace plain `const`
 sed -i --regexp-extended 's/^const (\S+ \w+(\[\])? ?[={])/inline &/' $( \
   git grep -l '^const ' -- \
     '*.h' \
     ':(exclude)src/leveldb' \
     ':(exclude)src/secp256k1' \
   )

-END VERIFY SCRIPT-
2026-08-05 08:35:04 +02:00
MarcoFalke
fab1a62c87 refactor: Use inline constexpr for string literals in headers
This is needed for the next scripted-diff commit, which would otherwise
turn the const from `static const char*` into `inline const char*`.
2026-08-05 08:34:58 +02:00
MarcoFalke
fa08bbed8d contrib: Adjust generate-seeds.py to write inline constexpr
Otherwise, the changes in the previous commit will be reverted when this
script regenerates the header.

Co-Authored-By: l0rinc <pap.lorinc@gmail.com>
2026-08-05 08:34:38 +02:00
MarcoFalke
fad753611b scripted-diff: Use inline constexpr over (static) const
Both are fine and this refactor shouldn't change any behavior.

However, inline constexpr will ensure each symbol has a single address
across all TU, making the release binary smaller.

Note, a follow-up commit will deal with string literals (const char*)
and other static const, which can not be constexpr (e.g. std::vector).

-BEGIN VERIFY SCRIPT-
 # Limit to types that can be constexpr
 type='bool|CAmount|size_t|((signed|unsigned) )?int|u?int[0-9]+_t|std::array|DatabaseFormat|CFeeRate|std::streamsize'
 sed -i --regexp-extended "s/^(static )?const (${type})\>/inline constexpr \2/" $( \
   git grep -l --extended-regexp "^(static )?const " -- \
     '*.h' \
     ':(exclude)src/leveldb' \
     ':(exclude)src/secp256k1' \
 )
-END VERIFY SCRIPT-
2026-08-05 08:34:13 +02:00
MarcoFalke
faedb52583 refactor: Make CFeeRate(integral) ctor constexpr
This is required for the next commit.

Also, in a test, use `inline constexpr` for an `auto` type, which is
also needed for the next commit, which hard-codes a list of types for
conversion.
2026-08-05 08:34:13 +02:00
MarcoFalke
5555d5dcb5 scripted-diff: Use inline constexpr over static constexpr
Both are fine and this refactor shouldn't change any behavior.

However, inline constexpr will ensure each symbol has a single address
across all TU, making the release binary smaller.

Review note: In theory the script may also cover functions, but they
were handled in the prior commit, to remove the redundant inline for
them.

-BEGIN VERIFY SCRIPT-
 sed --regexp-extended -i 's/^(static constexpr|constexpr static)\>/inline constexpr/g' $( \
   git grep --extended-regexp -l '^(static constexpr|constexpr static)' -- \
     '*.h' \
     ':(exclude)src/crc32c' \
     ':(exclude)src/ipc/libmultiprocess' \
     ':(exclude)src/minisketch' \
 )
-END VERIFY SCRIPT-
2026-08-05 08:32:32 +02:00
MarcoFalke
fa6e1a1e85 refactor: Remove static from constexpr functions in headers
Those functions have no need to be static in every TU. Also, static
somewhat contradicts and overwrites the inline keyword.

So remove the static, and just keep constexpr (which implies inline).
2026-08-05 08:31:22 +02:00
w0xlt
acf45c44c0 rest: add Cache-Control headers to REST responses
Add Cache-Control headers to REST API responses so standard HTTP caches
can cache safe responses by default without per-deployment proxy rules.

Cache policy summary:
- Immutable: /block binary and hex responses, /blockpart, /blockfilter,
  and /spenttxouts in all formats, and blockhash-specific
  /deploymentinfo/<blockhash>.json responses return
  "public, immutable, max-age=86400".
- No-store: /block and /block/notxdetails JSON, /tx, /headers,
  /blockfilterheaders, /blockhashbyheight, /chaininfo, /mempool,
  /getutxos, tip-relative /deploymentinfo.json, and RESTERR error
  responses return "no-store".

Mutable responses are not stored because REST does not provide cache
validators such as ETag or Last-Modified.

Co-authored-by: stickies-v <stickies-v@protonmail.com>
2026-08-04 15:37:40 -07: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
David Gumberg
f280f5eb47 wallet: rpc: deprecate removeprunedfunds
This RPC has no helpful use while being both dangerous and a maintenance
burden.

Despite what the name says, it allows the deletion of arbitrary
transactions, and `importprunedfunds` does not allow the importing of
transactions not belonging to the user, and `listtransactions` does not
list transactions not belonging to the wallet, so this RPC can only be
used to delete transactions actually belonging to the wallet, and in the
unlikely event that transactions not belonging to the wallet are
present, they cause no harm except for occupying a few bytes on the
users disk.
2026-08-04 14:23:42 -04:00
Henry Romp
4e8c4bc794 test: classify SOCKS5 peers via getpeerinfo addrbind
The SOCKS5 destinations factory classified connections by scanning
debug.log for connection attempts to the requested address and port.
The destination is not unique per connection, so the log cannot
identify which attempt is being served: first-match returned a stale
type when an automatic connection reused an address private broadcast
had already used, and latest-match still breaks if two attempts to the
same address overlap.

Match the exact connection instead: the source addr:port of the
proxy's client socket equals the node's addrbind for that peer, so
looking it up in getpeerinfo identifies precisely the connection being
served and returns its connection_type. This also stops treating
debug.log contents as a stable interface.

Co-authored-by: Greg Sanders <gsanders87@gmail.com>
2026-08-04 13:50:33 -04: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