test: Better test coverage for ParseHDKeypath() #35170

Manually merged
optout21 merged 4 commits from 2604-parse-keypath-legacy into master 2026-11-05 10:53:03 +00:00 AGit
optout21 commented 2026-04-28 09:21:34 +00:00 (Migrated from github.com)

Background: The ParseHDKeypath method (src/util/bip32.cpp) is used directly only in a limited way: when loading legacy wallets. However, it shares internals with parsing within descriptors (ParseKeyPath, ParseKeyPathNum in src/script/descriptor.cpp, c.f. #35069).

Deficiencies: The method has a unit test, but it checks only the bool result, and not the parsed keypath. This can be demonstrated by breaking the implementation by adding a keypath.clear(); statement just before the final return true;. With this obviously broken implementation the tests pass.

Solution proposed: Extend the tests with checks (without modifying the behavior).

Changes:

  • Extend the unit tests with checks for the returned parsed keypath. Add the expected parsed numerical keypath as test data. Note: breaking the production code as described above now results in test failure.

  • In the unit test also perform round-trip conversion: convert to string, then parse again, and convert to string again. In the last two steps the results should match the input before the round-trip (note: this is not true for the first roundtrip). Additionally, add negative tests for the unsupported 'h' hardened delimiter.

Background: The `ParseHDKeypath` method (`src/util/bip32.cpp`) is used directly only in a limited way: when loading legacy wallets. However, it shares internals with parsing within descriptors (`ParseKeyPath`, `ParseKeyPathNum` in `src/script/descriptor.cpp`, c.f. #35069). Deficiencies: The method has a unit test, but it checks only the bool result, and not the parsed keypath. This can be demonstrated by breaking the implementation by adding a `keypath.clear();` statement just before the final `return true;`. With this obviously broken implementation the tests pass. Solution proposed: Extend the tests with checks (without modifying the behavior). Changes: - Extend the unit tests with checks for the returned parsed keypath. Add the expected parsed numerical keypath as test data. Note: breaking the production code as described above now results in test failure. - In the unit test also perform round-trip conversion: convert to string, then parse again, and convert to string again. In the last two steps the results should match the input before the round-trip (note: this is not true for the first roundtrip). Additionally, add negative tests for the unsupported 'h' hardened delimiter.
DrahtBot commented 2026-04-28 09:21:49 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK Sjors
Concept ACK l0rinc
Stale ACK haishmg, brunoerg, w0xlt

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

No conflicts as of last run.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35170 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35170.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35170#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [Sjors](https://github.com/bitcoin/bitcoin/pull/35170#issuecomment-6463430293) | | Concept ACK | [l0rinc](https://github.com/bitcoin/bitcoin/pull/35170#pullrequestreview-4187740368) | | Stale ACK | [haishmg](https://github.com/bitcoin/bitcoin/pull/35170#issuecomment-4337163769), [brunoerg](https://github.com/bitcoin/bitcoin/pull/35170#pullrequestreview-5370755363), [w0xlt](https://github.com/bitcoin/bitcoin/pull/35170#pullrequestreview-5617390605) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts No conflicts as of last run. <!--5faf32d7da4f0f540f40219e4f7537a3-->
l0rinc (Migrated from github.com) reviewed 2026-04-28 10:19:46 +00:00
l0rinc (Migrated from github.com) left a comment

Concept ACK, only reviewed lightly to understand the extent of the change

Concept ACK, only reviewed lightly to understand the extent of the change
l0rinc (Migrated from github.com) commented 2026-04-28 10:19:01 +00:00

2bd25fc refactor: Rename ParseHDKeypath to ParseHDKeypathLegacy:

Can you make this a scripted diff for simplicity?

> [2bd25fc](https://github.com/bitcoin/bitcoin/pull/35170/changes/2bd25fc3a4ae663b0da77a9a4d9fecac50260183) _refactor: Rename ParseHDKeypath to ParseHDKeypathLegacy_: Can you make this a scripted diff for simplicity?
l0rinc (Migrated from github.com) commented 2026-04-28 10:18:20 +00:00

1f80ddb fuzz: In parse_hd_keypath exercise the non-apostrophe version:

we don't want to correlate the two calls for the fuzzer:

    (void)FormatHDKeypath(random_keypath, /*apostrophe=*/fuzzed_data_provider.ConsumeBool());
    (void)WriteHDKeypath(random_keypath, /*apostrophe=*/fuzzed_data_provider.ConsumeBool());
> [1f80ddb](https://github.com/bitcoin/bitcoin/pull/35170/changes/1f80ddb330e844602adc502e83554eb065791e35) _fuzz: In parse_hd_keypath exercise the non-apostrophe version_: we don't want to correlate the two calls for the fuzzer: ```suggestion (void)FormatHDKeypath(random_keypath, /*apostrophe=*/fuzzed_data_provider.ConsumeBool()); (void)WriteHDKeypath(random_keypath, /*apostrophe=*/fuzzed_data_provider.ConsumeBool()); ```
l0rinc (Migrated from github.com) commented 2026-04-28 10:15:53 +00:00

67ae7a2 test: Refactor in parse_hd_keypath: extract test data in an array:

could we swap the order to store the value first and the validity next to follow the order in the usage, i.e. BOOST_CHECK_EQUAL(ParseHDKeypath(keypath_str, keypath), is_valid);

> [67ae7a2](https://github.com/bitcoin/bitcoin/pull/35170/changes/67ae7a2df4c847263e1da4c01a4c03e4fb85863f) _test: Refactor in parse_hd_keypath: extract test data in an array_: could we swap the order to store the value first and the validity next to follow the order in the usage, i.e. `BOOST_CHECK_EQUAL(ParseHDKeypath(keypath_str, keypath), is_valid);`
haishmg commented 2026-04-28 16:24:38 +00:00 (Migrated from github.com)

ACK 2bd25fc3a4ae663b0da77a9a4d9fecac50260183

Reviewed the test refactor and added coverage, the ParseHDKeypathLegacy rename, and the fuzz target change. The new assertions cover returned path elements and round-trip behavior without changing the legacy wallet load behavior.

Ran locally on macOS arm64:

  • build/bin/test_bitcoin --run_test=psbt_wallet_tests/parse_hd_keypath
  • ctest --test-dir build -R 'psbt_wallet|ipc_tests|walletdb_tests' --output-on-failure -j 9\n- ctest --test-dir build -j 9 --output-on-failure (0 failed out of 348; script_assets_tests skipped)\n- git diff --check upstream/master...HEAD
ACK 2bd25fc3a4ae663b0da77a9a4d9fecac50260183 Reviewed the test refactor and added coverage, the `ParseHDKeypathLegacy` rename, and the fuzz target change. The new assertions cover returned path elements and round-trip behavior without changing the legacy wallet load behavior. Ran locally on macOS arm64: - `build/bin/test_bitcoin --run_test=psbt_wallet_tests/parse_hd_keypath` - `ctest --test-dir build -R 'psbt_wallet|ipc_tests|walletdb_tests' --output-on-failure -j 9`\n- `ctest --test-dir build -j 9 --output-on-failure` (0 failed out of 348; `script_assets_tests` skipped)\n- `git diff --check upstream/master...HEAD`
optout21 (Migrated from github.com) reviewed 2026-04-28 17:03:19 +00:00
optout21 (Migrated from github.com) commented 2026-04-28 17:03:19 +00:00

bab6209 test: parse_hd_keypath: Add round-trip tests:

This type conversion is unnecessary (and wrong).

> [bab6209](https://github.com/bitcoin/bitcoin/pull/35170/changes/bab6209ed47a2792e4a92c61d9187ae37f468a2b) _test: parse_hd_keypath: Add round-trip tests_: This type conversion is unnecessary (and wrong).
optout21 (Migrated from github.com) reviewed 2026-04-29 04:21:25 +00:00
optout21 (Migrated from github.com) left a comment

Thanks for the reviews! Pushed changes for the suggestions from the first review. Also extended the PR description with 'Potential future steps'.

The duplicated implementation -- ParseHDKeypath and ParseKeyPath -- could be merged, to reduce code duplication. Combining the two implementations could result in slightly better code; the former implementation looks better, while the latter has better unit test coverage.

git diff 2bd25fc3a4ae663b0da77a9a4d9fecac50260183..a548fac787a89e2e69ec89a6f9450935b3a9e08f

Thanks for the reviews! Pushed changes for the suggestions from the first review. Also extended the PR description with 'Potential future steps'. > The duplicated implementation -- ParseHDKeypath and ParseKeyPath -- could be merged, to reduce code duplication. Combining the two implementations could result in slightly better code; the former implementation looks better, while the latter has better unit test coverage. `git diff 2bd25fc3a4ae663b0da77a9a4d9fecac50260183..a548fac787a89e2e69ec89a6f9450935b3a9e08f`
optout21 (Migrated from github.com) commented 2026-04-29 04:20:27 +00:00

Thanks for insisting, done.

Thanks for insisting, done.
optout21 (Migrated from github.com) commented 2026-04-29 04:20:09 +00:00

Done.

Done.
optout21 (Migrated from github.com) commented 2026-04-29 04:18:54 +00:00

That's how it was done first, but to keep the formatting so that items align to the same columns, it produced a lot of extra white space. The length of the string input varies a lot, while the bool only a little (4 or 5 chars), so it was put first for that reason.

That's how it was done first, but to keep the formatting so that items align to the same columns, it produced a lot of extra white space. The length of the string input varies a lot, while the bool only a little (4 or 5 chars), so it was put first for that reason.
optout21 (Migrated from github.com) commented 2026-04-29 04:20:40 +00:00

Done

Done
optout21 commented 2026-06-17 19:49:44 +00:00 (Migrated from github.com)

Rebased to current master (to refresh)

Rebased to current master (to refresh)
brunoerg commented 2026-07-24 20:48:10 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
brunoerg (Migrated from github.com) reviewed 2026-07-24 20:49:37 +00:00
brunoerg (Migrated from github.com) commented 2026-07-24 20:49:38 +00:00

2d6efe8414aeb75675769ca3ca71b0113ebf7169: nit: These comments "num -> str2" and "str2 -> num2" seem unnecessary, the code is already clear.

2d6efe8414aeb75675769ca3ca71b0113ebf7169: nit: These comments "num -> str2" and "str2 -> num2" seem unnecessary, the code is already clear.
brunoerg (Migrated from github.com) reviewed 2026-07-24 20:54:23 +00:00
brunoerg (Migrated from github.com) commented 2026-07-24 20:54:23 +00:00

94536aba8f0f374953e765b9b76772765a18d2aa: Nice catch! The apostrophe param was added in WriteHDKeypath in bd13dc2f46 (3 years ago). I'm just wondering how effective is fuzzing FormatHDKeypath if WriteHDKeypath can exactly call FormatHDKeypath again with same values.

94536aba8f0f374953e765b9b76772765a18d2aa: Nice catch! The apostrophe param was added in `WriteHDKeypath` in bd13dc2f46ea10302a928fcf0f53b7aed77ad260 (3 years ago). I'm just wondering how effective is fuzzing `FormatHDKeypath` if `WriteHDKeypath` can exactly call `FormatHDKeypath` again with same values.
brunoerg (Migrated from github.com) reviewed 2026-07-24 21:24:42 +00:00
brunoerg (Migrated from github.com) left a comment

code review ACK cf76d345c85283e64a37e850b92b748c5ee29d2b

Nothing blocker from my comments but happy to re-ack if any of them (or any other thing) is addressed.

code review ACK cf76d345c85283e64a37e850b92b748c5ee29d2b Nothing blocker from my comments but happy to re-ack if any of them (or any other thing) is addressed.
DrahtBot commented 2026-08-15 02:48:46 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
optout21 commented 2026-08-18 18:06:32 +00:00 (Migrated from github.com)

PR #32784 has been merged recently, and it overlaps with the changes of this PR (resulted in a conflict). Rebasing had to be done manually, including changes:

  • The test cases had to be updated, as they were changed & extended in #32784
  • The change to the fuzz test was dropped, as the same change has been independently done in #32768 as well.

git range-diff cf76d345c85283e64a37e850b92b748c5ee29d2b...b3e4cd2eef85a55b2a734f5f9817993ff943e852

PR #32784 has been merged recently, and it overlaps with the changes of this PR (resulted in a conflict). Rebasing had to be done manually, including changes: - The test cases had to be updated, as they were changed & extended in #32784 - The change to the fuzz test was dropped, as the same change has been independently done in #32768 as well. `git range-diff cf76d345c85283e64a37e850b92b748c5ee29d2b...b3e4cd2eef85a55b2a734f5f9817993ff943e852`
optout21 (Migrated from github.com) reviewed 2026-08-18 18:10:56 +00:00
optout21 (Migrated from github.com) left a comment

@brunoerg, thanks for the review. I've applied the nit, as the PR had to be changed (due to merge conflict).

@brunoerg, thanks for the review. I've applied the nit, as the PR had to be changed (due to merge conflict).
optout21 (Migrated from github.com) commented 2026-08-18 18:09:43 +00:00

Note: this is irrelevant now, as #32784 had solved this (in a different way).

Note: this is irrelevant now, as #32784 had solved this (in a different way).
optout21 (Migrated from github.com) commented 2026-08-18 18:08:39 +00:00

Applied (as I had to touch due to merge conflict). Note that this code has been moved to src/test/bip32_tests.cpp now.

Applied (as I had to touch due to merge conflict). Note that this code has been moved to `src/test/bip32_tests.cpp` now.
w0xlt commented 2026-08-18 21:49:30 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
DrahtBot commented 2026-08-19 19:25:32 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
optout21 commented 2026-08-21 11:32:34 +00:00 (Migrated from github.com)

Reworked, due to new conflict. #35069 has been merged, whereby the implementation of ParseHDKeypath and ParsePubkey has been mostly deduplicated, and test data changed.
Updated this PR accordingly, it still keeps the test improvements (test data as data, check expected results, add round-trip tests), and the renaming.
Ready for review.

Reworked, due to new conflict. #35069 has been merged, whereby the implementation of `ParseHDKeypath` and `ParsePubkey` has been mostly deduplicated, and test data changed. Updated this PR accordingly, it still keeps the test improvements (test data as data, check expected results, add round-trip tests), and the renaming. Ready for review.
brunoerg (Migrated from github.com) reviewed 2026-09-30 19:06:14 +00:00
brunoerg (Migrated from github.com) left a comment

reACK 56b1a59b47

reACK 56b1a59b47bf7eb80bad5cbaf115e524a4192d57
First-time contributor

Base: aa76bd266df9742a266d52e0e5da8dbf033658f6
Head: 3ce364124c09157722781720ee60aabb5a99e133

Alternatives

Round-trip through WriteHDKeypath instead of FormatHDKeypath plus stripping the leading slash. In the round-trip block, use WriteHDKeypath(keypath_num, /apostrophe=/true). It returns "m" + FormatHDKeypath(...), so ParseHDKeypath accepts its output directly, including "m" for an empty path. That removes keypath_str2_adjusted, the starts_with('/') erase, and its comment. Optionally, compare the vectors with a single BOOST_CHECK(keypath_num2 == keypath_num) instead of the per-element loop. Benefit: Simpler test code. The round trip then uses the same formatter as the existing fuzz target (src/test/fuzz/parse_hd_keypath.cpp:26-28) and needs no special handling for the leading '/'. ParseHDKeypath rejects "/1" only because getline yields an empty first element, and that detail would no longer matter. Trade-off: The test would no longer call FormatHDKeypath directly. FormatHDKeypath is already exercised through WriteHDKeypath, and it is used directly by descriptor code. Also, the fuzz target already asserts round trips for both apostrophe modes, so the unit round trip adds only fixed-case coverage either way. Unresolved: Whether the author wants FormatHDKeypath tested on its own here, without the "m" prefix.

Previously reported concerns remain unresolved: 1 suggestion.

Previous findings
[Suggestion · still present] Include the input path in assertion context

Wrap each iteration’s assertions in a test context containing keypath_str (and, if useful, the element index). When an assertion fails, the shared table location and reported values do not identify which input case failed; context would make these failures easier to diagnose without changing the checks.

Location: src/test/bip32_tests.cpp:340 (head).

First reported at dd665be15b553ef4aa5913c03f4b5e3a53751ce3. Last checked at 3ce364124c09157722781720ee60aabb5a99e133.

Resolved findings
[Suggestion · resolved] Clarify what “Legacy” means for this parser

The legacy wallet database loader is one caller, but ParsePathBIP32 also routes the derivehdkey RPC’s user-supplied path through this parser; that RPC derives keys associated with active or unused(KEY) descriptors (see src/wallet/rpc/wallet.cpp:994, 1015–1048). The stated legacy-wallet-only rationale and future-removal inference therefore do not match the call graph: removing this parser with legacy-wallet loading would also break the current RPC. Consider a neutral BIP32-specific name, or clarify that “Legacy” refers to the parser’s grammar or implementation rather than its callers or lifecycle. This rename does not change runtime behavior.

Location: src/rpc/util.cpp:1386 (head).

Fixed. First reported at 56b1a59b47bf7eb80bad5cbaf115e524a4192d57. Last checked at 3ce364124c09157722781720ee60aabb5a99e133. The prior finding objected to renaming the parser with a "Legacy" name even though the RPC path also calls it. At head, the function is still named ParseHDKeypath in both the header and the implementation, and the RPC caller still uses that name. The patch touches only src/test/bip32_tests.cpp. Dropping the rename removed the change the finding was about. The author plans to address this separately. Author reply 2026-10-06T21:02:16Z

Review tier: routine

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:ab973404fb8e3c0d560a5f0df76c1f96a2e0e21182cfc208ac10a039068cb623:00633cd9cb08c8f4661c30fbf00eaba6318f037423dd36deda26cc4a9d01c2c2 --> Base: `aa76bd266df9742a266d52e0e5da8dbf033658f6` Head: `3ce364124c09157722781720ee60aabb5a99e133` <!-- ralph-case:ac5e11a18acb1962ccb60e4824ff9a2fbb25d2c30e6179c3b9cc4afc4e0768b4 --> ##### Alternatives **Round-trip through WriteHDKeypath instead of FormatHDKeypath plus stripping the leading slash.** In the round-trip block, use WriteHDKeypath(keypath_num, /*apostrophe=*/true). It returns "m" + FormatHDKeypath(...), so ParseHDKeypath accepts its output directly, including "m" for an empty path. That removes keypath_str2_adjusted, the starts_with('/') erase, and its comment. Optionally, compare the vectors with a single BOOST_CHECK(keypath_num2 == keypath_num) instead of the per-element loop. Benefit: Simpler test code. The round trip then uses the same formatter as the existing fuzz target (src/test/fuzz/parse_hd_keypath.cpp:26-28) and needs no special handling for the leading '/'. ParseHDKeypath rejects "/1" only because getline yields an empty first element, and that detail would no longer matter. Trade-off: The test would no longer call FormatHDKeypath directly. FormatHDKeypath is already exercised through WriteHDKeypath, and it is used directly by descriptor code. Also, the fuzz target already asserts round trips for both apostrophe modes, so the unit round trip adds only fixed-case coverage either way. Unresolved: Whether the author wants FormatHDKeypath tested on its own here, without the "m" prefix. Previously reported concerns remain unresolved: 1 suggestion. ##### Previous findings <details> <summary>[Suggestion · still present] Include the input path in assertion context</summary> Wrap each iteration’s assertions in a test context containing `keypath_str` (and, if useful, the element index). When an assertion fails, the shared table location and reported values do not identify which input case failed; context would make these failures easier to diagnose without changing the checks. Location: `src/test/bip32_tests.cpp:340` (head). First reported at `dd665be15b553ef4aa5913c03f4b5e3a53751ce3`. Last checked at `3ce364124c09157722781720ee60aabb5a99e133`. </details> <details> <summary>Resolved findings</summary> <details> <summary>[Suggestion · resolved] Clarify what “Legacy” means for this parser</summary> The legacy wallet database loader is one caller, but ParsePathBIP32 also routes the derivehdkey RPC’s user-supplied path through this parser; that RPC derives keys associated with active or unused(KEY) descriptors (see src/wallet/rpc/wallet.cpp:994, 1015–1048). The stated legacy-wallet-only rationale and future-removal inference therefore do not match the call graph: removing this parser with legacy-wallet loading would also break the current RPC. Consider a neutral BIP32-specific name, or clarify that “Legacy” refers to the parser’s grammar or implementation rather than its callers or lifecycle. This rename does not change runtime behavior. Location: `src/rpc/util.cpp:1386` (head). Fixed. First reported at `56b1a59b47bf7eb80bad5cbaf115e524a4192d57`. Last checked at `3ce364124c09157722781720ee60aabb5a99e133`. The prior finding objected to renaming the parser with a "Legacy" name even though the RPC path also calls it. At head, the function is still named ParseHDKeypath in both the header and the implementation, and the RPC caller still uses that name. The patch touches only src/test/bip32_tests.cpp. Dropping the rename removed the change the finding was about. The author plans to address this separately. [Author reply](https://github.com/bitcoin/bitcoin/pull/35170#issuecomment-6025386291) 2026-10-06T21:02:16Z </details> </details> Review tier: routine [Full review report](<https://review.fish.foo/traces/35170-3ce364124c09157722781720ee60aabb5a99e133-1559-5.html>)
w0xlt (Migrated from github.com) reviewed 2026-09-30 21:12:29 +00:00
w0xlt (Migrated from github.com) left a comment
ACK 56b1a59b47bf7eb80bad5cbaf115e524a4192d57
sedited (Migrated from github.com) reviewed 2026-10-05 11:09:43 +00:00
sedited (Migrated from github.com) commented 2026-10-05 11:09:43 +00:00

In commit 56b1a59b47:

I'm not convinced this rename makes sense after the addition of derivehdkey. I'd prefer keeping it as is.

In commit 56b1a59b47bf7eb80bad5cbaf115e524a4192d57: I'm not convinced this rename makes sense after the addition of `derivehdkey`. I'd prefer keeping it as is.
optout21 (Migrated from github.com) reviewed 2026-10-05 16:03:54 +00:00
optout21 (Migrated from github.com) commented 2026-10-05 16:03:54 +00:00

I don't fully get the "after the addition of derivehdkey" part. Do you meant that after #35069 the two implementations share the same internals? So although ParseHDKeypath is used only in the legacy wallet case, it's internals are also used by the descriptor parsing (ParseKeyPath from descriptor.cpp)? If so, I can agree and will consider it.

I don't fully get the "after the addition of `derivehdkey`" part. Do you meant that after #35069 the two implementations share the same internals? So although `ParseHDKeypath` is used only in the legacy wallet case, it's internals are also used by the descriptor parsing (`ParseKeyPath` from `descriptor.cpp`)? If so, I can agree and will consider it.
achow101 (Migrated from github.com) reviewed 2026-10-06 20:07:19 +00:00
achow101 (Migrated from github.com) commented 2026-10-06 20:07:19 +00:00

Agree with keeping the original naming. There is nothing legacy about this function. That the legacy wallet is currently the only caller should not make a difference for its naming, there may be other unrelated callers in the future.

Agree with keeping the original naming. There is nothing legacy about this function. That the legacy wallet is currently the only caller should not make a difference for its naming, there may be other unrelated callers in the future.
optout21 commented 2026-10-06 21:02:16 +00:00 (Migrated from github.com)

With #35069 the two implementations has been brought together (share the same internal implementation), so the rename to 'Legacy' makes not much sense. Dropped the rename, and updated the OD accordingly. This change is a pure test-only change now. Thanks for the comments!

Re-reviews are welcome -- the rename was the very last commit, it was dropped, but the other 4 commits are unmodified (current changeset is a subset of the previous version).

With #35069 the two implementations has been brought together (share the same internal implementation), so the rename to 'Legacy' makes not much sense. Dropped the rename, and updated the OD accordingly. This change is a pure test-only change now. Thanks for the comments! Re-reviews are welcome -- the rename was the very last commit, it was dropped, but the other 4 commits are unmodified (current changeset is a subset of the previous version).
w0xlt (Migrated from github.com) reviewed 2026-10-22 16:17:27 +00:00
w0xlt (Migrated from github.com) left a comment

reACK dd665be15b

reACK dd665be15b553ef4aa5913c03f4b5e3a53751ce3
Sjors (Migrated from github.com) approved these changes 2026-10-28 06:37:23 +00:00
Sjors (Migrated from github.com) left a comment

Concept ACK

ACK dd665be15b

Concept ACK ACK dd665be15b553ef4aa5913c03f4b5e3a53751ce3
Sjors (Migrated from github.com) commented 2026-10-28 06:33:09 +00:00

In 41bba5e1b0 test: Refactor in bip32_tests: extract test data in an array:

IIUC this temporarily reduces test coverage. The commit message could mention it, or leave it out of the array initially:

diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp
--- a/src/test/bip32_tests.cpp
+++ b/src/test/bip32_tests.cpp
@@ -296,7 +296,6 @@
         {false, "m/0a"},
         {false, "m/0G"},
         {false, "m/h0"},
-        {true,  "m/0h/1h/2h"},
         {true,  "m/0'/0'"},
         {true,  "m/0h/0h"},
         {true,  "m/0'/0h"},
@@ -327,6 +326,13 @@
         std::vector<uint32_t> keypath;
         BOOST_CHECK_EQUAL(ParseHDKeypath(keypath_str, keypath), is_valid);
     }
+
+    std::vector<uint32_t> keypath;
+    BOOST_REQUIRE(ParseHDKeypath("m/0h/1h/2h", keypath));
+    BOOST_REQUIRE_EQUAL(keypath.size(), 3);
+    BOOST_CHECK_EQUAL(keypath[0], BIP32_HARDENED_FLAG);
+    BOOST_CHECK_EQUAL(keypath[1], BIP32_HARDENED_FLAG | 1);
+    BOOST_CHECK_EQUAL(keypath[2], BIP32_HARDENED_FLAG | 2);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
In 41bba5e1b0977d5b4225f77f8ed103b7b145cd11 _test: Refactor in bip32_tests: extract test data in an array_: IIUC this temporarily reduces test coverage. The commit message could mention it, or leave it out of the array initially: ```diff diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -296,7 +296,6 @@ {false, "m/0a"}, {false, "m/0G"}, {false, "m/h0"}, - {true, "m/0h/1h/2h"}, {true, "m/0'/0'"}, {true, "m/0h/0h"}, {true, "m/0'/0h"}, @@ -327,6 +326,13 @@ std::vector<uint32_t> keypath; BOOST_CHECK_EQUAL(ParseHDKeypath(keypath_str, keypath), is_valid); } + + std::vector<uint32_t> keypath; + BOOST_REQUIRE(ParseHDKeypath("m/0h/1h/2h", keypath)); + BOOST_REQUIRE_EQUAL(keypath.size(), 3); + BOOST_CHECK_EQUAL(keypath[0], BIP32_HARDENED_FLAG); + BOOST_CHECK_EQUAL(keypath[1], BIP32_HARDENED_FLAG | 1); + BOOST_CHECK_EQUAL(keypath[2], BIP32_HARDENED_FLAG | 2); } BOOST_AUTO_TEST_SUITE_END() ```
optout21 (Migrated from github.com) reviewed 2026-10-28 07:04:38 +00:00
optout21 (Migrated from github.com) left a comment

Applied a minor change following review -- thanks!

git range-diff dd665be15b553ef4aa5913c03f4b5e3a53751ce3...3ce364124c09157722781720ee60aabb5a99e133

Applied a minor change following review -- thanks! `git range-diff dd665be15b553ef4aa5913c03f4b5e3a53751ce3...3ce364124c09157722781720ee60aabb5a99e133`
optout21 (Migrated from github.com) commented 2026-10-28 07:03:00 +00:00

Indeed! There was a single test case with result check, the first commit removed this check, while the second added it to all test cases. This check was removed temporarily.
For clarity, I simply kept this test case separately in the first commit (integrated into the array in the second). Also mentioned it in the commit message.

Indeed! There was a single test case with result check, the first commit removed this check, while the second added it to all test cases. This check was removed temporarily. For clarity, I simply kept this test case separately in the first commit (integrated into the array in the second). Also mentioned it in the commit message.
Sjors commented 2026-10-28 07:37:45 +00:00 (Migrated from github.com)

re-ACK 3ce3641

re-ACK 3ce3641
achow101 commented 2026-11-04 21:54:55 +00:00 (Migrated from github.com)
ACK 3ce364124c09157722781720ee60aabb5a99e133
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35170
No description provided.