Skip to main content

Crate quai_wallet

Crate quai_wallet 

Source
Expand description

BIP39/BIP32 derivation, encrypted seed backups, selection and optional native storage. Bounded watch-only discovery relies on explicitly tagged node observations. No verified chain-proof recovery or complete reorg engine is implemented.

Secret-owning wrappers redact diagnostics and do not implement Clone, Display, or generic serialization. Secret exports require explicit access. Zeroization is best effort; it cannot erase caller copies or guarantee that cryptographic dependencies/compiler temporaries never retain copies.

Modules§

account_custody
Portable account nonce and signed-candidate custody, with bounded public encoding.
allocation
Bounded public journal for durable HD address allocation.
discovery
Bounded, history-aware watch-only discovery; observations are not chain proofs.
full_backup
Portable authenticated wallet-state backups, with optional native capture/restore. Old QUAISEED envelopes remain separate. Plaintext serialization is explicit, bounded and zeroized; no wallet serde is exposed.
metadata
Portable immutable public key origins, shared by native and browser wallet state.
payment_allocation
Public, bounded payment-code allocation journal. Persist ranges before search and completions before exposure; the browser adapter supplies atomic commits.
qi_addresses
Scoped, advisory Qi address inventory and cached usage views. Never allocation authority.
qi_custody
Portable Qi input custody. Source observations are explicit and never history proofs.
qi_keys
Explicit local Qi key resolution across HD, imported and payment origins.
storage
Native SQLite storage primitives, not a scanner or verified reconciliation engine.
wordlist
Bounded wordlist utilities and published OWL/OWL-A dictionary decoding. The compression format is documented by quais.js’s MIT-licensed wordlist sources.

Structs§

AccountPublic
An account xpub and explicit origin metadata, suitable for watch-only use.
AggregationPolicy
Threshold aggregation policy. Increasing denominations requires the pinned node’s first-Qi-transaction block exception; this selector cannot arrange it.
BackupKdf
Explicit Argon2id v1.3 cost parameters, bounded before any KDF allocation.
CandidateCoin
Caller-supplied, validated-index UTXO candidate; this type does not prove on-chain ownership.
CoinSelection
Pure selection result; reserving these inputs and fresh output addresses is a separate atomic step.
DerivedAddress
Public derivation metadata; contains no secret key, mnemonic, seed or chain code.
EncryptedSeedBackup
Fixed-size authenticated encrypted seed backup; safe to persist as ciphertext. No file I/O or generic wallet serialization is performed by this type.
ExtendedKeyMetadata
Public BIP32 derivation metadata. Sharing chain information reduces wallet privacy. A four-byte fingerprint is a routing hint, not proof of key ownership.
ExtendedPrivateKey
BIP32 private extended key with redacted diagnostics and a zeroizing scalar.
ExtendedPublicKey
Public BIP32 key for nonhardened watch-only derivation. Extended public keys reveal wallet activity; diagnostics omit their value.
HdWallet
Wallet root at m/44’/coin’. Derivation is stateless and stores no addresses or mnemonic.
Mnemonic
A validated mnemonic stored as word indexes; no passphrase is retained.
MnemonicEntropy
Explicitly exported BIP39 entropy, containing 16, 20, 24, 28 or 32 bytes. The owned buffer zeroizes on drop; diagnostics never expose its contents.
ReservationId
Application-chosen identity of one durable operation, shared by the native store and both custody books. Application-chosen identity of one durable operation, shared by the native store and both custody books. Application-chosen identity of one durable operation, shared by the native store and both custody books. Caller-generated unique 128-bit operation identifier; never reuse, including after release.
Search
Explicit search range; returned continuation metadata supports caller-owned checkpoints.
SearchResult
Successful search and safe continuation information.
SearchWindow
Matching addresses from one AccountPublic::search_window call.
SecretString
Explicitly exported secret text. Diagnostics redact the text; Drop zeroizes it.
Seed
A 64-byte BIP39 seed whose owned buffer is zeroized on drop.
SeedBackup
Original seed bytes plus explicit coin and preferred account metadata.
SelectionRequest
Explicit transfer constraints, including the fee budget approved by the caller.

Enums§

BackupError
Backup errors do not reveal input secrets or distinguish corruption from a wrong password.
CoinType
BIP44 coin types from the pinned Quai SDK.
Grinding
How a scan derives candidate addresses.
Language
All ten BIP39 languages supported by the pinned JavaScript reference. Language to be used for the mnemonic phrase.
ReservationState
Application-chosen identity of one durable operation, shared by the native store and both custody books. Application-chosen identity of one durable operation, shared by the native store and both custody books. Application-chosen identity of one durable operation, shared by the native store and both custody books. Durable monotonic operation state.
SelectionError
Invalid snapshot, insufficient spendable value, or bounded planning failure.
SweepMode
Output policy for sweeping or threshold aggregation in a bounded snapshot.
WalletError
Wallet errors never echo phrases, passphrases, seeds or extended private keys.
WindowStop
Why a SearchWindow ended.

Functions§

denominate_largest
Fewest largest-first denominations for an exact value, the analogue of the reference’s uncapped denominate.
preserves_denominations
Verify that outputs can split the input inventory without combining smaller input denominations into larger outputs. Output ordering does not affect this capacity check; aggregation requires a separate explicit block-position policy.
select_aggregate
Aggregate an ascending stable prefix of eligible small coins; fund the exact fee from other eligible coins, removing the smallest aggregation coins when needed. Fee inputs precede aggregation inputs; their refund denominations are appended after aggregation outputs, matching the reference’s ordering.
select_fewest
Match the reference’s fewest-input policy: smallest sufficient single coin, otherwise descending-value greedy inputs. No exponential subset search.
select_fewest_converting
select_fewest for a conversion or a wrapping, whose spend outputs are one Quai-ledger destination the node credits as a single aggregated value.
select_sweep
Spend eligible, unreserved coins with no change. request.target must be zero; output value is total minus the explicit fee. Exceeding an input bound fails instead of silently leaving coins behind. Aggregation must reduce output count and may need a node capable of arranging first-Qi block placement. AggregateThreshold delegates to select_aggregate and has its own explicit threshold/reduction policy; the other modes spend every eligible coin.
select_with_fee
Re-select until the exact selected shape’s quoted fee is covered, never exceeding the authorized maximum. Fees only increase to prevent oscillation; an overestimate can therefore remain paid and is reported in the result. The estimator must price the final input/output shape, including change.