Expand description
§Solana Stealth SDK
A library for private payments on Solana using Stealth Addresses.
§Overview
Stealth addresses allow a sender to pay a recipient without revealing the connection between them. Each payment generates a unique one-time address that only the recipient can detect and spend from.
§Quick Start
§Receiving Payments
ⓘ
use solana_stealth::{StealthMetaAddress, Scanner};
// Generate a meta-address (do this once)
let meta = StealthMetaAddress::generate();
println!("Share this publicly: {}", meta.to_public_string());
// Save your keys securely
meta.save_to_file("~/.stealth/keys.json").unwrap();
// Scan for incoming payments
let scanner = Scanner::new(&meta);
let payments = scanner.scan("https://api.devnet.solana.com").await.unwrap();
for payment in payments {
println!("Received {} lamports at {}", payment.amount.unwrap_or(0), payment.stealth_address);
// Derive the keypair to spend these funds
let keypair = scanner.derive_spend_keypair(&payment).unwrap();
let solana_keypair = keypair.to_solana_keypair().unwrap();
}§Sending Payments
ⓘ
use solana_stealth::{PublicMetaAddress, StealthPayment};
// Parse recipient's meta-address
let recipient = PublicMetaAddress::from_string("stealth1abc...").unwrap();
// Create a stealth payment
let payment = StealthPayment::create(&recipient, 1_000_000_000).unwrap(); // 1 SOL
// The payment contains:
// - stealth_address: where to send the funds
// - ephemeral_pubkey: publish this on-chain so recipient can detect the payment§How It Works
- Recipient generates a stealth meta-address (spending + viewing keypairs)
- Recipient publishes their meta-address publicly
- Sender generates a unique stealth address using ECDH with the meta-address
- Sender sends funds to the stealth address and publishes an announcement
- Recipient scans announcements and detects payments addressed to them
- Recipient derives the private key to spend the received funds
§Privacy Properties
- Each payment uses a unique one-time address
- Only the recipient can detect which payments are theirs
- The sender cannot be linked to the recipient on-chain
- Amounts are visible on-chain (v1 limitation)
Re-exports§
pub use address::derive_stealth_address;pub use address::check_stealth_address;pub use address::StealthPayment;pub use error::Result;pub use error::StealthError;pub use keys::PublicMetaAddress;pub use keys::StealthMetaAddress;pub use scanner::Announcement;pub use scanner::DetectedPayment;pub use scanner::Scanner;pub use scanner::ScannerConfig;pub use spend::StealthKeypair;
Modules§
- address
- Stealth address generation and payment creation
- error
- Error types for the Solana Stealth SDK
- keys
- Key generation and management for Stealth Addresses
- scanner
- Scanner for detecting incoming stealth payments
- spend
- Spend key derivation for stealth addresses
Constants§
- META_
ADDRESS_ PREFIX - Prefix for encoded meta-addresses
- PROTOCOL_
VERSION - Version of the protocol