librustzcash/rustdoc/latest/zcash_client_backend/data_api/trait.WalletWrite.html

360 lines
58 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="This trait encapsulates the write capabilities required to update stored wallet data."><title>WalletWrite in zcash_client_backend::data_api - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-20739d33.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="zcash_client_backend" data-themes="" data-resource-suffix="" data-rustdoc-version="1.88.0-nightly (74509131e 2025-04-29)" data-channel="nightly" data-search-js="search-f7877310.js" data-settings-js="settings-5514c975.js" ><script src="../../static.files/storage-4e99c027.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-7ef8a74a.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../zcash_client_backend/index.html">zcash_<wbr>client_<wbr>backend</a><span class="version">0.18.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Wallet<wbr>Write</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#adding-accounts" title="Adding accounts">Adding accounts</a></li><li><a href="#creating-a-new-wallet" title="Creating a new wallet">Creating a new wallet</a></li><li><a href="#restoring-a-wallet-from-backup" title="Restoring a wallet from backup">Restoring a wallet from backup</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.UtxoRef" title="UtxoRef">UtxoRef</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.create_account" title="create_account">create_account</a></li><li><a href="#tymethod.get_address_for_index" title="get_address_for_index">get_address_for_index</a></li><li><a href="#tymethod.get_next_available_address" title="get_next_available_address">get_next_available_address</a></li><li><a href="#tymethod.import_account_hd" title="import_account_hd">import_account_hd</a></li><li><a href="#tymethod.import_account_ufvk" title="import_account_ufvk">import_account_ufvk</a></li><li><a href="#tymethod.put_blocks" title="put_blocks">put_blocks</a></li><li><a href="#tymethod.put_received_transparent_utxo" title="put_received_transparent_utxo">put_received_transparent_utxo</a></li><li><a href="#tymethod.set_transaction_status" title="set_transaction_status">set_transaction_status</a></li><li><a href="#tymethod.store_decrypted_tx" title="store_decrypted_tx">store_decrypted_tx</a></li><li><a href="#tymethod.store_transactions_to_be_sent" title="store_transactions_to_be_sent">store_transactions_to_be_sent</a></li><li><a href="#tymethod.truncate_to_height" title="truncate_to_height">truncate_to_height</a></li><li><a href="#tymethod.update_chain_tip" title="update_chain_tip">update_chain_tip</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.reserve_next_n_ephemeral_addresses" title="reserve_next_n_ephemeral_addresses">reserve_next_n_ephemeral_addresses</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In zcash_<wbr>client_<wbr>backend::<wbr>data_<wbr>api</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">zcash_client_backend</a>::<wbr><a href="index.html">data_api</a></div><h1>Trait <span class="trait">WalletWrite</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/zcash_client_backend/data_api.rs.html#2349-2621">Source</a> </span></div><pre class="rust item-decl"><code>pub trait WalletWrite: <a class="trait" href="trait.WalletRead.html" title="trait zcash_client_backend::data_api::WalletRead">WalletRead</a> {
type <a href="#associatedtype.UtxoRef" class="associatedtype">UtxoRef</a>;
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 13 methods</span></summary> // Required methods
fn <a href="#tymethod.create_account" class="fn">create_account</a>(
&amp;mut self,
account_name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
seed: &amp;<a class="type" href="https://docs.rs/secrecy/0.8.0/secrecy/vec/type.SecretVec.html" title="type secrecy::vec::SecretVec">SecretVec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;,
birthday: &amp;<a class="struct" href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday">AccountBirthday</a>,
key_source: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>, <a class="struct" href="../keys/struct.UnifiedSpendingKey.html" title="struct zcash_client_backend::keys::UnifiedSpendingKey">UnifiedSpendingKey</a>), Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.import_account_hd" class="fn">import_account_hd</a>(
&amp;mut self,
account_name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
seed: &amp;<a class="type" href="https://docs.rs/secrecy/0.8.0/secrecy/vec/type.SecretVec.html" title="type secrecy::vec::SecretVec">SecretVec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;,
account_index: AccountId,
birthday: &amp;<a class="struct" href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday">AccountBirthday</a>,
key_source: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Account" title="type zcash_client_backend::data_api::WalletRead::Account">Account</a>, <a class="struct" href="../keys/struct.UnifiedSpendingKey.html" title="struct zcash_client_backend::keys::UnifiedSpendingKey">UnifiedSpendingKey</a>), Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.import_account_ufvk" class="fn">import_account_ufvk</a>(
&amp;mut self,
account_name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
unified_key: &amp;<a class="struct" href="../keys/struct.UnifiedFullViewingKey.html" title="struct zcash_client_backend::keys::UnifiedFullViewingKey">UnifiedFullViewingKey</a>,
birthday: &amp;<a class="struct" href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday">AccountBirthday</a>,
purpose: <a class="enum" href="enum.AccountPurpose.html" title="enum zcash_client_backend::data_api::AccountPurpose">AccountPurpose</a>,
key_source: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Account" title="type zcash_client_backend::data_api::WalletRead::Account">Account</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.get_next_available_address" class="fn">get_next_available_address</a>(
&amp;mut self,
account: Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>,
request: <a class="enum" href="../keys/enum.UnifiedAddressRequest.html" title="enum zcash_client_backend::keys::UnifiedAddressRequest">UnifiedAddressRequest</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(<a class="struct" href="../address/struct.UnifiedAddress.html" title="struct zcash_client_backend::address::UnifiedAddress">UnifiedAddress</a>, DiversifierIndex)&gt;, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.get_address_for_index" class="fn">get_address_for_index</a>(
&amp;mut self,
account: Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>,
diversifier_index: DiversifierIndex,
request: <a class="enum" href="../keys/enum.UnifiedAddressRequest.html" title="enum zcash_client_backend::keys::UnifiedAddressRequest">UnifiedAddressRequest</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../address/struct.UnifiedAddress.html" title="struct zcash_client_backend::address::UnifiedAddress">UnifiedAddress</a>&gt;, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.update_chain_tip" class="fn">update_chain_tip</a>(
&amp;mut self,
tip_height: BlockHeight,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.put_blocks" class="fn">put_blocks</a>(
&amp;mut self,
from_state: &amp;<a class="struct" href="chain/struct.ChainState.html" title="struct zcash_client_backend::data_api::chain::ChainState">ChainState</a>,
blocks: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="struct.ScannedBlock.html" title="struct zcash_client_backend::data_api::ScannedBlock">ScannedBlock</a>&lt;Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>&gt;&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.put_received_transparent_utxo" class="fn">put_received_transparent_utxo</a>(
&amp;mut self,
output: &amp;<a class="struct" href="../wallet/struct.WalletTransparentOutput.html" title="struct zcash_client_backend::wallet::WalletTransparentOutput">WalletTransparentOutput</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.WalletWrite.html#associatedtype.UtxoRef" title="type zcash_client_backend::data_api::WalletWrite::UtxoRef">UtxoRef</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.store_decrypted_tx" class="fn">store_decrypted_tx</a>(
&amp;mut self,
received_tx: <a class="struct" href="struct.DecryptedTransaction.html" title="struct zcash_client_backend::data_api::DecryptedTransaction">DecryptedTransaction</a>&lt;'_, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.store_transactions_to_be_sent" class="fn">store_transactions_to_be_sent</a>(
&amp;mut self,
transactions: &amp;[<a class="struct" href="struct.SentTransaction.html" title="struct zcash_client_backend::data_api::SentTransaction">SentTransaction</a>&lt;'_, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>&gt;],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.truncate_to_height" class="fn">truncate_to_height</a>(
&amp;mut self,
max_height: BlockHeight,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;BlockHeight, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.set_transaction_status" class="fn">set_transaction_status</a>(
&amp;mut self,
_txid: TxId,
_status: <a class="enum" href="enum.TransactionStatus.html" title="enum zcash_client_backend::data_api::TransactionStatus">TransactionStatus</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;;
// Provided method
fn <a href="#method.reserve_next_n_ephemeral_addresses" class="fn">reserve_next_n_ephemeral_addresses</a>(
&amp;mut self,
_account_id: Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>,
_n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;(TransparentAddress, <a class="struct" href="../wallet/struct.TransparentAddressMetadata.html" title="struct zcash_client_backend::wallet::TransparentAddressMetadata">TransparentAddressMetadata</a>)&gt;, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt; { ... }
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This trait encapsulates the write capabilities required to update stored wallet data.</p>
<h2 id="adding-accounts"><a class="doc-anchor" href="#adding-accounts">§</a>Adding accounts</h2>
<p>This trait provides several methods for adding accounts to the wallet data:</p>
<ul>
<li><a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a></li>
<li><a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a></li>
<li><a href="trait.WalletWrite.html#tymethod.import_account_ufvk" title="method zcash_client_backend::data_api::WalletWrite::import_account_ufvk"><code>WalletWrite::import_account_ufvk</code></a></li>
</ul>
<p>All of these methods take an <a href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday"><code>AccountBirthday</code></a>. The birthday height is defined as
the minimum block height that will be scanned for funds belonging to the wallet. If
<code>birthday.height()</code> is below the current chain tip, the account addition operation
will trigger a re-scan of the blocks at and above the provided height.</p>
<p>The order in which you call these methods will affect the resulting wallet structure:</p>
<ul>
<li>If only <a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a> is used, the resulting accounts will have
sequential <a href="https://zips.z.cash/zip-0032">ZIP 32</a> account indices within each given seed.</li>
<li>If <a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a> is used to import accounts with non-sequential
ZIP 32 account indices from the same seed, a call to <a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a>
will use the ZIP 32 account index just after the highest-numbered existing account.</li>
<li>If an account is added to the wallet, and then a later call to one of the methods
would produce a UFVK that collides with that account on any FVK component (i.e.
Sapling, Orchard, or transparent), an error will be returned. This can occur in the
following cases:
<ul>
<li>An account is created via <a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a> with an auto-selected
ZIP 32 account index, and that index is later imported explicitly via either
<a href="trait.WalletWrite.html#tymethod.import_account_ufvk" title="method zcash_client_backend::data_api::WalletWrite::import_account_ufvk"><code>WalletWrite::import_account_ufvk</code></a> or <a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a>.</li>
<li>An account is imported via <a href="trait.WalletWrite.html#tymethod.import_account_ufvk" title="method zcash_client_backend::data_api::WalletWrite::import_account_ufvk"><code>WalletWrite::import_account_ufvk</code></a> or
<a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a>, and then the ZIP 32 account index
corresponding to that accounts UFVK is later imported either implicitly
via <a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a>, or explicitly via a call to
<a href="trait.WalletWrite.html#tymethod.import_account_ufvk" title="method zcash_client_backend::data_api::WalletWrite::import_account_ufvk"><code>WalletWrite::import_account_ufvk</code></a> or <a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a>.</li>
</ul>
</li>
</ul>
<p>Note that an error will be returned on an FVK collision even if the UFVKs do not
match exactly, e.g. if they have different subsets of components.</p>
<p>A future change to this trait might introduce a method to “upgrade” an imported
account with derivation information. See <a href="https://github.com/zcash/librustzcash/issues/1284">zcash/librustzcash#1284</a> for details.</p>
<p>Users of the <code>WalletWrite</code> trait should generally distinguish in their APIs and wallet
UIs between creating a new account, and importing an account that previously existed.
By convention, wallets should only allow a new account to be generated after confirmed
funds have been received by the newest existing account; this allows automated account
recovery to discover and recover all funds within a particular seed.</p>
<h2 id="creating-a-new-wallet"><a class="doc-anchor" href="#creating-a-new-wallet">§</a>Creating a new wallet</h2>
<p>To create a new wallet:</p>
<ul>
<li>Generate a new <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">BIP 39</a> mnemonic phrase, using a crate like <a href="https://crates.io/crates/bip0039"><code>bip0039</code></a>.</li>
<li>Derive the corresponding seed from the mnemonic phrase.</li>
<li>Use <a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a> with the resulting seed.</li>
</ul>
<p>Callers should construct the <a href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday"><code>AccountBirthday</code></a> using <a href="struct.AccountBirthday.html#method.from_treestate" title="associated function zcash_client_backend::data_api::AccountBirthday::from_treestate"><code>AccountBirthday::from_treestate</code></a> for
the block at height <code>chain_tip_height - 100</code>. Setting the birthday height to a tree state below
the pruning depth ensures that reorgs cannot cause funds intended for the wallet to be missed;
otherwise, if the chain tip height were used for the wallet birthday, a transaction targeted at
a height greater than the chain tip could be mined at a height below that tip as part of a
reorg.</p>
<h2 id="restoring-a-wallet-from-backup"><a class="doc-anchor" href="#restoring-a-wallet-from-backup">§</a>Restoring a wallet from backup</h2>
<p>To restore a backed-up wallet:</p>
<ul>
<li>Derive the seed from its BIP 39 mnemonic phrase.</li>
<li>Use <a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a> once for each ZIP 32 account index that the
user wants to restore.</li>
<li>If the highest previously-used ZIP 32 account index was <em>not</em> restored by the user,
remember this index separately as <code>index_max</code>. The first time the user wants to
generate a new account, use <a href="trait.WalletWrite.html#tymethod.import_account_hd" title="method zcash_client_backend::data_api::WalletWrite::import_account_hd"><code>WalletWrite::import_account_hd</code></a> to create the account
<code>index_max + 1</code>.</li>
<li><a href="trait.WalletWrite.html#tymethod.create_account" title="method zcash_client_backend::data_api::WalletWrite::create_account"><code>WalletWrite::create_account</code></a> can be used to generate subsequent new accounts in
the restored wallet.</li>
</ul>
<p>Automated account recovery has not yet been implemented by this crate. A wallet app
that supports multiple accounts can implement it manually by tracking account balances
relative to <a href="struct.WalletSummary.html#method.fully_scanned_height" title="method zcash_client_backend::data_api::WalletSummary::fully_scanned_height"><code>WalletSummary::fully_scanned_height</code></a>, and creating new accounts as
funds appear in existing accounts.</p>
<p>If the number of accounts is known in advance, the wallet should create all accounts before
scanning the chain so that the scan can be done in a single pass for all accounts.</p>
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.UtxoRef" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2351">Source</a><h4 class="code-header">type <a href="#associatedtype.UtxoRef" class="associatedtype">UtxoRef</a></h4></section></summary><div class="docblock"><p>The type of identifiers used to look up transparent UTXOs.</p>
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.create_account" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2391-2397">Source</a><h4 class="code-header">fn <a href="#tymethod.create_account" class="fn">create_account</a>(
&amp;mut self,
account_name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
seed: &amp;<a class="type" href="https://docs.rs/secrecy/0.8.0/secrecy/vec/type.SecretVec.html" title="type secrecy::vec::SecretVec">SecretVec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;,
birthday: &amp;<a class="struct" href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday">AccountBirthday</a>,
key_source: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>, <a class="struct" href="../keys/struct.UnifiedSpendingKey.html" title="struct zcash_client_backend::keys::UnifiedSpendingKey">UnifiedSpendingKey</a>), Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Tells the wallet to track the next available account-level spend authority, given the
current set of <a href="https://zips.z.cash/zip-0316">ZIP 316</a> account identifiers known to the wallet database.</p>
<p>The “next available account” is defined as the ZIP-32 account index immediately following
the highest existing account index among all accounts in the wallet that share the given
seed. Users of the <a href="trait.WalletWrite.html" title="trait zcash_client_backend::data_api::WalletWrite"><code>WalletWrite</code></a> trait that only call this method are guaranteed to have
accounts with sequential indices.</p>
<p>Returns the account identifier for the newly-created wallet database entry, along with the
associated <a href="../keys/struct.UnifiedSpendingKey.html" title="struct zcash_client_backend::keys::UnifiedSpendingKey"><code>UnifiedSpendingKey</code></a>. Note that the unique account identifier should <em>not</em> be
assumed equivalent to the ZIP 32 account index. It is an opaque identifier for a pool of
funds or set of outputs controlled by a single spending authority.</p>
<p>The ZIP-32 account index may be obtained by calling <a href="trait.WalletRead.html#tymethod.get_account" title="method zcash_client_backend::data_api::WalletRead::get_account"><code>WalletRead::get_account</code></a>
with the returned account identifier.</p>
<p>The <a href="trait.WalletWrite.html" title="trait zcash_client_backend::data_api::WalletWrite"><code>WalletWrite</code></a> trait documentation has more details about account creation and import.</p>
<h5 id="arguments"><a class="doc-anchor" href="#arguments">§</a>Arguments</h5>
<ul>
<li><code>account_name</code>: A human-readable name for the account.</li>
<li><code>seed</code>: The 256-byte (at least) HD seed from which to derive the account UFVK.</li>
<li><code>birthday</code>: Metadata about where to start scanning blocks to find transactions intended
for the account.</li>
<li><code>key_source</code>: A string identifier or other metadata describing the source of the seed.
This is treated as opaque metadata by the wallet backend; it is provided for use by
applications which need to track additional identifying information for an account.</li>
</ul>
<h5 id="implementation-notes"><a class="doc-anchor" href="#implementation-notes">§</a>Implementation notes</h5>
<p>Implementations of this method <strong>MUST NOT</strong> “fill in gaps” by selecting an account index
that is lower than any existing account index among all accounts in the wallet that share
the given seed.</p>
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
<p>Panics if the length of the seed is not between 32 and 252 bytes inclusive.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.import_account_hd" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2429-2436">Source</a><h4 class="code-header">fn <a href="#tymethod.import_account_hd" class="fn">import_account_hd</a>(
&amp;mut self,
account_name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
seed: &amp;<a class="type" href="https://docs.rs/secrecy/0.8.0/secrecy/vec/type.SecretVec.html" title="type secrecy::vec::SecretVec">SecretVec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;,
account_index: AccountId,
birthday: &amp;<a class="struct" href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday">AccountBirthday</a>,
key_source: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Account" title="type zcash_client_backend::data_api::WalletRead::Account">Account</a>, <a class="struct" href="../keys/struct.UnifiedSpendingKey.html" title="struct zcash_client_backend::keys::UnifiedSpendingKey">UnifiedSpendingKey</a>), Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Tells the wallet to track a specific account index for a given seed.</p>
<p>Returns details about the imported account, including the unique account identifier for
the newly-created wallet database entry, along with the associated <a href="../keys/struct.UnifiedSpendingKey.html" title="struct zcash_client_backend::keys::UnifiedSpendingKey"><code>UnifiedSpendingKey</code></a>.
Note that the unique account identifier should <em>not</em> be assumed equivalent to the ZIP 32
account index. It is an opaque identifier for a pool of funds or set of outputs controlled
by a single spending authority.</p>
<p>Import accounts with indices that are exactly one greater than the highest existing account
index to ensure account indices are contiguous, thereby facilitating automated account
recovery.</p>
<p>The <a href="trait.WalletWrite.html" title="trait zcash_client_backend::data_api::WalletWrite"><code>WalletWrite</code></a> trait documentation has more details about account creation and import.</p>
<h5 id="arguments-1"><a class="doc-anchor" href="#arguments-1">§</a>Arguments</h5>
<ul>
<li><code>account_name</code>: A human-readable name for the account.</li>
<li><code>seed</code>: The 256-byte (at least) HD seed from which to derive the account UFVK.</li>
<li><code>account_index</code>: The ZIP 32 account-level component of the HD derivation path at
which to derive the accounts UFVK.</li>
<li><code>birthday</code>: Metadata about where to start scanning blocks to find transactions intended
for the account.</li>
<li><code>key_source</code>: A string identifier or other metadata describing the source of the seed.
This is treated as opaque metadata by the wallet backend; it is provided for use by
applications which need to track additional identifying information for an account.</li>
</ul>
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
<p>Panics if the length of the seed is not between 32 and 252 bytes inclusive.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.import_account_ufvk" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2465-2472">Source</a><h4 class="code-header">fn <a href="#tymethod.import_account_ufvk" class="fn">import_account_ufvk</a>(
&amp;mut self,
account_name: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>,
unified_key: &amp;<a class="struct" href="../keys/struct.UnifiedFullViewingKey.html" title="struct zcash_client_backend::keys::UnifiedFullViewingKey">UnifiedFullViewingKey</a>,
birthday: &amp;<a class="struct" href="struct.AccountBirthday.html" title="struct zcash_client_backend::data_api::AccountBirthday">AccountBirthday</a>,
purpose: <a class="enum" href="enum.AccountPurpose.html" title="enum zcash_client_backend::data_api::AccountPurpose">AccountPurpose</a>,
key_source: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Account" title="type zcash_client_backend::data_api::WalletRead::Account">Account</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Tells the wallet to track an account using a unified full viewing key.</p>
<p>Returns details about the imported account, including the unique account identifier for
the newly-created wallet database entry. Unlike the other account creation APIs
(<a href="trait.WalletWrite.html#tymethod.create_account"><code>Self::create_account</code></a> and <a href="trait.WalletWrite.html#tymethod.import_account_hd"><code>Self::import_account_hd</code></a>), no spending key is returned
because the wallet has no information about how the UFVK was derived.</p>
<p>Certain optimizations are possible for accounts which will never be used to spend funds. If
<code>spending_key_available</code> is <code>false</code>, the wallet may choose to optimize for this case, in
which case any attempt to spend funds from the account will result in an error.</p>
<p>The <a href="trait.WalletWrite.html" title="trait zcash_client_backend::data_api::WalletWrite"><code>WalletWrite</code></a> trait documentation has more details about account creation and import.</p>
<h5 id="arguments-2"><a class="doc-anchor" href="#arguments-2">§</a>Arguments</h5>
<ul>
<li><code>account_name</code>: A human-readable name for the account.</li>
<li><code>unified_key</code>: The UFVK used to detect transactions involving the account.</li>
<li><code>birthday</code>: Metadata about where to start scanning blocks to find transactions intended
for the account.</li>
<li><code>purpose</code>: Metadata describing whether or not data required for spending should be
tracked by the wallet.</li>
<li><code>key_source</code>: A string identifier or other metadata describing the source of the seed.
This is treated as opaque metadata by the wallet backend; it is provided for use by
applications which need to track additional identifying information for an account.</li>
</ul>
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
<p>Panics if the length of the seed is not between 32 and 252 bytes inclusive.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_next_available_address" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2479-2483">Source</a><h4 class="code-header">fn <a href="#tymethod.get_next_available_address" class="fn">get_next_available_address</a>(
&amp;mut self,
account: Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>,
request: <a class="enum" href="../keys/enum.UnifiedAddressRequest.html" title="enum zcash_client_backend::keys::UnifiedAddressRequest">UnifiedAddressRequest</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(<a class="struct" href="../address/struct.UnifiedAddress.html" title="struct zcash_client_backend::address::UnifiedAddress">UnifiedAddress</a>, DiversifierIndex)&gt;, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Generates, persists, and marks as exposed the next available diversified address for the
specified account, given the current addresses known to the wallet.</p>
<p>Returns <code>Ok(None)</code> if the account identifier does not correspond to a known
account.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.get_address_for_index" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2508-2513">Source</a><h4 class="code-header">fn <a href="#tymethod.get_address_for_index" class="fn">get_address_for_index</a>(
&amp;mut self,
account: Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>,
diversifier_index: DiversifierIndex,
request: <a class="enum" href="../keys/enum.UnifiedAddressRequest.html" title="enum zcash_client_backend::keys::UnifiedAddressRequest">UnifiedAddressRequest</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="../address/struct.UnifiedAddress.html" title="struct zcash_client_backend::address::UnifiedAddress">UnifiedAddress</a>&gt;, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Generates, persists, and marks as exposed a diversified address for the specified account
at the provided diversifier index.</p>
<p>Returns <code>Ok(None)</code> in the case that it is not possible to generate an address conforming
to the provided request at the specified diversifier index. Such a result might arise from
the diversifier index not being valid for a <a href="../keys/enum.ReceiverRequirement.html#variant.Require" title="variant zcash_client_backend::keys::ReceiverRequirement::Require"><code>ReceiverRequirement::Require</code></a>ed receiver.
Some implementations of this trait may return <code>Err(_)</code> in some cases to expose more
information, which is only accessible in a backend-specific context.</p>
<p>Address generation should fail if an address has already been exposed for the given
diversifier index and the given request produced an address having different receivers than
what was originally exposed.</p>
<h5 id="warnings"><a class="doc-anchor" href="#warnings">§</a>WARNINGS</h5>
<p>If an address generated using this method has a transparent receiver and the
chosen diversifier index would be outside the wallets internally-configured gap limit,
funds sent to these address are <strong>likely to not be discovered on recovery from seed</strong>. It
up to the caller of this method to either ensure that they only request transparent
receivers with indices within the range of a reasonable gap limit, or that they ensure that
their wallet provides backup facilities that can be used to ensure that funds sent to such
addresses are recoverable after a loss of wallet data.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.update_chain_tip" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2522">Source</a><h4 class="code-header">fn <a href="#tymethod.update_chain_tip" class="fn">update_chain_tip</a>(
&amp;mut self,
tip_height: BlockHeight,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Updates the wallets view of the blockchain.</p>
<p>This method is used to provide the wallet with information about the state of the
blockchain, and detect any previously scanned data that needs to be re-validated
before proceeding with scanning. It should be called at wallet startup prior to calling
<a href="trait.WalletRead.html#tymethod.suggest_scan_ranges" title="method zcash_client_backend::data_api::WalletRead::suggest_scan_ranges"><code>WalletRead::suggest_scan_ranges</code></a> in order to provide the wallet with the information it
needs to correctly prioritize scanning operations.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.put_blocks" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2532-2536">Source</a><h4 class="code-header">fn <a href="#tymethod.put_blocks" class="fn">put_blocks</a>(
&amp;mut self,
from_state: &amp;<a class="struct" href="chain/struct.ChainState.html" title="struct zcash_client_backend::data_api::chain::ChainState">ChainState</a>,
blocks: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="struct" href="struct.ScannedBlock.html" title="struct zcash_client_backend::data_api::ScannedBlock">ScannedBlock</a>&lt;Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>&gt;&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Updates the state of the wallet database by persisting the provided block information,
along with the note commitments that were detected when scanning the block for transactions
pertaining to this wallet.</p>
<h6 id="arguments-3"><a class="doc-anchor" href="#arguments-3">§</a>Arguments</h6>
<ul>
<li><code>from_state</code> must be the chain state for the block height prior to the first
block in <code>blocks</code>.</li>
<li><code>blocks</code> must be sequential, in order of increasing block height.</li>
</ul>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.put_received_transparent_utxo" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2539-2542">Source</a><h4 class="code-header">fn <a href="#tymethod.put_received_transparent_utxo" class="fn">put_received_transparent_utxo</a>(
&amp;mut self,
output: &amp;<a class="struct" href="../wallet/struct.WalletTransparentOutput.html" title="struct zcash_client_backend::wallet::WalletTransparentOutput">WalletTransparentOutput</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.WalletWrite.html#associatedtype.UtxoRef" title="type zcash_client_backend::data_api::WalletWrite::UtxoRef">UtxoRef</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Adds a transparent UTXO received by the wallet to the data store.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.store_decrypted_tx" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2545-2548">Source</a><h4 class="code-header">fn <a href="#tymethod.store_decrypted_tx" class="fn">store_decrypted_tx</a>(
&amp;mut self,
received_tx: <a class="struct" href="struct.DecryptedTransaction.html" title="struct zcash_client_backend::data_api::DecryptedTransaction">DecryptedTransaction</a>&lt;'_, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Caches a decrypted transaction in the persistent wallet store.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.store_transactions_to_be_sent" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2557-2560">Source</a><h4 class="code-header">fn <a href="#tymethod.store_transactions_to_be_sent" class="fn">store_transactions_to_be_sent</a>(
&amp;mut self,
transactions: &amp;[<a class="struct" href="struct.SentTransaction.html" title="struct zcash_client_backend::data_api::SentTransaction">SentTransaction</a>&lt;'_, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>&gt;],
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Saves information about transactions constructed by the wallet to the persistent
wallet store.</p>
<p>This must be called before the transactions are sent to the network.</p>
<p>Transactions that have been stored by this method should be retransmitted while it
is still possible that they could be mined.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.truncate_to_height" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2582">Source</a><h4 class="code-header">fn <a href="#tymethod.truncate_to_height" class="fn">truncate_to_height</a>(
&amp;mut self,
max_height: BlockHeight,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;BlockHeight, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Truncates the wallet database to at most the specified height.</p>
<p>Implementations of this method may choose a lower block height to which the data store will
be truncated if it is not possible to truncate exactly to the specified height. Upon
successful truncation, this method returns the height to which the data store was actually
truncated.</p>
<p>This method assumes that the state of the underlying data store is consistent up to a
particular block height. Since it is possible that a chain reorg might invalidate some
stored state, this method must be implemented in order to allow users of this API to
“reset” the data store to correctly represent chainstate as of at most the requested block
height.</p>
<p>After calling this method, the block at the returned height will be the most recent block
and all other operations will treat this block as the chain tip for balance determination
purposes.</p>
<p>There may be restrictions on heights to which it is possible to truncate. Specifically, it
will only be possible to truncate to heights at which is is possible to create a witness
given the current state of the wallets note commitment tree.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.set_transaction_status" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2616-2620">Source</a><h4 class="code-header">fn <a href="#tymethod.set_transaction_status" class="fn">set_transaction_status</a>(
&amp;mut self,
_txid: TxId,
_status: <a class="enum" href="enum.TransactionStatus.html" title="enum zcash_client_backend::data_api::TransactionStatus">TransactionStatus</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Updates the wallet backend with respect to the status of a specific transaction, from the
perspective of the main chain.</p>
<p>Fully transparent transactions, and transactions that do not contain either shielded inputs
or shielded outputs belonging to the wallet, may not be discovered by the process of chain
scanning; as a consequence, the wallet must actively query to determine whether such
transactions have been mined.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.reserve_next_n_ephemeral_addresses" class="method"><a class="src rightside" href="../../src/zcash_client_backend/data_api.rs.html#2598-2607">Source</a><h4 class="code-header">fn <a href="#method.reserve_next_n_ephemeral_addresses" class="fn">reserve_next_n_ephemeral_addresses</a>(
&amp;mut self,
_account_id: Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.AccountId" title="type zcash_client_backend::data_api::WalletRead::AccountId">AccountId</a>,
_n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;(TransparentAddress, <a class="struct" href="../wallet/struct.TransparentAddressMetadata.html" title="struct zcash_client_backend::wallet::TransparentAddressMetadata">TransparentAddressMetadata</a>)&gt;, Self::<a class="associatedtype" href="trait.WalletRead.html#associatedtype.Error" title="type zcash_client_backend::data_api::WalletRead::Error">Error</a>&gt;</h4></section><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>transparent-inputs</code></strong> only.</div></span></summary><div class="docblock"><p>Reserves the next <code>n</code> available ephemeral addresses for the given account.
This cannot be undone, so as far as possible, errors associated with transaction
construction should have been reported before calling this method.</p>
<p>To ensure that sufficient information is stored on-chain to allow recovering
funds sent back to any of the used addresses, a “gap limit” of 20 addresses
should be observed as described in <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#user-content-Address_gap_limit">BIP 44</a>.</p>
<p>Returns an error if there is insufficient space within the gap limit to allocate
the given number of addresses, or if the account identifier does not correspond
to a known account.</p>
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-WalletWrite-for-MockWalletDb" class="impl"><a class="src rightside" href="../../src/zcash_client_backend/data_api/testing.rs.html#2711-2824">Source</a><a href="#impl-WalletWrite-for-MockWalletDb" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.WalletWrite.html" title="trait zcash_client_backend::data_api::WalletWrite">WalletWrite</a> for <a class="struct" href="testing/struct.MockWalletDb.html" title="struct zcash_client_backend::data_api::testing::MockWalletDb">MockWalletDb</a></h3><span class="item-info"><div class="stab portability">Available on <strong>crate feature <code>test-dependencies</code></strong> only.</div></span></section></summary><div class="impl-items"><section id="associatedtype.UtxoRef-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/zcash_client_backend/data_api/testing.rs.html#2712">Source</a><a href="#associatedtype.UtxoRef-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.UtxoRef" class="associatedtype">UtxoRef</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></h4></section></div></details></div><script src="../../trait.impl/zcash_client_backend/data_api/trait.WalletWrite.js" async></script></section></div></main></body></html>