How payjoin/rust-payjoin works
Project Type and Purpose
• The project is a multi-crate Rust implementation for Payjoin—a method for collaborative Bitcoin transactions aimed at batching payments, lowering fees, and enhancing privacy.
• The project is intended for use with Bitcoin wallets and integrates with external systems (e.g., BTCPayServer, JoinMarket, WasabiWallet, Blue Wallet, Sparrow) to facilitate improved transactional privacy.
File Structure
• At the top level you see configuration files (Cargo.toml, docker-related configs, GitHub actions) indicating CI/CD and container deployment.
• There are several dedicated directories/crates:
• "payjoin": Core library containing modules for handling PSBT processing, sending and receiving payjoin transactions, handling different protocol versions (V1 and V2), along with utility modules (e.g., bech32, uri, error codes).
• "payjoin-cli": A CLI wrapper (with its own Dockerfile, README, tests, etc.) that makes use of the core library to operate as a reference implementation.
• "payjoin-directory": Implements the store-and-forward directory server required for asynchronous Payjoin V2 transactions.
• "payjoin-test-utils": Utility code for testing, indicating robust test support.
• The internal structure of the "payjoin" crate further splits into subdirectories like src/psbt, src/receive, src/send, and others—this separation is key to representing the various responsibilities within the core library.
Specific Elements
• Specify submodules within the library (like sending, receiving, PSBT, etc.) if space permits, to give a sense of granularity.