pub struct AccountHDPath { /* private fields */ }
Expand description

Account-only HD Path for BIP-44, BIP-49, BIP-84 and similar.

It’s not supposed to be used to derive actual addresses, but only to build other path based on this

Represents m/purpose'/coin_type'/account'/x/x, like m/44'/0'/0'/x/x.

Create new

use hdpath::{AccountHDPath, Purpose};

//creates path m/84'/0'/0'
let hd_account = AccountHDPath::new(Purpose::Witness, 0, 0);

Parse string

use hdpath::{AccountHDPath};

//creates path m/84'/0'/0'
let hd_account = AccountHDPath::from_str("m/84'/0'/0'").unwrap();

Internal type and index can be explicitly market as unused (which is the default format for converting it into a string).

use hdpath::{AccountHDPath};

//creates path m/84'/0'/0'
let hd_account = AccountHDPath::from_str("m/84'/0'/0'/x/x").unwrap();

Create actial path

use hdpath::{AccountHDPath, Purpose, StandardHDPath};

let hd_account = AccountHDPath::from_str("m/84'/0'/0'").unwrap();
// gives hd path m/84'/0'/0'/0/4
let hd_path: StandardHDPath = hd_account.address_at(0, 4).unwrap();

Implementations

Derive path to an address withing this account path

let hd_account = AccountHDPath::try_from("m/84'/0'/0'").unwrap();
// gives hd path m/84'/0'/0'/0/4
let hd_path: StandardHDPath = hd_account.address_at(0, 4).unwrap();

Return error (field_name, invalid_value) if the field has an incorrect value. It may happed if change or index are in hardened space.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Size of the HD Path

Get element as the specified position. The implementation must return Some<PathValue> for all values up to len(). And return None if the position if out of bounds. Read more

Encode as bytes, where first byte is number of elements in path (always 5 for StandardHDPath) following by 4-byte BE values Read more

Get parent HD Path. Return None if the current path is empty (i.e. already at the top) Read more

Convert current to CustomHDPath structure Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.