Expand description
§CDK Wallet
The CDK Wallet is a high level Cashu wallet. The Wallet is for a single mint and single unit. Multiple Wallets can be created to support multi mints and multi units.
§Example
§Create and Initialize Wallet
use std::sync::Arc;
use cdk::nuts::CurrencyUnit;
use cdk::wallet::Wallet;
use cdk_sqlite::wallet::memory;
use rand::random;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let seed = random::<[u8; 64]>();
let mint_url = "https://testnut.cashudevkit.org";
let unit = CurrencyUnit::Sat;
let localstore = memory::empty().await?;
let wallet = Wallet::new(mint_url, unit, Arc::new(localstore), seed, None)?;
// Required: Recover crashed operations (swap, send, receive, melt)
// This prevents proofs from being stuck in reserved states.
let report = wallet.recover_incomplete_sagas().await?;
println!("Recovered: {}, Compensated: {}, Skipped: {}, Failed: {}",
report.recovered, report.compensated, report.skipped, report.failed);
// Optional: Check and mint pending mint quotes (makes network calls)
let minted = wallet.mint_unissued_quotes().await?;
println!("Minted {} from pending quotes", minted);
Ok(())
}Re-exports§
pub use bip321::resolve_bip353_payment_instruction;pub use bip321::parse_payment_instruction;pub use bip321::Bip321UriBuilder;pub use bip321::ParsedPaymentInstruction;pub use bip321::PaymentRequestBip321Ext;pub use payment_request::CreateRequestParams;pub use payment_request::NostrWaitInfo;pub use wallet_repository::TokenData;pub use wallet_repository::WalletConfig;pub use wallet_repository::WalletRepository;pub use wallet_repository::WalletRepositoryBuilder;
Modules§
- bip321
- BIP 321 Payment Instruction Helpers
- payment_
request - Utilities for paying NUT-18 Payment Requests.
- subscription
- Client for subscriptions
- types
- Wallet Types
- util
- Wallet Utility Functions
- wallet_
repository - Wallet Repository
Structs§
- Auth
Wallet - CDK Auth Wallet
- Backup
Options - Options for backup operations
- Backup
Result - Result of a backup operation
- Base
Auth Http Client - Http Client
- Base
Http Client - Http Client
- Lnurl
PayInvoice Response - LNURL-pay invoice response from the callback
- Lnurl
PayResponse - LNURL-pay response from the initial request
- Melt
Confirm Options - Options for confirming a melt operation
- Melt
Quote - Melt Quote Info
- Mint
Quote - Mint Quote Info
- NUT13
Options - Options for
crate::wallet::Wallet::restore_with_opts. - Pending
Melt - A pending melt operation that can be awaited.
- Prepared
Melt - A prepared melt operation that can be confirmed or cancelled.
- Prepared
Send - Prepared send transaction
- Receive
Options - Receive options
- Recovery
Report - Report of recovery operations performed by
Wallet::recover_incomplete_sagas. - Restore
Options - Options for restore operations
- Restore
Result - Result of a restore operation
- Restored
- Amounts recovered during a restore operation
- Send
Memo - Send memo
- Send
Options - Send options
- Wallet
- CDK Wallet
- Wallet
Builder - Builder for creating a new
Wallet
Enums§
- Keyset
Filter - Filter for keyset queries
- Melt
Outcome - Outcome of a melt operation using async support (NUT-05).
- P2PK
Locked Proof Send Mode - Send behavior for selected P2PK-locked input proofs
- Send
Kind - Send Kind
- Wallet
Subscription - Wallet Subscription filter
Traits§
- Auth
Mint Connector - Interface that connects a wallet to a mint. Typically represents an HttpClient.
- Http
Transport - Expected HTTP Transport
- Mint
Connector - Interface that connects a wallet to a mint. Typically represents an HttpClient.
Type Aliases§
- Auth
Http Client - Auth HTTP Client with async transport
- Http
Client - Default Http Client with async transport (non-Tor)