Commit Graph

50374 Commits

Author SHA1 Message Date
jeanpablo
2f6aa41d3d wallet: remove unused WalletDatabase::m_refcount
The counter is never incremented. Only the BDB implementation ever
maintained it, and that went away in 04a7a7a28c ("build, wallet, doc:
Remove BDB"). `AddRef()` and `RemoveRef()`, which the comment above the
member describes as maintaining it, were removed in c0f3f3264f
("wallet: Remove unused db functions"), leaving the member behind.
2026-08-31 13:37:45 +01:00
jeanpablo
f64b3fa70f wallet: remove unused CHDChain keypool index members
`m_next_external_index` and `m_next_internal_index` are declared and
initialized and never read or written afterwards. Their last uses were
removed in 83af1a3cca ("wallet: Delete LegacySPKM"). Neither appears in
`SERIALIZE_METHODS` or in `SetNull`.
2026-08-31 13:37:45 +01:00
jeanpablo
4afc7bc40d wallet: remove unused COutput::ToString
No callers. It was used by `COutput::print()`, which was removed in
3802224110 ("Remove all other print() methods").
2026-08-31 13:37:45 +01:00
jeanpablo
a0e9aac428 wallet: remove unused DescriptorScriptPubKeyMan::AddDescriptorKey
The private method has no callers. It opened a `WalletBatch` and
forwarded to `AddDescriptorKeyWithDB`, which is still called from two
other places.

Its last caller, in `CWallet::AddWalletDescriptor`, was replaced in
aa4f7823aa ("wallet: include keys when constructing DescriptorSPKM
during import"), which builds the manager with `CreateFromMigration`
instead of adding the key afterwards.
2026-08-31 13:37:45 +01:00
merge-script
d2e24e951d Merge bitcoin/bitcoin#36054: test: add script_tests cases covering interpreter mutants
4a12773f26 test: cover DERSIG rejects a non-compound signature type (ViniciusCestarii)
86c7fb910d test: cover OP_16 does not count towards the opcode limit (ViniciusCestarii)
331bf79881 test: cover OP_WITHIN must pop all 3 elements (ViniciusCestarii)
3bb87bc61b test: cover OP_FROMALTSTACK must pop the altstack (ViniciusCestarii)

Pull request description:

  Kills some live mutants on interpreter.cpp that affect consensus found by https://bitcoincore.space. They are:

  <details>
  <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#3951">interpreter.cpp#3951</a>: <code>OP_FROMALTSTACK</code>: removed <code>popstack(altstack)</code></summary>

  ```diff
  diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
  index 98b16eca6b..68265d20b5 100644
  --- a/src/script/interpreter.cpp
  +++ b/src/script/interpreter.cpp
  @@ -698,7 +698,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
                       if (altstack.size() < 1)
                           return set_error(serror, SCRIPT_ERR_INVALID_ALTSTACK_OPERATION);
                       stack.push_back(altstacktop(-1));
  -                    popstack(altstack);
  +
                   }
                   break;
  ```

  </details>

  <details>
  <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#4084">interpreter.cpp#4084</a>: <code>OP_WITHIN</code>: removed one <code>popstack(stack)</code></summary>

  ```diff
  diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
  index 98b16eca6b..874cf5e1cf 100644
  --- a/src/script/interpreter.cpp
  +++ b/src/script/interpreter.cpp
  @@ -1018,7 +1018,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
                       CScriptNum bn2(stacktop(-2), fRequireMinimal);
                       CScriptNum bn3(stacktop(-1), fRequireMinimal);
                       bool fValue = (bn2 <= bn1 && bn1 < bn3);
  -                    popstack(stack);
  +
                       popstack(stack);
                       popstack(stack);
                       stack.push_back(fValue ? vchTrue : vchFalse);
  ```

  </details>

  <details>
  <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#3883">interpreter.cpp#3883</a>: opcode limit: <code>opcode > OP_16</code> → <code>opcode >= OP_16</code></summary>

  ```diff
  diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
  index 98b16eca6b..e985643606 100644
  --- a/src/script/interpreter.cpp
  +++ b/src/script/interpreter.cpp
  @@ -459,7 +459,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&

               if (sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0) {
                   // Note how OP_RESERVED does not count towards the opcode limit.
  -                if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) {
  +                if (opcode >= OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) {
                       return set_error(serror, SCRIPT_ERR_OP_COUNT);
                   }
               }
  ```

  </details>

  <details>
  <summary><a href="https://bitcoincore.space/src/script/interpreter.cpp#3808">interpreter.cpp#3808</a>: <code>IsValidSignatureEncoding</code>: compound type check returns <code>true</code></summary>

  ```diff
  diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
  index 98b16eca6b..b613a6ac19 100644
  --- a/src/script/interpreter.cpp
  +++ b/src/script/interpreter.cpp
  @@ -133,7 +133,7 @@ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) {
       if (sig.size() > 73) return false;

       // A signature is of type 0x30 (compound).
  -    if (sig[0] != 0x30) return false;
  +    if (sig[0] != 0x30) return true;

       // Make sure the length covers the entire signature.
       if (sig[1] != sig.size() - 3) return false;
  ```

  </details>

  Recommend reviewing per commit.

ACKs for top commit:
  instagibbs:
    ACK 4a12773f26
  brunoerg:
    ACK 4a12773f26
  jeanpablojp:
    tACK 4a12773f26

Tree-SHA512: 5f53c733d11cb5d645f420d90ab626f894ef0bb155d01b9de0cae502109b2eaa46c072797d08df115da7a8738f01f31212a207a4d0e6f782128beb37332cf46e
2026-08-31 10:01:42 +01:00
merge-script
ca7162cde5 Merge bitcoin/bitcoin#35868: rpc, wallet: fix invalid JSON in HelpExampleRpc curl examples
21d4e0ba75 rpc, wallet, test: fix invalid JSON in HelpExampleRpc curl examples (GuTS805)

Pull request description:

  Several `HelpExampleRpc` call sites reused CLI-style argument strings
  verbatim instead of valid JSON — missing commas, bare unquoted words, or
  single backslashes that are not valid JSON escapes. As a result the
  documented `curl` command for 14 RPCs (`getblockfrompeer`, `addnode`,
  `addconnection`, `sendmsgtopeer`, `restorewallet`, `getmempoolcluster`,
  `importmempool`, `getindexinfo`, `listlabels`, `unloadwallet`,
  `createwalletdescriptor`, `addhdkey`, `loadwallet`, `listunspent`) fails
  to parse as JSON if copy-pasted as-is. Also fixes a stray trailing quote
  in the `restorewallet` named-argument examples.

  This was previously raised in #31275, which sipa confirmed at runtime by
  adding a `UniValue::read` check, but that PR was closed unmerged. Since
  then two more examples broke the same way (`getmempoolcluster`,
  `addhdkey`), which is why this adds a permanent regression check to
  `rpc_help.py::dump_help()` instead of just fixing the current list.

  Fixes #35864.

ACKs for top commit:
  maflcko:
    review ACK 21d4e0ba75 🚝
  sedited:
    ACK 21d4e0ba75

Tree-SHA512: 2a8abc07d681b9dc81b8079a68421278da890049cea33a1561a48d53cbf919a30df588f559e9df94fa4a1ab7027f742f3b12c163afc25246a620340cb3522336
2026-08-29 10:33:22 +02:00
merge-script
d0e777baf5 Merge bitcoin/bitcoin#36111: rpc: bound memory for overlong Bech32 errors
7fcaccd9d0 bech32: bound overlength error locations (Lőrinc)

Pull request description:

  **Problem:** `validateaddress` reports likely error positions for invalid Bech32 inputs, including multiple useful positions for character and checksum errors.
  For an overlength input, `LocateErrors()` returns every position after the 90-character limit, which the RPC converts to a `UniValue` number before serializing the response.
  A near-limit authenticated request therefore creates about 33 million `int` values and 33 million `UniValue` objects.

  **Fix:** Return position 90 for an overlength input, which identifies where the single length violation begins.
  Character and checksum errors continue to return multiple useful positions when they can be determined.
  The tests now include an oversized example and pin the bounded result.

  **Reproducer:** Peak memory usage for a near-limit authenticated request:

  <details>
  <summary>Linux reproducer</summary>

  ```bash
  sed -i "/def test_validateaddress(self):/a\\
          self.nodes[0].validateaddress('bcrt1' + 'q' * (2**25 - 100))\\
          __import__('time').sleep(30)" test/functional/rpc_invalid_address_message.py
  cmake -B build && cmake --build build -j2
  build/test/functional/rpc_invalid_address_message.py >/dev/null 2>&1 &
  sleep 20 && awk '/VmHWM/' /proc/$(pgrep bitcoind)/status
  ```
  </details>

  ```text
  Before ████████████████████████ 5.69 GiB
  After  █░░░░░░░░░░░░░░░░░░░░░░░  240 MiB
  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 7fcaccd9d0
  sedited:
    ACK 7fcaccd9d0
  janb84:
    ACK 7fcaccd9d0

Tree-SHA512: 3d439774d394f081b8107f8131963f7aa23ed048b0d6d349a80f9b3481fefeef7b5ce239fbd33606ad1f4960e6bfd899f968c50febc70d38b2fe731c6049583f
2026-08-29 10:20:42 +02:00
Hennadii Stepanov
05e49b342f Merge bitcoin/bitcoin#36107: iwyu: Fix warnings in src/init and treat them as errors
1ad8641278 iwyu: Fix warnings in `src/init` 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:
    lgtm ACK 1ad8641278

Tree-SHA512: d63d2f5aeac487f01012b8802aff32eb53a8b5d53b8a6c8ece2a40b8c9603402f4f9a20c0918b3007ffaee1ed38a1009698e7b80be29c6a5175517e3279db952
2026-08-28 12:47:04 +01:00
Lőrinc
7fcaccd9d0 bech32: bound overlength error locations
`LocateErrors()` returns multiple useful positions for character and checksum errors, but an overlength string has one structural error.
Every character from the limit onward is outside the permitted address, so listing each position adds no diagnostic value.
`validateaddress` converts every returned position into a `UniValue` number before serializing the response.
An authenticated request below the HTTP body limit can therefore require several gigabytes of memory.

Return only the first position beyond the length limit, which identifies where the violation begins.
Character and checksum errors continue to report multiple useful positions when they can be determined, and the existing unit and functional tests cover both behaviors.
2026-08-27 23:49:18 -05:00
Hennadii Stepanov
ea7d459ac0 Merge bitcoin/bitcoin#36057: build: check for SetThreadDescription() at configure time
bed46bd16c build: check for SetThreadDescription() at configure time (ViniciusCestarii)

Pull request description:

  SetThreadDescription() is missing from mingw-w64 headers before 12.0.0, so the Windows cross-compile fails on distro toolchains, e.g. Ubuntu 24.04. Reported by hebasto in https://github.com/bitcoin/bitcoin/pull/35884#issuecomment-5379490348.

  Check for the symbol at configure time and guard its use with a new `HAVE_SETTHREADDESCRIPTION` guard, as cmake/introspection.cmake already does for other optional symbols. This avoids having to declare a minimum mingw-w64 version: toolchains that have the symbol get OS-level thread names, older ones build fine without them.

ACKs for top commit:
  fanquake:
    utACK bed46bd16c - could be reverted + docs updated post branch-off.
  hebasto:
    re-ACK bed46bd16c.

Tree-SHA512: 3edbbd252fc68e976d930a8a6124746b3ba586ea58dc0720a67f8975e935057e2838bb7484d6b789771a327d2b69a092d64f335dd483f90b84a3ef290c138bfb
2026-08-27 23:11:24 +01:00
Hennadii Stepanov
1ad8641278 iwyu: Fix warnings in src/init and treat them as errors 2026-08-27 20:23:24 +01:00
GuTS805
21d4e0ba75 rpc, wallet, test: fix invalid JSON in HelpExampleRpc curl examples
Several HelpExampleRpc call sites reused CLI-style argument strings
verbatim (missing commas, bare unquoted words, or single backslashes
that are not valid JSON escapes), producing curl examples that fail
JSON parsing as documented. Also fixes a stray trailing quote in the
restorewallet named-argument examples, a missing comma in the
listunspent example, and a wrong-schema string-instead-of-array
listunspent argument caught in review.

Lines touched are converted to raw string literals (or strprintf with a
raw string template) throughout, for consistency and to avoid manual
quote/backslash escaping.

Adds a regression check to rpc_help.py::dump_help() so this class of
bug can't silently reappear.
2026-08-27 22:34:18 +05:30
merge-script
204256c73f Merge bitcoin/bitcoin#35900: iwyu: Fix warnings in src/interfaces and treat them as errors
b3ff9c4d68 iwyu: Fix warnings in `src/interfaces` and treat them as errors (Hennadii Stepanov)
d564b0255f iwyu: Add temporary mapping to work around upstream bug (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 b3ff9c4d68 🖋

Tree-SHA512: 9359854c7b6e6ec93022947e78ef57fc68728326df874371028997a550fd1b6ef08e4b09271163b9d5c921c9e01deadf92b0eb5ae3f620d797e4f9bdea8f4727
2026-08-27 14:55:53 +01:00
merge-script
da1cb4dd90 Merge bitcoin/bitcoin#35586: doc: note -blocknotify is not run during IBD/reindex in help text
d5e64b01e1 doc: note -blocknotify is not run during IBD/reindex in help text (Guillermo Fernandes)

Pull request description:

  Adds a note to the `-blocknotify` help output that it is not executed for blocks connected during initial block download or reindexing (it only fires once the node reaches the post-init sync state). Suggested by sedited in review of #35518.

ACKs for top commit:
  sedited:
    ACK d5e64b01e1

Tree-SHA512: 06b4a3c6354689e9846b5af6c210c3bb360b917477ac9506814c0238a1afb78392c4b6a6bbd51a4b9d98c841a1bc86686e90072155ce9a4f5e8f875cfe288c0c
2026-08-27 13:17:36 +02:00
merge-script
b31aae4f9a Merge bitcoin/bitcoin#36094: ci: bump riscv toolchain to tag 2026.08.25
607f220c6c Revert "ci: use mirror for riscv submodules" (will)
64af18f4e6 ci: bump riscv toolchain to tag 2026.08.25 (will)

Pull request description:

  This bump includes the new github mirrors for sourceware repos for:

    binutils  https://github.com/gnutools/binutils-gdb.git
    gdb       https://github.com/gnutools/binutils-gdb.git
    glibc     https://github.com/gnutools/glibc.git
    newlib    https://github.com/cygwin/cygwin.git
    musl      https://github.com/kraj/musl.git

  from commit riscv-collab/riscv-gnu-toolchain@92d2391 so that we can remove the fish.foo mirrors.

ACKs for top commit:
  maflcko:
    lgtm ACK 607f220c6c
  sedited:
    ACK 607f220c6c

Tree-SHA512: 627ce75b73e9b8dace6bc883d4e017753d531b083a7ac440a542656c124d5a3dc7827c7390287cb232ebf53416018e2717623d81f92c3518b00cfbff994db1d5
2026-08-27 12:36:56 +02:00
will
607f220c6c Revert "ci: use mirror for riscv submodules"
This reverts commit b283e1751c.
2026-08-27 10:53:38 +01:00
will
64af18f4e6 ci: bump riscv toolchain to tag 2026.08.25
This bump includes the new github mirrors for sourceware repos for:

  binutils  https://github.com/gnutools/binutils-gdb.git
  gdb       https://github.com/gnutools/binutils-gdb.git
  glibc     https://github.com/gnutools/glibc.git
  newlib    https://github.com/cygwin/cygwin.git
  musl      https://github.com/kraj/musl.git

from commit 92d239130d
2026-08-27 10:53:20 +01:00
merge-script
fd573f6db9 Merge bitcoin/bitcoin#36044: test: cover OP_SUCCESSx bypassing the initial stack element size limit
558e26e66e test: cover OP_SUCCESSx bypassing the initial stack element size limit (ViniciusCestarii)

Pull request description:

  BIP-342 specifies that the initial stack resource checks happen after OP_SUCCESSx processing, and explicitly notes the checks "can be bypassed using OP_SUCCESSx". Core implements this correctly, but there are currently no tests covering this behavior. This means a consensus-breaking change to the ordering could pass the test suite undetected. Verified this on local commit 68d24d7430, which mutates to incorrectly implement the order and CI still turns green.

  Add a new test at feature_taproot.py to cover OP_SUCCESSx bypassing the initial stack element size limit.

  Verified that the new test catches the mutant: f8f42a13a8.

ACKs for top commit:
  instagibbs:
    ACK 558e26e66e

Tree-SHA512: 66d7bbbf286bf7e5c5762704e8c0f835c6a8026d7d604263e9debcd7e71df80506c0238b8a15cda3d4ba245d9c2bc46e79a1986d66583e571e208c8dfbe66156
2026-08-27 10:46:41 +01:00
merge-script
2224e4af6c Merge bitcoin/bitcoin#35850: fuzz: Implement connect_block harness
2777300c68 fuzz: Implement connect_block harness (Robin David)
40add915be test: Add reset to CuckooCache (Eugene Siegel)

Pull request description:

  Adds a fuzz target that directly calls `ConnectBlock` with `fJustCheck` set to true, so it hits block/transaction validation without writing undo data or updating the chainstate.

  This PR is essentially https://github.com/bitcoin/bitcoin/pull/34651 with some minor tweaks and style cleanups. Additional validation harnesses (e.g. https://github.com/bitcoin/bitcoin/pull/34895) could build on this test's setup.

ACKs for top commit:
  Crypt-iQ:
    ACK 2777300c68
  nervana21:
    tACK 2777300c68

Tree-SHA512: e2dc74154a6e29e0f3eaec9caeeec53d64bcc96adb0d1739281da97712dd931c3937eaf71f977bfc9c9330f26e35b3633f72788143b76e24e17c37b0a4258ba4
2026-08-27 10:24:55 +01:00
Robin David
2777300c68 fuzz: Implement connect_block harness
Co-authored-by: marcofleon <marleo23@proton.me>
2026-08-26 17:54:44 +01:00
ViniciusCestarii
bed46bd16c build: check for SetThreadDescription() at configure time 2026-08-26 13:43:38 -03:00
Eugene Siegel
40add915be test: Add reset to CuckooCache
Add a method that clears and resets CuckooCache, intended for
use in tests only. Without this, fuzz tests may reuse the cache
across iterations, resulting in instability.
2026-08-26 17:36:06 +01:00
merge-script
a24110cef7 Merge bitcoin/bitcoin#36092: fix: UB sanitizer in mempool estimator logging
576a0ebb53 fix: UB sanitizer in mempool estimator logging (rustaceanrob)

Pull request description:

  The following is failing in CI, when a block has `m_height` of 64 bit max:
  ```
   SUMMARY: UndefinedBehaviorSanitizer: unsigned-integer-overflow /home/runner/work/_temp/src/policy/fees/mempool_estimator.cpp:210:62
  MS: 0 ; base unit: 0000000000000000000000000000000000000000
  0x1,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x26,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2f,0x0,0x3,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7a,0x3f,0x3f,0x0,0x0,0x2f,0x0,0x3,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7a,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0x18,0x0,0x0,0x85,0x3f,0xff,0xff,0xff,0xff,0xff,0x18,0x0,0x0,0x85,0xd6,0x1,0x0,0x86,0x0,0x0,0x0,0x2a,0x0,0xff,0xff,0xff,
  \001\000\000\000\003\377\377\377\377\377\377\377\377\001\000\377\377\377\377\377\377\377\377\000\000&\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000/\000\003\002\002\002\002\002\002\002\000\000\000\000\000\000\000z??\000\000/\000\003\002\002\002\002\002\002\002\000\000\000\000\000\000\000z???\377\377\377\377\377\030\000\000\205?\377\377\377\377\377\030\000\000\205\326\001\000\206\000\000\000*\000\377\377\377
  artifact_prefix='./'; Test unit written to ./crash-b4333d1fe3993fe8610b86654e385682c23050b9
  Base64: AQAAAAP//////////wEA//////////8AACYAAAAAAAAAAAAAAAAAAAAAAAAvAAMCAgICAgICAAAAAAAAAHo/PwAALwADAgICAgICAgAAAAAAAAB6Pz8///////8YAACFP///////GAAAhdYBAIYAAAAqAP///w==

  ⚠️ Failure generated from target with exit code 1: ['/home/runner/work/_temp/build_ ₿🧪_/bin/fuzz', '-runs=1', PosixPath('/home/runner/work/_temp/ci/scratch_ ₿🧪_/qa-assets/fuzz_corpora/policy_estimator_io')]
  Check if using libFuzzer ... True
  Command '['docker', 'exec', '--env', 'DANGER_RUN_CI_ON_HOST=1', '8100bf684275e706787e07f8ab94431926ba5184562c52bce95c932210f6f38f', '/home/runner/work/_temp/ci/test/03_test_script.sh']' returned non-zero exit status 1.

  ```

ACKs for top commit:
  maflcko:
    lgtm ACK 576a0ebb53
  marcofleon:
    ACK 576a0ebb53
  jeanpablojp:
    tACK 576a0ebb53

Tree-SHA512: a7533e68a95b2f0200abdcf08ae72a7f3654db03cffe642ed39b0a5aa48d932a8b07ee4e4477b591a488b5358dd19fe85a03015642b663fd41a771b3090bc8a3
2026-08-26 16:34:02 +01:00
merge-script
8b84f91778 Merge bitcoin/bitcoin#36088: util: Set Univalue to null after read failure
fa72de78a9 util: Set Univalue to null after read failure (MarcoFalke)
fa7786592d test: Add UniValue failed read test (MarcoFalke)

Pull request description:

  Currently, `UniValue::read()` may leave the value in a dirty/corrupt state after a read failure.

  This is perfectly fine, because all production code-paths check the read return value and exit early.

  However, it seems nicer and safer to discard the dirty and corrupt state. So do that here.

  This refactor doesn't change any production behavior. However, it fixes a fuzz failure in the `rpc` target, which was recently reworked in commit fa895bb77a. Later, adding new fuzz inputs (e.g. `fuzz_corpora/rpc/fa1b0eeaa948a091f022c1ff2d0002a3fa6a631f `) and commit 747cff8424 made it hit this invalid UniValue code path.

ACKs for top commit:
  rustaceanrob:
    ACK fa72de78a9
  hodlinator:
    re-ACK fa72de78a9
  jeanpablojp:
    tACK fa72de78a9
  Sjors:
    ACK fa72de78a9
  l0rinc:
    code review ACK fa72de78a9

Tree-SHA512: 6c0597a5ab558dc7d22e1742e89078e07a59a87185228114db4381c3381e19b668b95e42cb7ff80288fa56fb15ea1e0e181f59ba3ceaea8a2a3bff12899c7821
2026-08-26 16:29:29 +01:00
rustaceanrob
576a0ebb53 fix: UB sanitizer in mempool estimator logging
The following is failing in CI, when a block has `m_height` of 64 bit
max:
```
 SUMMARY: UndefinedBehaviorSanitizer: unsigned-integer-overflow /home/runner/work/_temp/src/policy/fees/mempool_estimator.cpp:210:62
MS: 0 ; base unit: 0000000000000000000000000000000000000000
0x1,0x0,0x0,0x0,0x3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x26,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2f,0x0,0x3,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7a,0x3f,0x3f,0x0,0x0,0x2f,0x0,0x3,0x2,0x2,0x2,0x2,0x2,0x2,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x7a,0x3f,0x3f,0x3f,0xff,0xff,0xff,0xff,0xff,0x18,0x0,0x0,0x85,0x3f,0xff,0xff,0xff,0xff,0xff,0x18,0x0,0x0,0x85,0xd6,0x1,0x0,0x86,0x0,0x0,0x0,0x2a,0x0,0xff,0xff,0xff,
\001\000\000\000\003\377\377\377\377\377\377\377\377\001\000\377\377\377\377\377\377\377\377\000\000&\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000/\000\003\002\002\002\002\002\002\002\000\000\000\000\000\000\000z??\000\000/\000\003\002\002\002\002\002\002\002\000\000\000\000\000\000\000z???\377\377\377\377\377\030\000\000\205?\377\377\377\377\377\030\000\000\205\326\001\000\206\000\000\000*\000\377\377\377
artifact_prefix='./'; Test unit written to ./crash-b4333d1fe3993fe8610b86654e385682c23050b9
Base64: AQAAAAP//////////wEA//////////8AACYAAAAAAAAAAAAAAAAAAAAAAAAvAAMCAgICAgICAAAAAAAAAHo/PwAALwADAgICAgICAgAAAAAAAAB6Pz8///////8YAACFP///////GAAAhdYBAIYAAAAqAP///w==

⚠️ Failure generated from target with exit code 1: ['/home/runner/work/_temp/build_ ₿🧪_/bin/fuzz', '-runs=1', PosixPath('/home/runner/work/_temp/ci/scratch_ ₿🧪_/qa-assets/fuzz_corpora/policy_estimator_io')]
Check if using libFuzzer ... True
Command '['docker', 'exec', '--env', 'DANGER_RUN_CI_ON_HOST=1', '8100bf684275e706787e07f8ab94431926ba5184562c52bce95c932210f6f38f', '/home/runner/work/_temp/ci/test/03_test_script.sh']' returned non-zero exit status 1.

```
2026-08-26 14:10:32 +01:00
merge-script
5f45583e43 Merge bitcoin/bitcoin#36077: bugfix: give TxDownloadManager its own RNG
80eaa6cabf bugfix: give TxDownloadManager its own RNG (Greg Sanders)

Pull request description:

  TxDownloadManagerImpl retains a reference to PeerManagerImpl::m_rng,
  which is non-thread-safe and guarded by g_msgproc_mutex.

  BlockConnected runs on the validation background thread while holding
  only m_tx_download_mutex. Reconsidering an orphan with multiple
  announcers could therefore use m_rng concurrently with message
  processing.

  Regression introduced in #35986

  Added a regression test on second commit, can remove it from the PR if deemed superfluous.

  This is a Project Loupe find.

ACKs for top commit:
  maflcko:
    review ACK 80eaa6cabf 🐓
  hodlinator:
    ACK 80eaa6cabf
  sedited:
    ACK 80eaa6cabf

Tree-SHA512: 2dbc4a9298bfa1375dc364ead4b1ec74c2ebe54fb7c311180fa06fc32240406be2979a2dd6ae0e7a23b099ddcd63f5c76c126d84a1405fc7eacd337eb009dd88
2026-08-26 14:22:28 +02:00
MarcoFalke
fa72de78a9 util: Set Univalue to null after read failure 2026-08-26 13:18:15 +02:00
MarcoFalke
fa7786592d test: Add UniValue failed read test
Just to document the current behavior, fixed in the next commit.
2026-08-26 12:27:18 +02:00
merge-script
e339043ee9 Merge bitcoin/bitcoin#35829: http: Make class fields private and make HTTPResponse a struct
5e0d7a286a refactor: Drastically narrow scope of http_bitcoin namespace and rename it to bitcoin_http (Hodlinator)
8f9fd8698a refactor: Make HTTPRemoteClient fields private (Hodlinator)
d72f67fd6c refactor: Expose additional HTTPRemoteClient fields through accessors (Hodlinator)
10bbae302f refactor: Expose HTTPRemoteClient fields to tests through methods (Hodlinator)
5b06d90831 refactor: Replace HTTPServer::MaybeDispatchRequestsFromClient() with HTTPRemoteClient::TryReadRequest() (Hodlinator)
a1183c02aa refactor: Extract Send() and Receive() into HTTPRemoteClient from HTTPServer (Hodlinator)
6d9b61d4f8 refactor: Extract HTTPRemoteClient::MaybeDisconnect() from HTTPServer::DisconnectClients() (Hodlinator)
6fec8d6914 refactor: Make HTTPRequest fields private (Hodlinator)
b8cd77237b refactor: Make HTTPRequest::GetHeader() return saner optional type (Hodlinator)
e5be0dc35e refactor: Make HTTPResponse a struct since all fields are public (Hodlinator)

Pull request description:

  The new HTTP server implementation in v32 has `HTTPServer` reaching into and modifying fields of `HTTPRemoteClient` and `HTTPRequest`. This PR encapsulates field data of the latter 2 types which enforces invariants and reduces cognitive load[^1]. Exposing data through accessor methods also implies adding lock annotations.

  Commits:
  * Makes `HTTPResponse` a struct since it is used that way. (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3336757663) [^2]
  * `HTTPRequest`:
    * Saner return type for `GetHeader()` (old type was mirroring the now removed libevent-wrapper and made later commits ugly).
    * Make fields private.
  * Simplifies boolean logic in `HTTPServer::DisconnectClients()`. (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3336757663)
  * Extraction of `HTTPServer` functions into `HTTPRemoteClient`:
    Refactors `HTTPRemoteClient` to be more self-contained rather than having `HTTPServer` reach into the fields of other objects. (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3339543447, https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3339543447)
  * Severely narrows `http_bitcoin` namespace and renames it to `bitcoin_http` (https://github.com/bitcoin/bitcoin/pull/35182#discussion_r3264510816)

  Follow-up to #35182.

  [^1]: Core Guidelines: C.9: Minimize exposure of members - https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c9-minimize-exposure-of-members
  [^2]: Core Guidelines: C.2: Use class if the class has an invariant; use struct if the data members can vary independently - https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently

ACKs for top commit:
  achow101:
    ACK 5e0d7a286a
  janb84:
    ACK 5e0d7a286a
  winterrdog:
    tACK 5e0d7a286a

Tree-SHA512: e1c5aa067538e31247ca74923e451038c90750ccc941ae16711dd976c8cd750bd1afaee6e4378aeee91440f7727955d9bfb32aa25a0a745613d0d771a674ebc8
2026-08-26 11:26:09 +01:00
Ava Chow
031175197f Merge bitcoin/bitcoin#36032: rpc: avoid quadratic output lookups
747cff8424 rpc: avoid quadratic output lookups (Lőrinc)

Pull request description:

  **Problem:** Transaction-creation RPCs currently take quadratic time to parse outputs.
  An authenticated RPC client can therefore tie up a worker with a large request.
  `sendmany` also holds the wallet lock while parsing, delaying other operations on the same wallet.

  **Fix:** Parse transaction outputs in linear time by reading corresponding keys and values by index instead of looking up each value by key.

  **Reproducer:** Run `time build/bin/test_bitcoin --run_test=rpc_tests/parse_outputs` before and after the fix:
  <details>
  <summary>parse_outputs test in `rpc_tests.cpp`</summary>

  ```cpp
  BOOST_AUTO_TEST_CASE(parse_outputs)
  {
      constexpr size_t OUTPUT_COUNT{10'000};
      UniValue outputs{UniValue::VOBJ};
      for (size_t i{0}; i < OUTPUT_COUNT; ++i) {
          auto destination{EncodeDestination(WitnessV0ScriptHash{CScript{} << i})};
          outputs.pushKVEnd(destination, ValueFromAmount(i + 1));
      }

      const auto parsed_outputs{ParseOutputs(outputs)};
      BOOST_REQUIRE_EQUAL(parsed_outputs.size(), OUTPUT_COUNT);
      for (size_t i{OUTPUT_COUNT}; i > 0; --i) {
          std::pair expected{CTxDestination{WitnessV0ScriptHash{CScript{} << (i - 1)}}, static_cast<CAmount>(i)};
          BOOST_CHECK(parsed_outputs[i - 1] == expected);
      }
  }
  ```
  </details>
  E.g. on my M4 Max with `debug` build:

  ```python
  Before  ████████████████████  1.80 s
  After   █████▒░░░░░░░░░░░░░░  0.50 s  -72%
  ```
  Related to #35889

ACKs for top commit:
  achow101:
    ACK 747cff8424
  jonatack:
    ACK 747cff8424
  jeanpablojp:
    tACK 747cff8424
  hodlinator:
    ACK 747cff8424

Tree-SHA512: 154c9f583f6e7f4154882aeb1ae11c40b327d0ef04147e12a0fee749494ae95314cdfc56baad78723f3383f225d752654be0ae9ed7458b1c73f7a6a80922e3ef
2026-08-25 14:52:08 -07:00
Ava Chow
b91d983f66 Merge bitcoin/bitcoin#36078: qa: Reduce -maxconnections in the functional test framework
b8a8893bf2 qa: Lower `-rpcmaxconnections` in `interface_http.py` test (Hennadii Stepanov)
6f4109b448 qa: Reduce `-maxconnections` in the functional test framework (Hennadii Stepanov)

Pull request description:

  This PR follows up on bitcoin/bitcoin#35730 and fixes a [regression](https://github.com/bitcoin/bitcoin/pull/35730#issuecomment-5409592163) on NetBSD.

  Since bitcoin/bitcoin#35730 the HTTP server reserves file descriptors for its listen sockets and for `-rpcmaxconnections` connected clients (16 by default), so `min_required_fds` in `init.cpp` grew.

  On select()-based platforms `available_fds` is capped at FD_SETSIZE, which is 256 on NetBSD. The previous value of 94 no longer fits and every node in the test suite started up with a warning, which the framework treats as unexpected stderr and fails on.

  Recompute the value with the new accounting (256 - 179 = 77) and update the comment to match the current variable names in `init.cpp`.

ACKs for top commit:
  achow101:
    ACK b8a8893bf2
  hodlinator:
    re-ACK b8a8893bf2
  winterrdog:
    re-ACK b8a8893bf2

Tree-SHA512: d6200cc334b98148d71992b1d085ca8f72ba68d330b26d7ba373a0917cca56a444b8d89b0c0827e2a56242893b268e9f581bffc8a631a2ff20cc51f10db3255e
2026-08-25 11:40:31 -07:00
merge-script
0f5c6d0b64 Merge bitcoin/bitcoin#35618: depends: Make tarball creation from local directory reproducible
7e973cce52 depends: Make tarball creation from local directory reproducible (Hennadii Stepanov)

Pull request description:

  This guarantees `$(package)_sha256_hash` reproducibility regardless of the default behavior of `$(build_TAR)` and fixes [caching](https://github.com/bitcoin/bitcoin/pull/36006#issuecomment-5328809116) for the `native_libmultiprocess` package.

  Steps to reproduce the issue using the master branch @ 2a9e35d293:
  ```console
  $ mkdir a && cd a && git init
  $ git remote add origin https://github.com/bitcoin/bitcoin.git
  $ git fetch --depth 1 origin 2a9e35d293
  $ git checkout FETCH_HEAD
  $ cd depends
  $ gmake print-native_libmultiprocess_sha256_hash  # Hash A. Compare with Hash B.
  native_libmultiprocess_sha256_hash=7dd817bfc0ee23c408299907aff13fefb0bd3a54ec66dc14ea15b0cc38c3d9ce
  $ cd ../../ && sleep 2
  $ mkdir b && cd b && git init
  $ git remote add origin https://github.com/bitcoin/bitcoin.git
  $ git fetch --depth 1 origin 2a9e35d293
  $ git checkout FETCH_HEAD
  $ cd depends
  $ gmake print-native_libmultiprocess_sha256_hash  # Hash B. Compare with Hash A.
  native_libmultiprocess_sha256_hash=34d6f79560c0ff7a4f46bd6bfb4693076546b41f071b6dbf879da45ac8384688
  ```

ACKs for top commit:
  fanquake:
    ACK 7e973cce52
  willcl-ark:
    ACK 7e973cce52

Tree-SHA512: f939cd1b2aca04eaa0f8426858bae3657ee9625f915834980caacfbf80843b952451f4d1c29e27179e533de3e10d31688593e4c25ed32e62392bfbaf9e58dd12
2026-08-25 17:07:36 +01:00
Hennadii Stepanov
b8a8893bf2 qa: Lower -rpcmaxconnections in interface_http.py test
On some systems, such as NetBSD, the non-default
`-rpcmaxconnections=128` is too high, so bitcoind refuses to start:
```
Error: Not enough file descriptors available. 256 available, 290 required.
```

The test only needs a value above the default of 16. Use 64 and lower
`-maxconnections` in that case so the total fits in 256.
2026-08-25 16:54:59 +01:00
Hennadii Stepanov
6f4109b448 qa: Reduce -maxconnections in the functional test framework
Since bitcoin/bitcoin#35730 the HTTP server reserves file descriptors
for its listen sockets and for `-rpcmaxconnections` connected clients
(16 by default), so `min_required_fds` in init.cpp grew.

On select()-based platforms `available_fds` is capped at FD_SETSIZE,
which is 256 on NetBSD. The previous value of 94 no longer fits and
every node in the test suite started up with a warning, which the
framework treats as unexpected stderr and fails on.

Recompute the value with the new accounting (256 - 179 = 77) and
update the comment to match the current variable names in init.cpp.
2026-08-25 16:54:51 +01:00
Greg Sanders
80eaa6cabf bugfix: give TxDownloadManager its own RNG
TxDownloadManagerImpl retains a reference to PeerManagerImpl::m_rng,
which is non-thread-safe and guarded by g_msgproc_mutex.

BlockConnected runs on the validation background thread while holding
only m_tx_download_mutex. Reconsidering an orphan with multiple
announcers could therefore use m_rng concurrently with message
processing.

Regression introduced in 9cc7dc50bd
2026-08-25 10:37:38 -04:00
Hodlinator
5e0d7a286a refactor: Drastically narrow scope of http_bitcoin namespace and rename it to bitcoin_http
http_bitcoin was mostly used during #35182 to distinguish from http_libevent counterpart:
- The http_libevent namespace was introduced around the legacy code in 89c54ae4cb.
- The http_bitcoin namespace was introduced in 68b5d289d1 and extended in subsequent commits.
- The http_libevent namespace together with code it contained was removed in 8c1eea0777.

bitcoin_http is a better name as it is Bitcoin Core's implementation of the HTTP protocol, not HTTP protocol's implementation of bitcoin 402 payment required codes or anything like that.
The namespace only remains for a few constants and a type which don't have HTTP in their names.
2026-08-25 13:23:15 +02:00
Hodlinator
8f9fd8698a refactor: Make HTTPRemoteClient fields private
Move-only change.

Also makes ReadRequest() private.
2026-08-25 13:23:15 +02:00
Hodlinator
d72f67fd6c refactor: Expose additional HTTPRemoteClient fields through accessors 2026-08-25 13:21:44 +02:00
Hodlinator
10bbae302f refactor: Expose HTTPRemoteClient fields to tests through methods
Enables making the fields private later.
2026-08-25 13:21:44 +02:00
Hodlinator
5b06d90831 refactor: Replace HTTPServer::MaybeDispatchRequestsFromClient() with HTTPRemoteClient::TryReadRequest() 2026-08-25 13:21:43 +02:00
merge-script
794a753958 Merge bitcoin/bitcoin#35583: test: close the listeners before terminating the event loop
e4d80e7001 test: close the loop after the network thread has completed (Vasil Dimov)
29fba5ddbb test: close the listeners before terminating the event loop (Vasil Dimov)

Pull request description:

  Whenever a test creates a new `P2PInterface` object a new listener is
  created inside `NetworkThread.create_listen_server()` by calling
  `cls.network_event_loop.create_server()`.

  These listeners are never closed which might result in:

  ```
  2026-06-10T22:13:35.3934880Z Task was destroyed but it is pending!
  2026-06-10T22:13:35.3936020Z task: <Task pending name='Task-54' coro=<BaseSelectorEventLoop._accept_connection2() done, defined at /opt/homebrew/Cellar/python@3.14/3.14.5/Frameworks/Python.framework/Versions/3.14/lib/python3.14/asyncio/selector_events.py:217> wait_for=<Future finished result=None>>
  ```

  when the event loop is closed.

  Fix that by closing the listeners.

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

ACKs for top commit:
  andrewtoth:
    ACK e4d80e7001
  sedited:
    ACK e4d80e7001

Tree-SHA512: b93d06526b4eb31ac445a1a0e379e5ec947661f8ea29f2e07ac88b9e4760b0cc5348638b320ab8d60735f34fc163fcdd18eba42b20e0a7726a98a5136433bd64
2026-08-25 10:41:58 +01:00
merge-script
f6b3f2ff6b Merge bitcoin/bitcoin#36064: qa: Minor improvement follow-ups to 35730
290be9eafa qa: Minor feature_init.py improvements (Hodlinator)
6248331b29 qa: Switch to warning when skipping tests (Hodlinator)
6d570415a0 refactor(qa): Move check right below related check (Hodlinator)
7e3b60584b refactor(qa): Simplify through using assert_raises() (Hodlinator)

Pull request description:

  * Simplify code through `assert_raises()` - https://github.com/bitcoin/bitcoin/pull/35730#discussion_r3812910717
  * Move check below related check - https://github.com/bitcoin/bitcoin/pull/35730#discussion_r3812910717
  * Warn when skipping checks - https://github.com/bitcoin/bitcoin/pull/35730#discussion_r3813035181
  * Minor improvements in 1 commit:
    * Log message instead of comment - https://github.com/bitcoin/bitcoin/pull/35730#discussion_r3814377374
    * Drop `r` from string literal prefix - https://github.com/bitcoin/bitcoin/pull/35730#discussion_r3814347609

ACKs for top commit:
  pinheadmz:
    ACK 290be9eafa
  winterrdog:
    tACK 290be9eafa

Tree-SHA512: 528a9701bc7529c74c02d56f0ca498dc2c0165e7d5a4ca5c8f35f7887e89df6898db9a5077811bed3d5318116479e1c974e9979a9b0c93eb72ed1d467fd8f01d
2026-08-25 10:10:22 +01:00
Ava Chow
6a028161da Merge bitcoin/bitcoin#36025: psbt: avoid duplicate taproot leaf script keys when merging
1cb416397b psbt: avoid duplicate taproot leaf script keys when merging (Shuvam Pandey)

Pull request description:

  Follow-up to #35665, which fixed the same combiner defect for `PSBT_GLOBAL_XPUB`. thomasbuilds
  and winterrdog asked for this one as its own PR when I reported it there.

  `m_tap_scripts` maps a leaf script to a set of control blocks, but is serialized as one record
  per control block, keyed by the control block (`SerializeToVector(s, PSBT_IN_TAP_LEAF_SCRIPT,
  std::span{control_block})`). `PSBTInput::Merge` unions it by the map key, so two PSBTs that map
  the same control block to different leaf scripts merge into an input that serializes the `0x15`
  key twice. Duplicate keys make a PSBT invalid, so it is the same `combinepsbt` then
  `decodepsbt` failure as the xpub case, at the input level. Present since #22558 (v24.0).

  Both decode on their own, and differ only in the leaf script the control block maps to, `OP_1`
  against `OP_1 OP_1`:

  ```
  $ A=cHNidP8BADwCAAAAAaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAIhXAUJKbdMGgSVS3i0tgNel6XgeKWg8o7JbVR7/ums6AOsACUcAAAA==
  $ B=cHNidP8BADwCAAAAAaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAIhXAUJKbdMGgSVS3i0tgNel6XgeKWg8o7JbVR7/ums6AOsADUVHAAAA=
  $ bitcoin-cli -regtest decodepsbt "$(bitcoin-cli -regtest combinepsbt "[\"$A\",\"$B\"]")"
  error code: -22
  error message:
  TX decode failed Duplicate Key, input key "15c050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0" already provided: unspecified iostream_category error
  ```

  winterrdog reproduced it on the #35665 thread with another pair.

  Merge the records rather than the map entries, keeping the leaf script already there. BIP 174
  lets the combiner "pick arbitrarily when conflicts occur", and unknown and proprietary records
  already resolve that way. Refusing to combine is the BIP's other option, but that would fail
  `combinepsbt` on input it accepts today.

  Merging by map key drops records as well. `std::map::insert` leaves existing keys alone, so
  when both PSBTs carry the same leaf script with different control blocks, the incoming set was
  dropped. Those keys do not conflict, so merging per record keeps them.

  The control blocks already present are collected once per merge rather than searched for per
  incoming record, which would be quadratic in the size of the two PSBTs `combinepsbt` takes from
  the caller.

  Since this is the second field with this shape I checked the rest. `m_xpubs` (#35665) and
  `m_tap_scripts` are the only two whose record key comes from the value, so two map entries can
  serialize the same key. `partial_sigs` is keyed by `CKeyID` and serialized under the pubkey,
  but the pubkey determines the `CKeyID`, so those records stay distinct. The others key the
  record by the map key, `m_proprietary` included, and `PSBTOutput` has no such field.

  The test fails on master on both counts, and covers the merges that do not conflict as well.

  I found this with a local assertion in the psbt fuzz target that a combined PSBT must
  roundtrip. That assertion can go in a follow-up.

  Tested:

  ```
  ./build/bin/test_bitcoin --run_test=psbt_tests
  ./build/bin/test_bitcoin --run_test=psbt_wallet_tests
  ./build/test/functional/test_runner.py rpc_psbt.py rpc_rawtransaction.py wallet_taproot.py wallet_signer.py feature_taproot.py wallet_basic.py
  ```

ACKs for top commit:
  achow101:
    ACK 1cb416397b
  winterrdog:
    re-ACK 1cb416397b

Tree-SHA512: 2599beffe701ba9b672e8dcc3d43844f3853ceeb3d86fc53798a428d3288aa8edd2e42f338b32a1046fa558d6cc5cfa5d55b3a0aaf960278b0f3002158381623
2026-08-24 14:53:58 -07:00
Ava Chow
07d92a9d65 Merge bitcoin/bitcoin#35516: rpc: preserve global xpubs and proprietary fields in joinpsbts
436921eb46 test: check joinpsbts preserves global xpubs and proprietary fields (Thomas)
011094b282 rpc: preserve global xpubs and proprietary fields in joinpsbts (Thomas)

Pull request description:

  `joinpsbts` collects the global xpubs of all the joined PSBTs into `merged_psbt`, but returns a separately constructed `shuffled_psbt` into which only the inputs, outputs, and unknown fields are copied. The collected `PSBT_GLOBAL_XPUB` records are silently dropped, and `PSBT_GLOBAL_PROPRIETARY` records are not collected at all.

  The xpub collection was added in #17034, which was written against a `joinpsbts` that still returned `merged_psbt`, but was merged after #16512 had introduced the `shuffled_psbt` rebuild, so the collected xpubs have never reached the result.

  Shuffle the inputs and outputs of `merged_psbt` in place instead of rebuilding a new PSBT, so that all global data is preserved, and union the global proprietary records in the merge loop, matching the `combinepsbt` behavior from #34893.

ACKs for top commit:
  jpk68:
    ACK 436921eb46
  achow101:
    ACK 436921eb46
  winterrdog:
    tACK 436921eb46

Tree-SHA512: d9de34c25aecc29b6b4fb80d6584fa919cc5ff9b7ef2f4d8ce35c4043fe7638fefb8af10448f2cd14021f5d25e149f0efc8798c5b8c9bc8b5582c6152010e891
2026-08-24 14:38:14 -07:00
Ava Chow
4375d74d24 Merge bitcoin/bitcoin#34993: wallet: NotifyCanGetAddressesChanged when advancing next_index
e2ab8ae551 wallet: spkm: Only notify CanGetAddressesChanged on change (David Gumberg)
0892f16f91 refactor: moveonly: Pair CanGetAddressesChanged notifications with desc range. (David Gumberg)
e6adae3db2 wallet: `NotifyCanGetAddressesChanged` when advancing `next_index` (David Gumberg)

Pull request description:

  Even though `TopUp()` notifies, advancing `next_index` after can deplete available addresses, so make sure to notify any time it's changed.

  This would manifest as users seeing a clickable `Receive` button in the GUI when in fact no address can be generated in some edge cases, e.g. when a user has a watch only wallet with a hardened derivation path and runs out of keys.

  This feels like it's begging for:

  1) a refactor to make it impossible to modify `next_index` or `range_end` without firing `CanGetAddressesChanged`
  2) a test

  I banged my head against the keyboard for a bit but I couldn't get either of these to fall out, I also tried massaging a few clankers into doing it but I couldn't get any results that seemed reasonable to me, still seems like a worthwhile fix so opening PR anyway.

  I also included a moveonly commit to pair code that can change the result of `CanGetAddresses()` with the notification firing

ACKs for top commit:
  achow101:
    ACK e2ab8ae551
  polespinasa:
    ACK e2ab8ae551
  furszy:
    utACK e2ab8ae551

Tree-SHA512: 5bb00d1ef4909a3e55535d283e5995df75e4288a151647f4a368b2086e2f2f4140693f43cae4f72727eafb49c9050aea8604cd6ddddc8646f7ac47b1357ed287
2026-08-24 14:25:08 -07:00
Hodlinator
290be9eafa qa: Minor feature_init.py improvements
* Emit log message before performing check.
* Drop needless 'r' from string literal.
2026-08-24 21:11:33 +02:00
Hodlinator
6248331b29 qa: Switch to warning when skipping tests
This is convention, see of example "except SkipTest" in test_framework.py.
2026-08-24 21:11:16 +02:00
merge-script
04cf9ecee4 Merge bitcoin/bitcoin#35978: contrib/init: fix unused variables in openrc script
d837bb38a4 contrib/init: fix unused variables in openrc script (jpk68)

Pull request description:

  - Makes it so that `${BITCOIND_BIN}` is actually used as `command=`, rather than the hardcoded `/usr/bin/bitcoind`.
  - Passes `BITCOIND_GROUP` to `start-stop-daemon`, so that the daemon process itself runs under it.

ACKs for top commit:
  jeanpablojp:
    utACK d837bb38a4
  thomasbuilds:
    ACK d837bb38
  winterrdog:
    utACK d837bb38a4

Tree-SHA512: 78c237224d65cc47ade606df4808fbf4ca70109d95301c35d1b336eead1b25138a83ce6f2314775b8a11a6745af2220af9027640530b9edb7e0167ccea081b6b
2026-08-24 19:51:29 +01:00
merge-script
aed80c7395 Merge bitcoin/bitcoin#36067: test: Remove BOOST_CHECK_CLOSE in favor of exact comparison
9e115edd39 test: Remove `BOOST_CHECK_CLOSE` in favor of exact comparison (rustaceanrob)

Pull request description:

  `max_cache` is known ahead of time in this test as a `size_t` of `10000`, and each of these calculations should be known ahead of time (500.0, 9500.0). This test can truncate the double and assert exact equality rather than use a tolerance. Found in #35713 whereby this is the only use of this macro in the unit tests. IMO it is appropriate to tighten this test and remove the macro.

ACKs for top commit:
  maflcko:
    lgtm ACK 9e115edd39
  josibake:
    ACK 9e115edd39

Tree-SHA512: 738f05650bd1426e8e29e94955685e8ad3cd62e57f1c65b7af045161e4ca5af64bbd1f0cfed8da427a1f778620e3c8f7dfb835881f8de169806096213056e863
2026-08-24 16:08:22 +01:00
merge-script
07ca9ba9e8 Merge bitcoin/bitcoin#36059: test: make index crash test check saved state
7ea36e985a test: preserve index crash test state (Lőrinc)
5aa15df60c test: expose missing index crash checkpoint (Lőrinc)

Pull request description:

  **Problem:** #35847 moved the unclean-shutdown test into the shared base index tests, but it checked only that each index could reopen and start background sync.
  Both checks also pass when the index reopens at height 0, so they do not verify that a height-100 checkpoint was saved before the simulated crash and reloaded afterward.

  **Fix:** The first commit records the existing false positive by asserting that each index reopens at height 0 before background sync.
  The second commit establishes a durable checkpoint at height 100, drains its setup notification, and changes the same assertion to the pre-crash height.

ACKs for top commit:
  jeanpablojp:
    tACK 7ea36e985a
  mzumsande:
    ACK 7ea36e985a

Tree-SHA512: 0dca2bdd978c5df4acbb01692bb2058e74efa70da3d7191687628075a680a57848ddda8087629b5d743d9a1648d7dc849fda9ff487252136a0c91cdfda33ba32
2026-08-24 15:46:55 +01:00