Skip to main content

Crate bsv_wallet_toolbox_rs

Crate bsv_wallet_toolbox_rs 

Source
Expand description

BSV Wallet Toolbox

Rust implementation of @bsv/wallet-toolbox, providing storage and services for BSV wallets. Built on top of bsv-sdk which provides cryptographic primitives, transaction building, and the WalletInterface trait.

§Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    bsv-wallet-toolbox                           │
├─────────────────────────────────────────────────────────────────┤
│  Wallet (implements WalletInterface with full storage/services) │
├───────────────┬──────────────────────┬──────────────────────────┤
│  WalletSigner │ WalletStorageManager │ Services │ Monitor       │
├───────────────┴──────────────────────┴──────────┴───────────────┤
│  Storage: StorageSqlx (SQLite/MySQL) | StorageClient (Remote)   │
└─────────────────────────────────────────────────────────────────┘
                                │
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                        bsv-sdk                                   │
│  primitives | script | transaction | wallet (ProtoWallet)       │
└─────────────────────────────────────────────────────────────────┘

§Features

  • sqlite (default) - SQLite storage backend
  • mysql - MySQL storage backend
  • remote - Remote storage via StorageClient (storage.babbage.systems)
  • full - All features enabled

§Example

use bsv_wallet_toolbox_rs::{Wallet, StorageSqlx, Services};
use bsv_rs::wallet::WalletInterface;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open local SQLite storage
    let storage = StorageSqlx::open("wallet.db").await?;

    // Configure mainnet services
    let services = Services::mainnet();

    // Create wallet with root key
    let wallet = Wallet::new(Some(root_key), storage, services).await?;

    // Use WalletInterface methods
    let outputs = wallet.list_outputs(args, "app.example.com").await?;

    Ok(())
}

Re-exports§

pub use error::Error;
pub use error::Result;
pub use storage::AuthId;
pub use storage::MonitorStorage;
pub use storage::WalletStorageProvider;
pub use storage::WalletStorageReader;
pub use storage::WalletStorageSync;
pub use storage::WalletStorageWriter;
pub use storage::classify_broadcast_results;
pub use storage::BroadcastOutcome;
pub use storage::StorageSqlx;
pub use chaintracks::BaseBlockHeader;
pub use chaintracks::Chaintracks;
pub use chaintracks::ChaintracksClient;
pub use chaintracks::ChaintracksInfo;
pub use chaintracks::ChaintracksManagement;
pub use chaintracks::ChaintracksOptions;
pub use chaintracks::ChaintracksStorage;
pub use chaintracks::HeightRange;
pub use chaintracks::InsertHeaderResult;
pub use chaintracks::LiveBlockHeader;
pub use services::AdaptiveTimeoutConfig;
pub use services::Arc;
pub use services::ArcConfig;
pub use services::BhsConfig;
pub use services::Bitails;
pub use services::BitailsConfig;
pub use services::BlockHeader;
pub use services::BlockHeaderService;
pub use services::BsvExchangeRate;
pub use services::Chain;
pub use services::FallbackChainTracker;
pub use services::FiatCurrency;
pub use services::FiatExchangeRates;
pub use services::GetMerklePathResult;
pub use services::GetRawTxResult;
pub use services::GetScriptHashHistoryResult;
pub use services::GetStatusForTxidsResult;
pub use services::GetUtxoStatusOutputFormat;
pub use services::GetUtxoStatusResult;
pub use services::NLockTimeInput;
pub use services::PostBeefResult;
pub use services::PostTxResultForTxid;
pub use services::ScriptHistoryItem;
pub use services::ServiceCallHistory;
pub use services::ServiceCollection;
pub use services::Services;
pub use services::ServicesOptions;
pub use services::TxStatusDetail;
pub use services::UtxoDetail;
pub use services::WalletServices;
pub use services::WhatsOnChain;
pub use services::WhatsOnChainConfig;
pub use wallet::HttpLookupResolver;
pub use wallet::OverlayCertificate;
pub use wallet::OverlayLookupResolver;
pub use wallet::ScriptType;
pub use wallet::SignerInput;
pub use wallet::UnlockingScriptTemplate;
pub use wallet::UtxoInfo;
pub use wallet::Wallet;
pub use wallet::WalletBalance;
pub use wallet::WalletOptions;
pub use wallet::WalletSigner;
pub use monitor::Monitor;
pub use monitor::MonitorOptions;
pub use monitor::MonitorTask;
pub use monitor::TaskConfig;
pub use monitor::TaskResult;
pub use monitor::TransactionStatusUpdate;
pub use managers::setup_wallet;
pub use managers::BasketUsageType;
pub use managers::CWIStyleWalletManager;
pub use managers::CWIStyleWalletManagerConfig;
pub use managers::CertificateUsageType;
pub use managers::Certifier;
pub use managers::GroupedPermissions;
pub use managers::ManagedStorage;
pub use managers::PermissionRequest;
pub use managers::PermissionRequestHandler;
pub use managers::PermissionToken;
pub use managers::PermissionUsageType;
pub use managers::PermissionsModule;
pub use managers::Profile;
pub use managers::SetupWalletOptions;
pub use managers::SimpleWalletManager;
pub use managers::TrustSettings;
pub use managers::UmpToken;
pub use managers::WalletAuthenticationManager;
pub use managers::WalletLogEntry;
pub use managers::WalletLogger;
pub use managers::WalletPermissionsManager;
pub use managers::WalletPermissionsManagerConfig;
pub use managers::WalletSettings;
pub use managers::WalletSettingsManager;
pub use managers::WalletSettingsManagerConfig;
pub use managers::WalletSnapshot;
pub use managers::WalletStorageManager;
pub use managers::WalletTheme;
pub use managers::DEFAULT_SETTINGS;
pub use managers::TESTNET_DEFAULT_SETTINGS;

Modules§

chaintracks
Chaintracks - Block Header Tracking System
error
Error types for the wallet toolbox.
lock_utils
Lock utility functions for safely acquiring RwLock guards.
managers
Wallet Manager Components
monitor
Monitor Module
services
Blockchain services layer for BSV wallet toolbox.
storage
Storage layer for wallet state persistence.
tsc_proof
TSC Proof to MerklePath (BRC-74 BUMP) conversion.
wallet
Wallet Module

Structs§

AbortActionArgs
Arguments for aborting a transaction in progress.
AbortActionResult
Result of aborting a transaction.
CreateActionArgs
Arguments for creating a new transaction action.
CreateActionResult
Result of creating an action.
InternalizeActionArgs
Arguments for internalizing a transaction.
InternalizeActionResult
Result of internalizing a transaction.
ListActionsArgs
Arguments for listing wallet actions (transactions).
ListActionsResult
Result of listing wallet actions.
ListCertificatesArgs
Arguments for listing certificates.
ListCertificatesResult
Result of listing certificates.
ListOutputsArgs
Arguments for listing wallet outputs.
ListOutputsResult
Result of listing wallet outputs.
RelinquishCertificateArgs
Arguments for relinquishing a certificate.
RelinquishOutputArgs
Arguments for relinquishing an output from a basket.

Traits§

WalletInterface
The WalletInterface trait defines all 28 wallet operations.