pub struct RelativeDerivationPath(/* private fields */);Expand description
A relative BIP-0032 derivation path.
Implementations§
Source§impl RelativeDerivationPath
impl RelativeDerivationPath
Sourcepub fn contains_hardened_child(&self) -> bool
pub fn contains_hardened_child(&self) -> bool
Returns true if the derivation path contains a hardened child number.
Sourcepub fn child(&self, cn: ChildNumber) -> Self
pub fn child(&self, cn: ChildNumber) -> Self
Constructs a new RelativeDerivationPath that is a child of this one.
Sourcepub fn into_child(self, cn: ChildNumber) -> Self
pub fn into_child(self, cn: ChildNumber) -> Self
Converts into a RelativeDerivationPath that is a child of this one.
Sourcepub fn children_from(
&self,
cn: ChildNumber,
) -> RelativeDerivationPathIterator<'_> ⓘ
pub fn children_from( &self, cn: ChildNumber, ) -> RelativeDerivationPathIterator<'_> ⓘ
Gets an Iterator over the children of this RelativeDerivationPath
starting with the given ChildNumber.
Sourcepub fn normal_children(&self) -> RelativeDerivationPathIterator<'_> ⓘ
pub fn normal_children(&self) -> RelativeDerivationPathIterator<'_> ⓘ
Gets an Iterator over the unhardened children of this RelativeDerivationPath.
Sourcepub fn hardened_children(&self) -> RelativeDerivationPathIterator<'_> ⓘ
pub fn hardened_children(&self) -> RelativeDerivationPathIterator<'_> ⓘ
Gets an Iterator over the hardened children of this RelativeDerivationPath.
Sourcepub fn join<T: AsRef<[ChildNumber]>>(&self, path: T) -> Self
pub fn join<T: AsRef<[ChildNumber]>>(&self, path: T) -> Self
Joins self with path and returns the resulting new path.
use bitcoin_key_expression::bip32::{RelativeDerivationPath, ChildNumber};
let base = "42".parse::<RelativeDerivationPath>().unwrap();
let deriv_1 = base.join("0/1".parse::<RelativeDerivationPath>().unwrap());
let deriv_2 = base.join(&[
ChildNumber::ZERO_NORMAL,
ChildNumber::ONE_NORMAL
]);
assert_eq!(deriv_1, deriv_2);Sourcepub fn to_u32_vec(&self) -> Vec<u32>
pub fn to_u32_vec(&self) -> Vec<u32>
Returns the derivation path as a vector of raw BIP-0032 u32 child numbers. Unhardened elements are copied as is. 0x80000000 is added to the hardened elements.
use bitcoin_key_expression::bip32::RelativeDerivationPath;
let path = "84'/0'/0'/0/1".parse::<RelativeDerivationPath>().unwrap();
const HARDENED: u32 = 0x80000000;
assert_eq!(path.to_u32_vec(), vec![84 + HARDENED, HARDENED, HARDENED, 0, 1]);Sourcepub fn from_u32_slice(numbers: &[u32]) -> Self
pub fn from_u32_slice(numbers: &[u32]) -> Self
Constructs a new derivation path from a slice of raw BIP-0032 u32 child numbers.
use bitcoin_key_expression::bip32::RelativeDerivationPath;
const HARDENED: u32 = 0x80000000;
let expected = vec![84 + HARDENED, HARDENED, HARDENED, 0, 1];
let path = RelativeDerivationPath::from_u32_slice(expected.as_slice());
assert_eq!(path.to_u32_vec(), expected);Trait Implementations§
Source§impl<'a> Arbitrary<'a> for RelativeDerivationPath
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for RelativeDerivationPath
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl AsRef<[ChildNumber]> for RelativeDerivationPath
impl AsRef<[ChildNumber]> for RelativeDerivationPath
Source§fn as_ref(&self) -> &[ChildNumber]
fn as_ref(&self) -> &[ChildNumber]
Source§impl Clone for RelativeDerivationPath
impl Clone for RelativeDerivationPath
Source§fn clone(&self) -> RelativeDerivationPath
fn clone(&self) -> RelativeDerivationPath
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelativeDerivationPath
impl Debug for RelativeDerivationPath
Source§impl Default for RelativeDerivationPath
impl Default for RelativeDerivationPath
Source§fn default() -> RelativeDerivationPath
fn default() -> RelativeDerivationPath
Source§impl<'de> Deserialize<'de> for RelativeDerivationPath
impl<'de> Deserialize<'de> for RelativeDerivationPath
Source§fn deserialize<D>(deserializer: D) -> Result<RelativeDerivationPath, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<RelativeDerivationPath, D::Error>where
D: Deserializer<'de>,
Source§impl Display for RelativeDerivationPath
impl Display for RelativeDerivationPath
impl Eq for RelativeDerivationPath
Source§impl<'a> From<&'a [ChildNumber]> for RelativeDerivationPath
impl<'a> From<&'a [ChildNumber]> for RelativeDerivationPath
Source§fn from(numbers: &'a [ChildNumber]) -> Self
fn from(numbers: &'a [ChildNumber]) -> Self
Source§impl From<AbsoluteDerivationPath> for RelativeDerivationPath
impl From<AbsoluteDerivationPath> for RelativeDerivationPath
Source§fn from(path: AbsoluteDerivationPath) -> Self
fn from(path: AbsoluteDerivationPath) -> Self
Source§impl From<RelativeDerivationPath> for Vec<ChildNumber>
impl From<RelativeDerivationPath> for Vec<ChildNumber>
Source§fn from(path: RelativeDerivationPath) -> Self
fn from(path: RelativeDerivationPath) -> Self
Source§impl From<RelativeDerivationPath> for AbsoluteDerivationPath
impl From<RelativeDerivationPath> for AbsoluteDerivationPath
Source§fn from(path: RelativeDerivationPath) -> Self
fn from(path: RelativeDerivationPath) -> Self
Source§impl From<Vec<ChildNumber>> for RelativeDerivationPath
impl From<Vec<ChildNumber>> for RelativeDerivationPath
Source§fn from(numbers: Vec<ChildNumber>) -> Self
fn from(numbers: Vec<ChildNumber>) -> Self
Source§impl FromIterator<ChildNumber> for RelativeDerivationPath
impl FromIterator<ChildNumber> for RelativeDerivationPath
Source§fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = ChildNumber>,
fn from_iter<T>(iter: T) -> Selfwhere
T: IntoIterator<Item = ChildNumber>,
Source§impl FromStr for RelativeDerivationPath
impl FromStr for RelativeDerivationPath
Source§impl Hash for RelativeDerivationPath
impl Hash for RelativeDerivationPath
Source§impl<I> Index<I> for RelativeDerivationPath
impl<I> Index<I> for RelativeDerivationPath
Source§impl<'a> IntoIterator for &'a RelativeDerivationPath
impl<'a> IntoIterator for &'a RelativeDerivationPath
Source§impl Ord for RelativeDerivationPath
impl Ord for RelativeDerivationPath
Source§fn cmp(&self, other: &RelativeDerivationPath) -> Ordering
fn cmp(&self, other: &RelativeDerivationPath) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RelativeDerivationPath
impl PartialEq for RelativeDerivationPath
Source§fn eq(&self, other: &RelativeDerivationPath) -> bool
fn eq(&self, other: &RelativeDerivationPath) -> bool
self and other values to be equal, and is used by ==.