pub struct Account { /* private fields */ }
Expand description
A logical grouping of addresses and transaction history within a wallet.
Account
represents a distinct subdivision of wallet functionality, similar to how
bank accounts work within a single banking relationship. Each account can have its own set of
addresses, relevant transactions, and sent output information that cannot be recovered
from the blockchain.
§Zcash Concept Relation
In Zcash’s hierarchical deterministic (HD) wallet structure:
- Account Subdivision: Follows the BIP-44/ZIP-32 HD hierarchy model (m/44’/133’/account’/*), where each account represents a separate logical collection of funds
- Isolation: Different accounts provide isolation for different purposes or users
- ZIP-32 Integration: When available, accounts may include ZIP-32 account indexes to maintain the hierarchical derivation structure
§Data Preservation
During wallet migration, the following account data must be preserved:
- Identity: The unique account identifier and human-readable name
- Addresses: All addresses associated with the account, including metadata
- Transaction Relationships: Which transactions are relevant to this account
- Sent Output Information: Data that can’t be recovered from the blockchain, such as outgoing transaction metadata
- Extended Key Information: HD wallet derivation path information when available
§Examples
// Create a new account
let mut account = Account::new();
// Set account properties
account.set_name("Savings");
account.set_zip32_account_id(0);
// In practice, you would have real addresses and transaction IDs
// Create a transparent address (as an example)
let t_addr = transparent::Address::new("t1ExampleAddress".to_string());
let address = Address::new(ProtocolAddress::Transparent(t_addr));
let txid = TxId::from_bytes([0u8; 32]);
// Add the address and transaction to the account
account.add_address(address);
account.add_relevant_transaction(txid);
Implementations§
Source§impl Account
impl Account
pub fn new() -> Self
pub fn name(&self) -> &str
pub fn set_name(&mut self, name: impl Into<String>)
pub fn birthday_height(&self) -> Option<BlockHeight>
pub fn set_birthday_height(&mut self, birthday_height: Option<BlockHeight>)
pub fn birthday_block(&self) -> Option<BlockHash>
pub fn set_birthday_block(&mut self, birthday_block: Option<BlockHash>)
pub fn zip32_account_id(&self) -> Option<u32>
pub fn set_zip32_account_id(&mut self, id: u32)
pub fn addresses(&self) -> &Vec<Address>
pub fn addresses_len(&self) -> usize
pub fn add_address(&mut self, address: Address)
pub fn relevant_transactions(&self) -> &HashSet<TxId>
pub fn relevant_transactions_len(&self) -> usize
pub fn add_relevant_transaction(&mut self, txid: TxId)
pub fn sapling_sent_outputs(&self) -> &Vec<SaplingSentOutput>
pub fn sapling_sent_outputs_len(&self) -> usize
pub fn add_sapling_sent_output(&mut self, output: SaplingSentOutput)
pub fn orchard_sent_outputs(&self) -> &Vec<OrchardSentOutput>
pub fn orchard_sent_outputs_len(&self) -> usize
pub fn add_orchard_sent_output(&mut self, output: OrchardSentOutput)
Trait Implementations§
Source§impl Attachable for Account
impl Attachable for Account
Source§fn attachments(&self) -> &Attachments
fn attachments(&self) -> &Attachments
Returns a reference to the attachments container.
Source§fn attachments_mut(&mut self) -> &mut Attachments
fn attachments_mut(&mut self) -> &mut Attachments
Returns a mutable reference to the attachments container.
Source§fn add_attachment(
&mut self,
payload: impl EnvelopeEncodable,
vendor: &str,
conforms_to: Option<&str>,
)
fn add_attachment( &mut self, payload: impl EnvelopeEncodable, vendor: &str, conforms_to: Option<&str>, )
Adds a new attachment with the specified payload and metadata. Read more
Source§fn get_attachment(&self, digest: &Digest) -> Option<&Envelope>
fn get_attachment(&self, digest: &Digest) -> Option<&Envelope>
Retrieves an attachment by its digest. Read more
Source§fn remove_attachment(&mut self, digest: &Digest) -> Option<Envelope>
fn remove_attachment(&mut self, digest: &Digest) -> Option<Envelope>
Removes an attachment by its digest. Read more
Source§fn clear_attachments(&mut self)
fn clear_attachments(&mut self)
Removes all attachments from the object.
Source§fn has_attachments(&self) -> bool
fn has_attachments(&self) -> bool
Returns whether the object has any attachments. Read more
impl StructuralPartialEq for Account
Auto Trait Implementations§
impl Freeze for Account
impl RefUnwindSafe for Account
impl !Send for Account
impl !Sync for Account
impl Unpin for Account
impl UnwindSafe for Account
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
Mutably borrows from an owned value. Read more
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>
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 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>
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