[][src]Struct hdpath::StandardHDPath

pub struct StandardHDPath { /* fields omitted */ }

Standard HD Path for BIP-44, BIP-49, BIP-84 and similar. For path as m/purpose'/coin_type'/account'/change/address_index, like m/44'/0'/0'/0/0.

Create new

use hdpath::{StandardHDPath, Purpose};

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

Parse string

use hdpath::{StandardHDPath, Purpose};

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

Implementations

impl StandardHDPath[src]

pub fn new(
    purpose: Purpose,
    coin_type: u32,
    account: u32,
    change: u32,
    index: u32
) -> StandardHDPath
[src]

Create a standard HD Path. Panics if any of the values is incorrect

use hdpath::{StandardHDPath, Purpose};

let hdpath =  StandardHDPath::new(Purpose::Witness, 0, 2, 0, 0);

pub fn try_new(
    purpose: Purpose,
    coin_type: u32,
    account: u32,
    change: u32,
    index: u32
) -> Result<StandardHDPath, (String, u32)>
[src]

Try to create a standard HD Path. Return error (field_name, invalid_value) if a field has an incorrect value.

use hdpath::{StandardHDPath, Purpose};


let index = 0x80000100; //received from unreliable source
match StandardHDPath::try_new(Purpose::Witness, 0, 2, 0, index) {
    Ok(hdpath) => { }
    Err(err) => println!("Invalid value {} = {}", err.0, err.1)
}

pub fn purpose(&self) -> &Purpose[src]

pub fn coin_type(&self) -> u32[src]

pub fn account(&self) -> u32[src]

pub fn change(&self) -> u32[src]

pub fn index(&self) -> u32[src]

pub fn to_bytes(&self) -> Vec<u8>[src]

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

pub fn from_bytes(path: &[u8]) -> Result<Self, Error>[src]

Decode from bytes, where first byte is number of elements in path (always 5 for StandardHDPath) following by 4-byte BE values

Trait Implementations

impl Clone for StandardHDPath[src]

impl Debug for StandardHDPath[src]

impl Default for StandardHDPath[src]

impl Eq for StandardHDPath[src]

impl From<StandardHDPath> for CustomHDPath[src]

impl FromStr for StandardHDPath[src]

type Err = Error

The associated error which can be returned from parsing.

impl Ord for StandardHDPath[src]

impl PartialEq<StandardHDPath> for StandardHDPath[src]

impl PartialOrd<StandardHDPath> for StandardHDPath[src]

impl StructuralEq for StandardHDPath[src]

impl StructuralPartialEq for StandardHDPath[src]

impl ToString for StandardHDPath[src]

impl<'_> TryFrom<&'_ str> for StandardHDPath[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<CustomHDPath> for StandardHDPath[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.