bsv_wallet_toolbox/lib.rs
1#![warn(missing_docs)]
2//! BSV Wallet Toolbox - Production-ready BSV wallet implementation in Rust.
3//!
4//! This crate provides a complete, production-ready BSV wallet with persistent
5//! storage, automatic transaction broadcasting, proof collection, and chain
6//! monitoring. It translates the TypeScript wallet-toolbox into idiomatic Rust.
7//!
8//! # Modules
9//!
10//! - [`error`] - Unified error types with WERR codes
11//! - [`status`] - Status enums for transactions, proofs, and sync
12//! - [`types`] - Shared types (`Chain`, `StorageProvidedBy`)
13//! - [`tables`] - Database table structs for all 16 entity types
14//! - [`storage`] - Storage traits, manager, and SQLx implementation
15//! - [`services`] - Network service providers (ARC, WhatsOnChain, etc.)
16//! - [`signer`] - Transaction signing with BRC-29 key derivation
17//! - [`wallet`] - High-level Wallet struct implementing WalletInterface
18//! - [`monitor`] - Background task runner for proofs, sync, and chain monitoring
19//! - [`utility`] - Cryptographic helpers and BRC-29 script templates
20//! - [`logging`] - Structured logging initialization via tracing
21
22/// Authentication manager for WAB-based wallet authentication flows.
23pub mod auth_manager;
24/// Error types for wallet operations.
25pub mod error;
26/// Structured logging initialization.
27pub mod logging;
28/// Background monitoring tasks for proofs and chain state.
29pub mod monitor;
30/// Permission management for wallet operations.
31pub mod permissions;
32/// Network service providers and traits.
33pub mod services;
34/// Transaction signing and key derivation.
35pub mod signer;
36/// Macro for implementing sqlx traits on enums as string columns.
37#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))]
38#[macro_use]
39mod sqlx_string_enum;
40
41/// Lenient NaiveDateTime serde helpers (handles trailing "Z" from TS).
42pub mod serde_datetime;
43/// Lenient serde helpers for TS interop (integer-as-bool, etc.).
44pub mod serde_helpers;
45/// Status enums for wallet entities.
46pub mod status;
47/// Storage layer: traits, manager, and implementations.
48pub mod storage;
49/// Database table structs mapping to SQL schema.
50pub mod tables;
51/// Shared types used across subsystems.
52pub mod types;
53/// Cryptographic utilities and BRC-29 script templates.
54pub mod utility;
55/// Wallet Authentication Backend (WAB) client for identity verification.
56pub mod wab_client;
57/// High-level wallet implementation.
58pub mod wallet;
59
60/// Database migration helpers (feature-gated by database backend).
61#[cfg(any(feature = "sqlite", feature = "mysql", feature = "postgres"))]
62pub mod migrations;
63
64/// BSV transaction type from the SDK.
65pub use bsv::transaction::Transaction;
66/// The WalletInterface trait defining all 29 wallet operations.
67pub use bsv::wallet::interfaces::WalletInterface;
68/// Key derivation for BRC-42/BRC-43 protocols.
69pub use bsv::wallet::key_deriver::KeyDeriver;
70/// Protocol wallet providing default WalletInterface implementations.
71pub use bsv::wallet::proto_wallet::ProtoWallet;
72
73/// Unified wallet error type.
74pub use error::WalletError;
75/// Convenience Result alias for wallet operations.
76pub use error::WalletResult;
77/// Status of a proven transaction request.
78pub use status::ProvenTxReqStatus;
79/// Status of wallet synchronization.
80pub use status::SyncStatus;
81/// Status of a wallet transaction.
82pub use status::TransactionStatus;
83
84/// Trait for wallet setup and configuration.
85pub use wallet::setup::SetupWallet;
86/// Builder for constructing configured Wallet instances.
87pub use wallet::setup::WalletBuilder;