NAME

Bitcoin::Crypto::DerivationPath - Path for BIP32 key derivation

SYNOPSIS

use Bitcoin::Crypto::DerivationPath;

my $derivation_path = Bitcoin::Crypto::DerivationPath->from_string("m/1/2'/3");

say $derivation_path->private;
say $_ for @{$derivation_path->path};

DESCRIPTION

This is a helper object which represents the key derivation path parsed from the m notation. It is returned by "get_path_info" in Bitcoin::Crypto::Util.

INTERFACE

Attributes

private

Required in the constructor. A boolean - whether the path is private (started with lowercase m).

path

Required in the constructor. An array reference of unsigned integers - the derivation path. Hardened keys are greater than or equal to 2^31 (Bitcoin::Crypto::Constants::max_child_keys).

Methods

from_string

$path = Bitcoin::Crypto::DerivationPath->from_string($m_notation_string)

Constructs a new derivation path based on the string.

as_string

$m_notation_string = $object->as_string;

Does the reverse of "from_string".

get_derivation_path

$path = $path->get_derivation_path()

A helper which returns self.

get_path_hardened

$hardened = $path->get_path_hardened()

Returns an array reference. Each item in the array is an array reference with two values, where the first one is the path key and the second one is a boolean indicating whether that key is hardened. The first value will always be within the range 0 .. 2^31 - 1 (unlike "path", which has keys larger than that for hardened keys).