AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 15 Bitcoin

Merge bitcoin/bitcoin#35170: test: Better test coverage for ParseHDKeypath()

Public commit record

What the developer wrote

Authored by merge-script

91/100 · Strong
Merge bitcoin/bitcoin#35170: test: Better test coverage for ParseHDKeypath()

3ce364124c09157722781720ee60aabb5a99e133 test: bip32_tests: Add some more tests cases (optout)
72414a709d57308e4fe69d5d96188beeeebb6855 test: bip32_tests: Add round-trip tests (optout)
60bdfdb19e98b7574b0a2c565f81c8dfec514e2f test: bip32_tests: Add expected result checks (optout)
7b5ce9c529bd38f29c1216a93fd44ae62edb56bb test: Refactor in bip32_tests: extract test data in an array (optout)

Pull request description:

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.

ACKs for top commit:
Sjors:
re-ACK 3ce3641
achow101:
ACK 3ce364124c09157722781720ee60aabb5a99e133

Tree-SHA512: 4b0450da1c5cccf12e15aeb272c927ef3b119466ae14d9fcea3e34c5ef6e02068c43e22d68a4433c9d1a4f3c111c799f8165c13147a7317706b03e056dfb86dd
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit only adds and improves unit tests for the ParseHDKeypath() function. It does not change any production code, so it cannot introduce a security vulnerability or fix one directly. The change makes the tests verify the actual parsed output and adds round-trip checks, which improves test quality but has no runtime security impact on its own.

Recommended action

No security action required. This is a test-only improvement. Consider reviewing whether the improved tests reveal any latent issues in ParseHDKeypath() or related descriptor parsing code, but the commit itself is benign.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.