Struct bitcoin::util::bip32::DerivationPath
source · pub struct DerivationPath(/* private fields */);
Expand description
A BIP-32 derivation path.
Implementations§
source§impl DerivationPath
impl DerivationPath
sourcepub fn master() -> DerivationPath
pub fn master() -> DerivationPath
Returns derivation path for a master key (i.e. empty derivation path)
sourcepub fn is_master(&self) -> bool
pub fn is_master(&self) -> bool
Returns whether derivation path represents master key (i.e. it’s length
is empty). True for m
path.
sourcepub fn child(&self, cn: ChildNumber) -> DerivationPath
pub fn child(&self, cn: ChildNumber) -> DerivationPath
Create a new DerivationPath that is a child of this one.
sourcepub fn into_child(self, cn: ChildNumber) -> DerivationPath
pub fn into_child(self, cn: ChildNumber) -> DerivationPath
Convert into a DerivationPath that is a child of this one.
sourcepub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator<'_> ⓘ
pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator<'_> ⓘ
Get an Iterator over the children of this DerivationPath starting with the given ChildNumber.
sourcepub fn normal_children(&self) -> DerivationPathIterator<'_> ⓘ
pub fn normal_children(&self) -> DerivationPathIterator<'_> ⓘ
Get an Iterator over the unhardened children of this DerivationPath.
sourcepub fn hardened_children(&self) -> DerivationPathIterator<'_> ⓘ
pub fn hardened_children(&self) -> DerivationPathIterator<'_> ⓘ
Get an Iterator over the hardened children of this DerivationPath.
sourcepub fn extend<T: AsRef<[ChildNumber]>>(&self, path: T) -> DerivationPath
pub fn extend<T: AsRef<[ChildNumber]>>(&self, path: T) -> DerivationPath
Concatenate self
with path
and return the resulting new path.
use bitcoin::util::bip32::{DerivationPath, ChildNumber};
use std::str::FromStr;
let base = DerivationPath::from_str("m/42").unwrap();
let deriv_1 = base.extend(DerivationPath::from_str("m/0/1").unwrap());
let deriv_2 = base.extend(&[
ChildNumber::from_normal_idx(0).unwrap(),
ChildNumber::from_normal_idx(1).unwrap()
]);
assert_eq!(deriv_1, deriv_2);
Trait Implementations§
source§impl AsRef<[ChildNumber]> for DerivationPath
impl AsRef<[ChildNumber]> for DerivationPath
source§fn as_ref(&self) -> &[ChildNumber]
fn as_ref(&self) -> &[ChildNumber]
Converts this type into a shared reference of the (usually inferred) input type.
source§impl Clone for DerivationPath
impl Clone for DerivationPath
source§fn clone(&self) -> DerivationPath
fn clone(&self) -> DerivationPath
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for DerivationPath
impl Debug for DerivationPath
source§impl Default for DerivationPath
impl Default for DerivationPath
source§fn default() -> DerivationPath
fn default() -> DerivationPath
Returns the “default value” for a type. Read more
source§impl<'de> Deserialize<'de> for DerivationPath
impl<'de> Deserialize<'de> for DerivationPath
source§fn deserialize<D>(deserializer: D) -> Result<DerivationPath, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<DerivationPath, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for DerivationPath
impl Display for DerivationPath
source§impl<'a> From<&'a [ChildNumber]> for DerivationPath
impl<'a> From<&'a [ChildNumber]> for DerivationPath
source§fn from(numbers: &'a [ChildNumber]) -> Self
fn from(numbers: &'a [ChildNumber]) -> Self
Converts to this type from the input type.
source§impl From<DerivationPath> for Vec<ChildNumber>
impl From<DerivationPath> for Vec<ChildNumber>
source§fn from(path: DerivationPath) -> Self
fn from(path: DerivationPath) -> Self
Converts to this type from the input type.
source§impl From<Vec<ChildNumber, Global>> for DerivationPath
impl From<Vec<ChildNumber, Global>> for DerivationPath
source§fn from(numbers: Vec<ChildNumber>) -> Self
fn from(numbers: Vec<ChildNumber>) -> Self
Converts to this type from the input type.
source§impl FromIterator<ChildNumber> for DerivationPath
impl FromIterator<ChildNumber> for DerivationPath
source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = ChildNumber>,
fn from_iter<T>(iter: T) -> Selfwhere T: IntoIterator<Item = ChildNumber>,
Creates a value from an iterator. Read more
source§impl FromStr for DerivationPath
impl FromStr for DerivationPath
source§impl Hash for DerivationPath
impl Hash for DerivationPath
source§impl<I> Index<I> for DerivationPathwhere
Vec<ChildNumber>: Index<I>,
impl<I> Index<I> for DerivationPathwhere Vec<ChildNumber>: Index<I>,
source§impl<'a> IntoIterator for &'a DerivationPath
impl<'a> IntoIterator for &'a DerivationPath
source§impl Ord for DerivationPath
impl Ord for DerivationPath
source§fn cmp(&self, other: &DerivationPath) -> Ordering
fn cmp(&self, other: &DerivationPath) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<DerivationPath> for DerivationPath
impl PartialEq<DerivationPath> for DerivationPath
source§fn eq(&self, other: &DerivationPath) -> bool
fn eq(&self, other: &DerivationPath) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<DerivationPath> for DerivationPath
impl PartialOrd<DerivationPath> for DerivationPath
source§fn partial_cmp(&self, other: &DerivationPath) -> Option<Ordering>
fn partial_cmp(&self, other: &DerivationPath) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for DerivationPath
impl Serialize for DerivationPath
impl Eq for DerivationPath
impl StructuralEq for DerivationPath
impl StructuralPartialEq for DerivationPath
Auto Trait Implementations§
impl RefUnwindSafe for DerivationPath
impl Send for DerivationPath
impl Sync for DerivationPath
impl Unpin for DerivationPath
impl UnwindSafe for DerivationPath
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> IntoDerivationPath for Twhere
T: Into<DerivationPath>,
impl<T> IntoDerivationPath for Twhere T: Into<DerivationPath>,
source§fn into_derivation_path(self) -> Result<DerivationPath, Error>
fn into_derivation_path(self) -> Result<DerivationPath, Error>
Convers a given type into a
DerivationPath
with possible error