try_derive_child_public_key_with_path

Function try_derive_child_public_key_with_path 

Source
pub fn try_derive_child_public_key_with_path<E, Err>(
    parent_public_key: &ExtendedPublicKey<E>,
    path: impl IntoIterator<Item = Result<NonHardenedIndex, Err>>,
) -> Result<ExtendedPublicKey<E>, Err>
where E: Curve, Stark: HdWallet<E>,
Expand description

Derives a child public key with specified derivation path

Derivation path is a fallible iterator that yields child indexes. If iterator yields an error, it’s propagated to the caller.

Returns:

  • Ok(child_pk) if derivation was successful
  • Err(index_err) if path contained Err(index_err)

Alias to <Stark as HdWallet<E>>::try_derive_child_public_key_with_path

§Example

Parse a path from the string and derive a child without extra allocations:

use hd_wallet::HdWallet;

let path = "1/10/2";
let child_indexes = path.split('/').map(str::parse);
let child_key = hd_wallet::stark::try_derive_child_public_key_with_path(
    &master_public_key,
    child_indexes,
)?;