Struct Address

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

A transparent address on the Zcash network.

An Address represents a transparent Zcash address, having an encoding that begins with ‘t’ and that functions similarly to Bitcoin addresses. These addresses offer no privacy features - all spends from and receives to transparent addresses are visible on the blockchain.

§Zcash Concept Relation

Zcash supports transparent addresses for backward compatibility with Bitcoin infrastructure. Two main types exist:

  • P2PKH (Pay to Public Key Hash): Standard addresses that begin with ‘t1’
  • P2SH (Pay to Script Hash): Script-based addresses that begin with ‘t3’

Transparent addresses make transaction data publicly visible, including:

  • Sender address
  • Receiver address
  • Transaction amount
  • Transaction time

§Data Preservation

During wallet migration, the following components are preserved:

  • Address string: The canonical string representation (e.g., “t1…”)
  • Spending authority: Private key information needed to spend funds
  • Derivation information: HD wallet path data for derived addresses

§Examples

// Create a new transparent address
let mut address = transparent::Address::new("t1exampleaddress");

// Set the spending authority (usually a derived key for HD wallets)
let spend_authority = TransparentSpendAuthority::Derived;
address.set_spend_authority(spend_authority);

// For HD wallets, set the derivation information
let change = NonHardenedChildIndex::from(0u32); // external chain
let address_index = NonHardenedChildIndex::from(3u32); // 4th address in chain
let derivation_info = DerivationInfo::new(change, address_index);
address.set_derivation_info(derivation_info);

// Access the address string
assert_eq!(address.address(), "t1exampleaddress");

Implementations§

Source§

impl Address

Source

pub fn new(address: impl Into<String>) -> Self

Creates a new transparent address with the given address string.

This constructor creates a basic transparent address with just the address string. Spending authority and derivation information can be added later if available.

§Arguments
  • address - The transparent address string (e.g., “t1…”)
§Examples
let address = transparent::Address::new("t1exampleaddress");
assert_eq!(address.address(), "t1exampleaddress");
Source

pub fn address(&self) -> &str

Returns the transparent address string.

§Returns

The canonical string representation of this transparent address.

Source

pub fn spend_authority(&self) -> Option<&TransparentSpendAuthority>

Returns the spending authority for this address, if available.

The spending authority contains the information needed to spend funds from this address, either as a direct key or as a reference to a derived key.

§Returns
  • Some(&TransparentSpendAuthority) if spending capability is available
  • None if this is a watch-only address without spending capability
Source

pub fn set_spend_authority( &mut self, spend_authority: TransparentSpendAuthority, )

Sets the spending authority for this address.

This method associates spending capability with the address, allowing funds to be spent from it. The authority can be either a direct key or a reference to a derived key from an HD wallet.

§Arguments
  • spend_authority - The spending authority to associate with this address
Source

pub fn derivation_info(&self) -> Option<&DerivationInfo>

Returns the HD wallet derivation information for this address, if available.

For addresses derived from an HD wallet seed, this provides the path information necessary to regenerate the address.

§Returns
  • Some(&DerivationInfo) if this address has derivation information
  • None if this is not an HD wallet derived address or the information is unavailable
Source

pub fn set_derivation_info(&mut self, derivation_info: DerivationInfo)

Sets the HD wallet derivation information for this address.

This method associates HD path information with the address, which is useful for addresses derived from a hierarchical deterministic wallet.

§Arguments
  • derivation_info - The derivation path information to associate with 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