librustzcash/rustdoc/latest/zcash_client_sqlite/wallet/index.html

54 lines
8.9 KiB
HTML
Raw 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="Functions for querying information in the wallet database."><title>zcash_client_sqlite::wallet - 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-1a91846b.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="zcash_client_sqlite" data-themes="" data-resource-suffix="" data-rustdoc-version="1.88.0-nightly (27d6200a7 2025-05-06)" 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 mod"><!--[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_sqlite/index.html">zcash_<wbr>client_<wbr>sqlite</a><span class="version">0.16.2</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module wallet</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#views" title="Views">Views</a><ul><li><a href="#v_transactions" title="`v_transactions`"><code>v_transactions</code></a></li><li><a href="#v_tx_outputs" title="`v_tx_outputs`"><code>v_tx_outputs</code></a></li></ul></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate zcash_<wbr>client_<wbr>sqlite</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_sqlite</a></div><h1>Module <span>wallet</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_sqlite/wallet.rs.html#1-4440">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Functions for querying information in the wallet database.</p>
<p>These functions should generally not be used directly; instead,
their functionality is available via the <a href="../../zcash_client_backend/data_api/trait.WalletRead.html" title="trait zcash_client_backend::data_api::WalletRead"><code>WalletRead</code></a> and
<a href="../../zcash_client_backend/data_api/trait.WalletWrite.html" title="trait zcash_client_backend::data_api::WalletWrite"><code>WalletWrite</code></a> traits.</p>
<h2 id="views"><a class="doc-anchor" href="#views">§</a>Views</h2>
<p>The wallet database exposes the following views as part of its public API:</p>
<h3 id="v_transactions"><a class="doc-anchor" href="#v_transactions">§</a><code>v_transactions</code></h3>
<p>This view exposes the history of transactions that affect the balance of each account in the
wallet. A transaction may be represented by multiple rows in this view, one for each account in
the wallet that contributes funds to or receives funds from the transaction in question. Each
row of the view contains:</p>
<ul>
<li><code>account_balance_delta</code>: the net effect of the transaction on the associated accounts
balance. This value is positive when funds are received by the account, and negative when the
balance of the account decreases due to a spend.</li>
<li><code>fee_paid</code>: the total fee paid to send the transaction, as a positive value. This fee is
associated with the transaction (similar to e.g. <code>txid</code> or <code>mined_height</code>), and not with any
specific account involved with that transaction. ` If multiple rows exist for a single
transaction, this fee amount will be repeated for each such row. Therefore, if more than one
of the wallets accounts is involved with the transaction, this fee should be considered only
once in determining the total value sent from the wallet as a whole.</li>
</ul>
<h4 id="seed-phrase-with-single-account"><a class="doc-anchor" href="#seed-phrase-with-single-account">§</a>Seed Phrase with Single Account</h4>
<p>In the case that the seed phrase for in this wallet has only been used to create a single
account, this view will contain one row per transaction, in the case that
<code>account_balance_delta</code> is negative, it is usually safe to add <code>fee_paid</code> back to the
<code>account_balance_delta</code> value to determine the amount sent to addresses outside the wallet.</p>
<h4 id="seed-phrase-with-multiple-accounts"><a class="doc-anchor" href="#seed-phrase-with-multiple-accounts">§</a>Seed Phrase with Multiple Accounts</h4>
<p>In the case that the seed phrase for in this wallet has been used to create multiple accounts,
this view may contain multiple rows per transaction, one for each account involved. In this
case, the total amount sent to addresses outside the wallet can usually be calculated by
grouping rows by <code>id_tx</code> and then using <code>SUM(account_balance_delta) + MAX(fee_paid)</code>.</p>
<h4 id="imported-seed-phrases"><a class="doc-anchor" href="#imported-seed-phrases">§</a>Imported Seed Phrases</h4>
<p>If a seed phrase is imported, and not every account associated with it is loaded into the
wallet, this view may show partial information about some transactions. In particular, any
computation that involves both <code>account_balance_delta</code> and <code>fee_paid</code> is likely to be
inaccurate.</p>
<h3 id="v_tx_outputs"><a class="doc-anchor" href="#v_tx_outputs">§</a><code>v_tx_outputs</code></h3>
<p>This view exposes the history of transaction outputs received by and sent from the wallet,
keyed by transaction ID, pool type, and output index. The contents of this view are useful for
producing a detailed report of the effects of a transaction. Each row of this view contains:</p>
<ul>
<li><code>from_account_id</code> for sent outputs, the account from which the value was sent.</li>
<li><code>to_account_id</code> in the case that the output was received by an account in the wallet, the
identifier for the account receiving the funds.</li>
<li><code>to_address</code> the address to which an output was sent, or the address at which value was
received in the case of received transparent funds.</li>
<li><code>value</code> the value of the output. This is always a positive number, for both sent and received
outputs.</li>
<li><code>is_change</code> a boolean flag indicating whether this is a change output belonging to the
wallet.</li>
<li><code>memo</code> the shielded memo associated with the output, if any.</li>
</ul>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="commitment_tree/index.html" title="mod zcash_client_sqlite::wallet::commitment_tree">commitment_<wbr>tree</a></dt><dt><a class="mod" href="init/index.html" title="mod zcash_client_sqlite::wallet::init">init</a></dt><dd>Functions for initializing the various databases.</dd><dt><a class="mod" href="testing/index.html" title="mod zcash_client_sqlite::wallet::testing">testing</a><wbr><span class="stab portability" title="Available on crate feature `test-dependencies` only"><code>test-dependencies</code></span></dt></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Account.html" title="struct zcash_client_sqlite::wallet::Account">Account</a></dt><dd>An account stored in a <code>zcash_client_sqlite</code> database.</dd></dl></section></div></main></body></html>