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
impl SaplingSentOutput
Sourcepub fn new() -> Self
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();
Sourcepub fn from_parts(
index: usize,
recipient_address: String,
value: Amount,
memo: Option<Memo>,
) -> Self
pub fn from_parts( index: usize, recipient_address: String, value: Amount, memo: Option<Memo>, ) -> Self
Creates a new SaplingSentOutput
from its constituent parts.
Sourcepub fn recipient_address(&self) -> &str
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.
Sourcepub fn set_recipient_address(&mut self, recipient_address: String)
pub fn set_recipient_address(&mut self, recipient_address: String)
Sets the string representation of the address used in construction of the output.
Sourcepub fn value(&self) -> Amount
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);
Trait Implementations§
Source§impl Clone for SaplingSentOutput
impl Clone for SaplingSentOutput
Source§fn clone(&self) -> SaplingSentOutput
fn clone(&self) -> SaplingSentOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SaplingSentOutput
impl Debug for SaplingSentOutput
Source§impl Default for SaplingSentOutput
impl Default for SaplingSentOutput
Source§impl From<SaplingSentOutput> for Envelope
impl From<SaplingSentOutput> for Envelope
Source§fn from(value: SaplingSentOutput) -> Self
fn from(value: SaplingSentOutput) -> Self
Source§impl Indexed for SaplingSentOutput
impl Indexed for SaplingSentOutput
Source§impl PartialEq for SaplingSentOutput
impl PartialEq for SaplingSentOutput
Source§impl TryFrom<Envelope> for SaplingSentOutput
impl TryFrom<Envelope> for SaplingSentOutput
impl Eq for SaplingSentOutput
impl StructuralPartialEq for SaplingSentOutput
Auto Trait Implementations§
impl Freeze for SaplingSentOutput
impl RefUnwindSafe for SaplingSentOutput
impl Send for SaplingSentOutput
impl Sync for SaplingSentOutput
impl Unpin for SaplingSentOutput
impl UnwindSafe for SaplingSentOutput
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