Bitcoin Core 31.99.0
P2P Digital Currency
Classes | Functions | Variables
bip32.h File Reference
#include <cstdint>
#include <span>
#include <string>
#include <util/expected.h>
#include <vector>
Include dependency graph for bip32.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  KeyPathElement
 

Functions

util::Expected< KeyPathElement, std::string > ParseKeyPathElement (std::span< const char > elem)
 Parse a single key path element like "0", "0'", or "0h". More...
 
bool ParseHDKeypath (const std::string &keypath_str, std::vector< uint32_t > &keypath)
 Parse an HD keypaths like "m/7/0'/2000". More...
 
std::string WriteHDKeypath (const std::vector< uint32_t > &keypath, bool apostrophe=false)
 Write HD keypaths as strings. More...
 
std::string FormatHDKeypath (const std::vector< uint32_t > &path, bool apostrophe=false)
 
bool HasHardenedDerivation (std::span< const uint32_t > keypath)
 Whether a parsed HD keypath contains at least one hardened derivation step. More...
 

Variables

static constexpr uint32_t BIP32_UNHARDENED_FLAG = 0x0
 BIP32 unhardened derivation index (no high bit set) More...
 
static constexpr uint32_t BIP32_HARDENED_FLAG = 0x80000000
 BIP32 hardened derivation flag (2^31) More...
 

Function Documentation

◆ FormatHDKeypath()

std::string FormatHDKeypath ( const std::vector< uint32_t > &  path,
bool  apostrophe = false 
)

Definition at line 62 of file bip32.cpp.

Here is the caller graph for this function:

◆ HasHardenedDerivation()

bool HasHardenedDerivation ( std::span< const uint32_t >  keypath)

Whether a parsed HD keypath contains at least one hardened derivation step.

Definition at line 77 of file bip32.cpp.

Here is the caller graph for this function:

◆ ParseHDKeypath()

bool ParseHDKeypath ( const std::string &  keypath_str,
std::vector< uint32_t > &  keypath 
)

Parse an HD keypaths like "m/7/0'/2000".

Definition at line 41 of file bip32.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ParseKeyPathElement()

util::Expected< KeyPathElement, std::string > ParseKeyPathElement ( std::span< const char >  elem)

Parse a single key path element like "0", "0'", or "0h".

Returns the derivation index and hardened status, or an error message.

Definition at line 17 of file bip32.cpp.

Here is the caller graph for this function:

◆ WriteHDKeypath()

std::string WriteHDKeypath ( const std::vector< uint32_t > &  keypath,
bool  apostrophe = false 
)

Write HD keypaths as strings.

Definition at line 72 of file bip32.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BIP32_HARDENED_FLAG

constexpr uint32_t BIP32_HARDENED_FLAG = 0x80000000
staticconstexpr

BIP32 hardened derivation flag (2^31)

Definition at line 17 of file bip32.h.

◆ BIP32_UNHARDENED_FLAG

constexpr uint32_t BIP32_UNHARDENED_FLAG = 0x0
staticconstexpr

BIP32 unhardened derivation index (no high bit set)

Definition at line 15 of file bip32.h.