pub struct Zewif { /* private fields */ }
Expand description
The top-level container for the Zcash Wallet Interchange Format (ZeWIF).
Zewif
is the root structure of the ZeWIF hierarchy, serving as a container
for multiple wallets and a global transaction history. This structure represents
the entirety of the data that would be migrated between different Zcash wallet
implementations.
§Zcash Concept Relation
In the Zcash wallet ecosystem:
- Interchange Container:
Zewif
serves as the standardized format for moving wallet data between different implementations - Multi-Wallet Support: A single interchange file can contain multiple wallets, each with its own accounts and configuration
- Global Transaction History: Transactions are stored at the top level and referenced by accounts in wallets, avoiding duplication
- Migration Target: This structure is the complete package that can be serialized/deserialized during wallet migration
§Data Preservation
During wallet migration, the ZeWIF top-level container preserves:
- Complete Wallet Collection: All wallets with their unique identities and configurations
- Full Transaction Graph: The complete transaction history across all wallets
- Relationship Structure: The connections between wallets, accounts, and transactions
- Vendor-Specific Extensions: Custom metadata through the attachments system
§Examples
// Create the top-level container
let mut zewif = Zewif::new(BlockHeight::from_u32(2000000));
// Add a wallet
let wallet = ZewifWallet::new(Network::Main);
zewif.add_wallet(wallet);
// Add a transaction to the global history
let txid = TxId::from_bytes([0u8; 32]); // In practice, a real transaction ID
let tx = Transaction::new(txid);
zewif.add_transaction(txid, tx);
// Access transactions
let tx_count = zewif.transactions().len();
Implementations§
Source§impl Zewif
impl Zewif
pub fn new(export_height: BlockHeight) -> Self
pub fn id(&self) -> ARID
pub fn wallets(&self) -> &Vec<ZewifWallet>
pub fn wallets_len(&self) -> usize
pub fn add_wallet(&mut self, wallet: ZewifWallet)
pub fn transactions(&self) -> &HashMap<TxId, Transaction>
pub fn add_transaction(&mut self, txid: TxId, transaction: Transaction)
pub fn get_transaction(&self, txid: TxId) -> Option<&Transaction>
pub fn set_transactions(&mut self, transactions: HashMap<TxId, Transaction>)
pub fn export_height(&self) -> BlockHeight
Trait Implementations§
Source§impl Attachable for Zewif
impl Attachable for Zewif
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 Zewif
Auto Trait Implementations§
impl Freeze for Zewif
impl RefUnwindSafe for Zewif
impl !Send for Zewif
impl !Sync for Zewif
impl Unpin for Zewif
impl UnwindSafe for Zewif
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