Struct SaplingSentOutput

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

Represents a sent output in a Sapling shielded transaction within a Zcash wallet.

SaplingSentOutput stores the plaintext details of a Sapling note that was sent by the wallet, which are not recoverable from the blockchain after transmission. This information enables selective disclosure, allowing a sender to prove they made a payment to a specific shielded address without revealing additional transaction details.

§Zcash Concept Relation

In Zcash’s Sapling protocol (activated in October 2018):

  • Shielded transactions encrypt transaction details on the blockchain using zk-SNARKs
  • Notes are the fundamental unit of value transfer, similar to UTXOs in transparent transactions
  • Sent output information is stored by the sender’s wallet to enable proofs of payment

Each sent output contains components of the Sapling note:

  • Diversifier: Part of the recipient’s shielded address derivation
  • Public key: The recipient’s public key for the transaction
  • Value: The amount of ZEC transferred
  • Rcm: Random commitment material used to construct the note commitment

§Data Preservation

During wallet migration, sent output information must be preserved to maintain the ability to generate payment proofs for regulatory compliance, auditing, or other selective disclosure purposes. The sending wallet is the only entity that has this information in plaintext form.

§Examples

// Create a new sent output
let mut sent_output = SaplingSentOutput::new();

let value = Amount::from_u64(5000000)?; // 0.05 ZEC
sent_output.set_value(value);

// Access the components
let amount = sent_output.value();
let zats: i64 = amount.into();
assert_eq!(zats, 5000000);

Implementations§

Source§

impl SaplingSentOutput

Source

pub fn new() -> Self

Creates a new SaplingSentOutput with default values.

This constructor initializes a SaplingSentOutput with empty default values for all fields. In practical use, these values would be set using the setter methods before the object is used.

§Returns

A new SaplingSentOutput instance with default values.

§Examples
let sent_output = SaplingSentOutput::new();
Source

pub fn from_parts( index: usize, recipient_address: String, value: Amount, memo: Option<Memo>, ) -> Self

Creates a new SaplingSentOutput from its constituent parts.

Source

pub fn recipient_address(&self) -> &str

Returns the string representation of the address used in construction of the output.

This will be either a Sapling address or a Unified address with a Sapling receiver. We preserve the original address string because in the case of Unified addresses, it is not otherwise possible to reconstruct the data for receivers other than the Sapling receiver, and as a consequence the recipient address in a restored wallet would appear different than in the source wallet.

Source

pub fn set_recipient_address(&mut self, recipient_address: String)

Sets the string representation of the address used in construction of the output.

Source

pub fn value(&self) -> Amount

Returns the value (amount) of ZEC sent in this output.

This represents the amount of ZEC transferred in this specific note, measured in zatoshis (1 ZEC = 10^8 zatoshis).

§Returns

The amount of ZEC as an Amount.

§Examples
let mut sent_output = SaplingSentOutput::new();
sent_output.set_value(Amount::from_u64(10_000_000)?); // 0.1 ZEC

let value = sent_output.value();
let zats: i64 = value.into();
assert_eq!(zats, 10_000_000);
Source

pub fn set_value(&mut self, value: Amount)

Sets the value (amount) of ZEC for this sent output.

§Arguments
  • value - The amount of ZEC to set
§Examples
let mut sent_output = SaplingSentOutput::new();
let amount = Amount::from_u64(50_000_000)?; // 0.5 ZEC
sent_output.set_value(amount);
Source

pub fn memo(&self) -> Option<&Memo>

Returns the memo associated with the output, if known.

Source

pub fn set_memo(&mut self, memo: Option<Memo>)

Sets the memo associated with the output.

Trait Implementations§

Source§

impl Clone for SaplingSentOutput

Source§

fn clone(&self) -> SaplingSentOutput

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 SaplingSentOutput

Source§

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

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

impl Default for SaplingSentOutput

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<SaplingSentOutput> for Envelope

Source§

fn from(value: SaplingSentOutput) -> Self

Converts to this type from the input type.
Source§

impl Indexed for SaplingSentOutput

Source§

fn index(&self) -> usize

Source§

fn set_index(&mut self, index: usize)

Source§

impl PartialEq for SaplingSentOutput

Source§

fn eq(&self, other: &SaplingSentOutput) -> 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 SaplingSentOutput

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 Eq for SaplingSentOutput

Source§

impl StructuralPartialEq for SaplingSentOutput

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