pub struct DerivationPath { /* private fields */ }Expand description
BIP32 derivation path.
§Example
use rustywallet_hd::DerivationPath;
// Parse a BIP44 Bitcoin path
let path = DerivationPath::parse("m/44'/0'/0'/0/0").unwrap();
assert_eq!(path.to_string(), "m/44'/0'/0'/0/0");
// Use helper for BIP44 Bitcoin
let btc_path = DerivationPath::bip44_bitcoin(0, 0, 0);
assert_eq!(btc_path.to_string(), "m/44'/0'/0'/0/0");Implementations§
Source§impl DerivationPath
impl DerivationPath
Sourcepub fn parse(path: &str) -> Result<Self, HdError>
pub fn parse(path: &str) -> Result<Self, HdError>
Parse a derivation path from string.
Supports both ' and h notation for hardened derivation.
Sourcepub fn bip44_bitcoin(account: u32, change: u32, index: u32) -> Self
pub fn bip44_bitcoin(account: u32, change: u32, index: u32) -> Self
Create BIP44 path for Bitcoin: m/44’/0’/account’/change/index
Sourcepub fn bip44_ethereum(account: u32, index: u32) -> Self
pub fn bip44_ethereum(account: u32, index: u32) -> Self
Create BIP44 path for Ethereum: m/44’/60’/account’/0/index
Sourcepub fn components(&self) -> &[ChildNumber]
pub fn components(&self) -> &[ChildNumber]
Get path components.
Sourcepub fn has_hardened(&self) -> bool
pub fn has_hardened(&self) -> bool
Check if path contains any hardened derivation.
Sourcepub fn child(&self, child: ChildNumber) -> Self
pub fn child(&self, child: ChildNumber) -> Self
Append a child number to the path.
Trait Implementations§
Source§impl Clone for DerivationPath
impl Clone for DerivationPath
Source§fn clone(&self) -> DerivationPath
fn clone(&self) -> DerivationPath
Returns a duplicate 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 Display for DerivationPath
impl Display for DerivationPath
Source§impl FromStr for DerivationPath
impl FromStr for DerivationPath
Source§impl PartialEq for DerivationPath
impl PartialEq for DerivationPath
impl Eq for DerivationPath
impl StructuralPartialEq for DerivationPath
Auto Trait Implementations§
impl Freeze for DerivationPath
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