bip32_path
Module for BIP32 paths parsing and handling.
- class Bip32PathConst
Bases:
object
Class container for BIP32 path constants.
- HARDENED_CHARS: Tuple[str, str, str] = ("'", 'h', 'p')
- MASTER_CHAR: str = 'm'
- class Bip32Path(elems: Optional[Sequence[Union[int, Bip32KeyIndex]]] = None, is_absolute: bool = True)
Bases:
object
BIP32 path class. It represents a BIP-0032 path.
- m_elems: List[Bip32KeyIndex]
- m_is_absolute: bool
- AddElem(elem: Union[int, Bip32KeyIndex]) Bip32Path
Return a new path object with the specified element added.
- Parameters:
elem (str or Bip32KeyIndex) – Path element
- Returns:
Bip32Path object
- Return type:
Bip32Path object
- Raises:
Bip32PathError – If the path element is not valid
- IsAbsolute() bool
Get if absolute path.
- Returns:
True if absolute path, false otherwise
- Return type:
bool
- Length() int
Get the number of elements of the path.
- Returns:
Number of elements
- Return type:
int
- ToList() List[int]
Get the path as a list of integers.
- Returns:
Path as a list of integers
- Return type:
list[int]
- ToStr() str
Get the path as a string.
- Returns:
Path as a string
- Return type:
str
- __str__() str
Get the path as a string.
- Returns:
Path as a string
- Return type:
str
- __getitem__(idx: int) Bip32KeyIndex
Get the specified element index.
- Parameters:
idx (int) – Element index
- Returns:
Bip32KeyIndex object
- Return type:
Bip32KeyIndex object
- __iter__() Iterator[Bip32KeyIndex]
Get the iterator to the current element.
- Returns:
Iterator to the current element
- Return type:
Iterator object
- class Bip32PathParser
Bases:
object
BIP32 path parser class. It parses a BIP-0032 path and returns a Bip32Path object.
- static Parse(path: str) Bip32Path
Parse a path and return a Bip32Path object.
- Parameters:
path (str) – Path
- Returns:
Bip32Path object
- Return type:
Bip32Path object
- Raises:
Bip32PathError – If the path is not valid