pub struct DerivationInfo { /* private fields */ }
Expand description
Hierarchical deterministic (HD) derivation information for wallet addresses.
DerivationInfo
captures the BIP-44/ZIP-32 derivation path components for
addresses in a hierarchical deterministic wallet. It specifically tracks the
last two non-hardened components of an HD path:
- Whether it’s a change address (typically 0 = external, 1 = change)
- The address index within that chain
§Zcash Concept Relation
Zcash follows BIP-44 and ZIP-32 for hierarchical deterministic key derivation, with paths typically structured as:
m / purpose' / coin_type' / account' / change / address_index
Where:
purpose'
is typically 44’ for transparent or 32’ for shieldedcoin_type'
is 133’ for Zcashaccount'
is the account number (hardened)change
is 0 for external addresses or 1 for internal (change) addressesaddress_index
is the sequential index of the address
The apostrophes (’) indicate hardened derivation, which prevents parent key compromise from affecting child keys.
§Data Preservation
During wallet migration, this information is preserved to maintain the hierarchical relationship between keys and the ability to derive the same addresses in the new wallet.
§Examples
// Create derivation info for an external address (change = 0)
// with index 5
let change = NonHardenedChildIndex::from(0u32); // external
let address_index = NonHardenedChildIndex::from(5u32);
// We need a constructor to create DerivationInfo
let derivation_info = DerivationInfo::new(change, address_index);
// The values can be retrieved for further derivation or reference
assert_eq!(u32::from(derivation_info.change()), 0);
assert_eq!(u32::from(derivation_info.address_index()), 5);
Implementations§
Source§impl DerivationInfo
impl DerivationInfo
Sourcepub fn new(
change: NonHardenedChildIndex,
address_index: NonHardenedChildIndex,
) -> Self
pub fn new( change: NonHardenedChildIndex, address_index: NonHardenedChildIndex, ) -> Self
Creates a new DerivationInfo
with the specified change and address index components.
§Arguments
change
- The change level index (0 for external, 1 for internal/change)address_index
- The sequential index of the address within its chain
§Examples
// Create derivation info for an external address (change = 0)
// with index 5
let change = NonHardenedChildIndex::from(0u32);
let address_index = NonHardenedChildIndex::from(5u32);
let derivation_info = DerivationInfo::new(change, address_index);
Sourcepub fn change(&self) -> NonHardenedChildIndex
pub fn change(&self) -> NonHardenedChildIndex
Returns the change component of the derivation path.
In BIP-44/ZIP-32, the change component is:
- 0 for external (receiving) addresses
- 1 for internal (change) addresses
§Returns
The change index as a NonHardenedChildIndex
Sourcepub fn address_index(&self) -> NonHardenedChildIndex
pub fn address_index(&self) -> NonHardenedChildIndex
Returns the address index component of the derivation path.
This is the sequential index of an address within its chain (external or change). Each new address in a wallet typically increments this index.
§Returns
The address index as a NonHardenedChildIndex
Trait Implementations§
Source§impl Clone for DerivationInfo
impl Clone for DerivationInfo
Source§fn clone(&self) -> DerivationInfo
fn clone(&self) -> DerivationInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for DerivationInfo
impl Debug for DerivationInfo
Source§impl From<DerivationInfo> for Envelope
impl From<DerivationInfo> for Envelope
Source§fn from(value: DerivationInfo) -> Self
fn from(value: DerivationInfo) -> Self
Source§impl PartialEq for DerivationInfo
impl PartialEq for DerivationInfo
Source§impl TryFrom<Envelope> for DerivationInfo
impl TryFrom<Envelope> for DerivationInfo
impl Copy for DerivationInfo
impl Eq for DerivationInfo
impl StructuralPartialEq for DerivationInfo
Auto Trait Implementations§
impl Freeze for DerivationInfo
impl RefUnwindSafe for DerivationInfo
impl Send for DerivationInfo
impl Sync for DerivationInfo
impl Unpin for DerivationInfo
impl UnwindSafe for DerivationInfo
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnvelopeEncodable for T
impl<T> EnvelopeEncodable for T
Source§fn into_envelope(self) -> Envelope
fn into_envelope(self) -> Envelope
Converts the value into an envelope by using its Into<Envelope>
implementation.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more