Skip to main content

Crate zcash_client_sqlite

Crate zcash_client_sqlite 

Source
Expand description

An SQLite-based Zcash light client.

zcash_client_sqlite contains complete SQLite-based implementations of the WalletRead, WalletWrite, and BlockSource traits from the zcash_client_backend crate. In combination with zcash_client_backend, it provides a full implementation of a SQLite-backed client for the Zcash network.

§Design

The light client is built around two SQLite databases:

  • A cache database, used to inform the light client about new CompactBlocks. It is read-only within all light client APIs except for init_cache_database which can be used to initialize the database.

  • A data database, where the light client’s state is stored. It is read-write within the light client APIs, and assumed to be read-only outside these APIs. Callers MUST NOT write to the database without using these APIs. Callers MAY read the database directly in order to extract information for display to users.

§Feature flags

  • multicore (enabled by default) — Enables multithreading support for creating proofs and building subtrees.

  • orchard — Enables support for storing data related to the sending and receiving of Orchard funds.

    This also enables zcash_pool_migration/wallet, which supplies the WalletMigration adapter the end-to-end migration proving simulation drives. That feature forces zcash_client_backend/orchard on, so it must never be reachable while this crate’s orchard feature is off — including from a dev-dependency, whose features unify into every workspace build. This crate’s storage-trait impls are gated on this feature while the backend traits grow their Orchard and Ironwood methods under theirs, so the two must turn on together or the impls stop satisfying the traits.

  • test-dependencies — Exposes APIs that are useful for testing, such as proptest strategies.

  • transparent-inputs — Enables receiving transparent funds and sending to transparent recipients

  • spend-index — Emits per-outpoint TransactionDataRequest::SpendsOfTransparentOutput requests (instead of address-based TransactionsInvolvingAddress) for transparent spend detection, for wallets whose chain-data source has a spent-outpoint index.

  • zcashd-compat — Enables import from legacy zcashd wallet.dat wallets.

  • zewif — Enables importing wallets from ZeWIF (Zcash Wallet Interchange Format) documents. Spending key material carried by a document is diverted to a caller-provided SecretSink and is never stored in the wallet database.

  • serde — Enables serde derives for certain types.

§Experimental features

  • unstable — Exposes unstable APIs. Their behaviour may change at any time.

  • expensive-tests — A feature used to isolate tests that are expensive to run. Test-only.

  • ignore-expensive-tests — Marks expensive tests as ignored without removing them from compilation. Test-only.

  • pczt-tests — A feature used to enable PCZT-specific tests. Test-only.

    This enables this crate’s orchard and transparent-inputs features, because zcash_client_backend/pczt forces the backend’s counterparts on, and the backend’s storage traits and this crate’s impls must grow their pool-specific methods together or the impls stop satisfying the traits.

Modules§

chain
Functions for enforcing chain validity and handling chain reorgs.
error
Error types for problems that may arise when reading or storing wallet data to SQLite.
testingtest-dependencies
Test-support utilities exposed under the test-dependencies feature: an in-memory db::TestDbFactory / db::TestDb wallet for the zcash_client_backend testing framework, a BlockCache compact-block source, and the [highest_rooted_orchard_checkpoint] commitment-tree helper. Consumed by this crate’s own tests and, through the feature, by downstream crates’ tests.
util
Types that should be part of the standard library, but aren’t.
wallet
Functions for querying information in the wallet database.

Structs§

AccountRef
A typesafe wrapper for the primary key identifier for a row in the accounts table.
AccountUuid
Unique identifier for a specific account tracked by a WalletDb.
BlockDb
A handle for the SQLite block source.
ExtensionTransaction
A restricted statement executor for writing to application-owned extension tables within a wallet database transaction.
FsBlockDbunstable
A block source that reads block data from disk and block metadata from a SQLite database.
ReceivedNoteId
An opaque type for received note identifiers.
SqlTransaction
A wrapper for a SQLite transaction affecting the wallet database.
TxRef
A newtype wrapper for sqlite primary key values for the transactions table.
UtxoId
A newtype wrapper for sqlite primary key values for the utxos table.
WalletDb
A wrapper for the SQLite connection to the wallet database, along with a capability to read the system from the clock. A WalletDb encapsulates the full set of capabilities that are required in order to implement the WalletRead, WalletWrite and WalletCommitmentTrees traits.

Enums§

FsBlockDbErrorunstable
Errors that can be generated by the filesystem/sqlite-backed block source.