Skip to content

DerivationPath (Class)

A BIP-32 derivation path for hierarchical key derivation.

Represents a path like "m/44'/111111'/0'/0/0" for deriving keys.

__eq__

__eq__(other: object) -> bool

__new__

__new__(path: str) -> DerivationPath

Create a derivation path from a string.

PARAMETER DESCRIPTION
path

A path string (e.g., "m/44'/111111'/0'").

TYPE: str

RETURNS DESCRIPTION
DerivationPath

A new DerivationPath instance.

TYPE: DerivationPath

RAISES DESCRIPTION
Exception

If the path format is invalid.

is_empty

is_empty() -> bool

Check if the path is empty (no components).

RETURNS DESCRIPTION
bool

True if empty.

TYPE: bool

length

length() -> int

Get the number of path components.

RETURNS DESCRIPTION
int

The path length.

TYPE: int

parent

parent() -> Optional[DerivationPath]

Get the parent path (one level up).

RETURNS DESCRIPTION
Optional[DerivationPath]

DerivationPath | None: The parent path, or None if at root.

push

push(child_number: int, hardened: Optional[bool] = None) -> None

Append a child index to the path.

PARAMETER DESCRIPTION
child_number

The child index.

TYPE: int

hardened

Whether to use hardened derivation (default: False).

TYPE: Optional[bool] DEFAULT: None

RAISES DESCRIPTION
Exception

If the child number is invalid.

to_string

to_string() -> str

Convert to string representation.

RETURNS DESCRIPTION
str

The path as a string (e.g., "m/44'/111111'/0'").

TYPE: str