Bitcoin Core
32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
src
test
fuzz
parse_hd_keypath.cpp
Go to the documentation of this file.
1
// Copyright (c) 2009-present The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
test/fuzz/FuzzedDataProvider.h
>
6
#include <
test/fuzz/fuzz.h
>
7
#include <
test/fuzz/util.h
>
8
#include <
util/bip32.h
>
9
10
#include <cassert>
11
#include <cstdint>
12
#include <vector>
13
14
FUZZ_TARGET
(
parse_hd_keypath
)
15
{
16
const
std::string
keypath_str
(buffer.begin(), buffer.end());
17
std::vector<uint32_t>
keypath
;
18
(
void
)
ParseHDKeypath
(
keypath_str
,
keypath
);
19
20
FuzzedDataProvider
fuzzed_data_provider
(buffer.data(), buffer.size());
21
const
std::vector<uint32_t>
random_keypath
=
ConsumeRandomLengthIntegralVector<uint32_t>
(
fuzzed_data_provider
);
22
23
// Roundtrip WriteHDKeypath() and ParseHDKeypath()
24
for
(
const
bool
apostrophe
: {
false
,
true
}) {
25
std::vector<uint32_t>
roundtrip
;
26
const
std::string
written
{
WriteHDKeypath
(
random_keypath
,
apostrophe
)};
27
assert
(
ParseHDKeypath
(
written
,
roundtrip
));
28
assert
(
roundtrip
==
random_keypath
);
29
}
30
}
FuzzedDataProvider.h
ParseHDKeypath
bool ParseHDKeypath(const std::string &keypath_str, std::vector< uint32_t > &keypath)
Parse an HD keypaths like "m/7/0'/2000".
Definition
bip32.cpp:41
WriteHDKeypath
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath, bool apostrophe)
Write HD keypaths as strings.
Definition
bip32.cpp:72
bip32.h
FuzzedDataProvider
Definition
FuzzedDataProvider.h:32
fuzz.h
FUZZ_TARGET
#define FUZZ_TARGET(...)
Definition
fuzz.h:35
util.h
Ticks
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition
time.h:82
assert
assert(!tx.IsCoinBase())
fuzzed_data_provider
FuzzedDataProvider & fuzzed_data_provider
Definition
fees.cpp:46
Generated on Mon Nov 2 2026 20:00:31 for Bitcoin Core by
1.9.8