Skip to main content

Module wallet

Module wallet 

Source
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§

AuthWallet
CDK Auth Wallet
BackupOptions
Options for backup operations
BackupResult
Result of a backup operation
BaseAuthHttpClient
Http Client
BaseHttpClient
Http Client
LnurlPayInvoiceResponse
LNURL-pay invoice response from the callback
LnurlPayResponse
LNURL-pay response from the initial request
MeltConfirmOptions
Options for confirming a melt operation
MeltQuote
Melt Quote Info
MintQuote
Mint Quote Info
NUT13Options
Options for crate::wallet::Wallet::restore_with_opts.
PendingMelt
A pending melt operation that can be awaited.
PreparedMelt
A prepared melt operation that can be confirmed or cancelled.
PreparedSend
Prepared send transaction
ReceiveOptions
Receive options
RecoveryReport
Report of recovery operations performed by Wallet::recover_incomplete_sagas.
RestoreOptions
Options for restore operations
RestoreResult
Result of a restore operation
Restored
Amounts recovered during a restore operation
SendMemo
Send memo
SendOptions
Send options
Wallet
CDK Wallet
WalletBuilder
Builder for creating a new Wallet

Enums§

KeysetFilter
Filter for keyset queries
MeltOutcome
Outcome of a melt operation using async support (NUT-05).
P2PKLockedProofSendMode
Send behavior for selected P2PK-locked input proofs
SendKind
Send Kind
WalletSubscription
Wallet Subscription filter

Traits§

AuthMintConnector
Interface that connects a wallet to a mint. Typically represents an HttpClient.
HttpTransport
Expected HTTP Transport
MintConnector
Interface that connects a wallet to a mint. Typically represents an HttpClient.

Type Aliases§

AuthHttpClient
Auth HTTP Client with async transport
HttpClient
Default Http Client with async transport (non-Tor)