Struct Address

Source
pub struct Address { /* private fields */ }
Expand description

A Zcash Sapling address and associated key data.

Sapling addresses rely on zero-knowledge proofs to validate transactions without revealing transaction details publicly. Each address can have associated keys:

  • Spending Keys: Allow full control (viewing and spending)
  • Viewing Keys: Allow monitoring transactions without spending capability
  • Diversifiers: Enable generating multiple unique addresses from the same key material

§Data Preservation

During wallet migration, the following components are preserved:

  • Address strings: The canonical string representation (e.g., “zs1…”)
  • Incoming Viewing Keys (IVKs): Preserved for transaction monitoring capability
  • Spending Keys: Preserved for spending capability when available
  • Diversifiers: Preserved to maintain address derivation capability
  • HD paths: Preserved to maintain hierarchical wallet structure

Note: Full Viewing Keys (FVKs) are not stored separately because they can be derived from spending keys when needed, and source wallets typically don’t store them separately.

§Examples

// Create a new Sapling shielded address
let mut address = sapling::Address::new("zs1exampleaddress".to_string());

// Associate an incoming viewing key (for monitoring transactions)
let ivk = SaplingIncomingViewingKey::new([0u8; 32]);
address.set_incoming_viewing_key(ivk);

// For addresses with spending capability, add a spending key
let spending_key = SaplingExtendedSpendingKey::new([0u8; 169]);
address.set_spending_key(spending_key);

// Set the diversifier if available
let diversifier_index = Blob::new([0; 11]);
address.set_diversifier_index(diversifier_index);

// Set HD derivation path information
address.set_hd_derivation_path("m/32'/1'/0'/0/5".to_string());

Implementations§

Source§

impl Address

Source

pub fn new(address: String) -> Self

Source

pub fn address(&self) -> &str

Source

pub fn set_address(&mut self, address: String)

Source

pub fn incoming_viewing_key(&self) -> Option<&SaplingIncomingViewingKey>

Returns the Incoming Viewing Key (IVK) associated with this address, if available.

The IVK enables viewing incoming transactions without granting spending capability. During wallet migration, IVKs are preserved exactly as they exist in the source wallet.

§Returns
  • Some(&SaplingIncomingViewingKey) if an IVK is associated with this address
  • None if no IVK is available (common for addresses without viewing capability)
Source

pub fn set_incoming_viewing_key(&mut self, ivk: SaplingIncomingViewingKey)

Associates an Incoming Viewing Key (IVK) with this shielded address.

This method is primarily used during wallet migration to preserve viewing capability for existing addresses. An IVK enables the wallet to scan the blockchain for incoming transactions without revealing transaction details publicly.

§Parameters
  • ivk: The 32-byte Sapling Incoming Viewing Key to associate with this address
Source

pub fn full_viewing_key(&self) -> Option<&SaplingExtendedFullViewingKey>

Source

pub fn set_full_viewing_key(&mut self, key: SaplingExtendedFullViewingKey)

Source

pub fn spending_key(&self) -> Option<&SaplingExtendedSpendingKey>

Source

pub fn set_spending_key(&mut self, key: SaplingExtendedSpendingKey)

Source

pub fn diversifier_index(&self) -> Option<&Blob<11>>

Source

pub fn set_diversifier_index(&mut self, d: Blob<11>)

Source

pub fn hd_derivation_path(&self) -> Option<&str>

Get the HD derivation path for this address, if available

Source

pub fn set_hd_derivation_path(&mut self, path: String)

Set the HD derivation path for this address

Trait Implementations§

Source§

impl Clone for Address

Source§

fn clone(&self) -> Address

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Address

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Address> for Envelope

Source§

fn from(value: Address) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Address

Source§

fn eq(&self, other: &Address) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Envelope> for Address

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(envelope: Envelope) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for Address

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> EnvelopeEncodable for T
where T: Into<Envelope> + Clone,

Source§

fn into_envelope(self) -> Envelope

Converts the value into an envelope by using its Into<Envelope> implementation.

Source§

fn to_envelope(&self) -> Envelope
where Self: Clone,

Converts a reference to this value into a Gordian Envelope. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T