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
impl Address
Sourcepub fn new(address: impl Into<String>) -> Self
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");
Sourcepub fn address(&self) -> &str
pub fn address(&self) -> &str
Returns the transparent address string.
§Returns
The canonical string representation of this transparent address.
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 availableNone
if this is a watch-only address without spending capability
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
Sourcepub fn derivation_info(&self) -> Option<&DerivationInfo>
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 informationNone
if this is not an HD wallet derived address or the information is unavailable
Sourcepub fn set_derivation_info(&mut self, derivation_info: DerivationInfo)
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§
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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