cdk_common/lib.rs
1//! This crate is the base foundation to build things that can interact with the CDK (Cashu
2//! Development Kit) and their internal crates.
3//!
4//! This is meant to contain the shared types, traits and common functions that are used across the
5//! internal crates.
6
7#![doc = include_str!("../README.md")]
8
9pub mod task;
10pub mod terminal;
11
12/// Authentication related types and utilities
13///
14/// Enabled by the `http` feature because OIDC auth helpers fetch discovery and
15/// JWK documents through `cdk-http-client`.
16#[cfg(feature = "http")]
17pub mod auth;
18
19/// Protocol version for gRPC Mint RPC communication
20pub const MINT_RPC_PROTOCOL_VERSION: &str = "1.0.0";
21
22/// Protocol version for gRPC Payment Processor communication
23pub const PAYMENT_PROCESSOR_PROTOCOL_VERSION: &str = "4.0.0";
24
25#[cfg(feature = "grpc")]
26pub mod grpc;
27
28pub mod common;
29pub mod database;
30pub mod error;
31pub mod melt;
32#[cfg(feature = "mint")]
33pub mod mint;
34pub mod mint_quote;
35#[cfg(feature = "mint")]
36pub mod payment;
37pub mod pub_sub;
38/// Client-side request rate limiting (GCRA token bucket + HTTP transport
39/// decorator).
40///
41/// Needs `wallet` for the KV-store persistence backend and `http` for the
42/// `Transport` trait it decorates.
43#[cfg(all(feature = "wallet", feature = "http"))]
44pub mod rate_limit;
45pub mod redact;
46#[cfg(feature = "mint")]
47pub mod state;
48pub mod stream;
49pub mod subscription;
50#[cfg(feature = "wallet")]
51pub mod wallet;
52pub mod ws;
53
54// re-exporting external crates
55pub use bitcoin;
56pub use cashu::amount::{self, Amount};
57pub use cashu::lightning_invoice::{self, Bolt11Invoice};
58pub use cashu::nuts::{self, *};
59#[cfg(feature = "mint")]
60pub use cashu::quote_id::{self, *};
61pub use cashu::{dhke, ensure_cdk, mint_url, secret, util, SECP256K1};
62/// Re-export `cdk-http-client` WebSocket client.
63///
64/// The `http` feature enables CDK common's HTTP-facing helpers and re-exports,
65/// and selects the default `bitreq` backend. Add `cdk-http-client/reqwest`
66/// elsewhere in the dependency graph to use `reqwest`; it takes precedence when
67/// both backend features are enabled.
68#[cfg(feature = "http")]
69pub use cdk_http_client::ws as ws_client;
70/// Re-export `cdk-http-client` types.
71///
72/// The `http` feature exposes these helpers and selects the default `bitreq`
73/// backend. Applications that need SOCKS proxy or invalid-certificate support
74/// can enable `cdk-http-client/reqwest`, which takes precedence over `bitreq`.
75#[cfg(feature = "http")]
76pub use cdk_http_client::{
77 fetch, HttpClient, HttpClientBuilder, HttpError, RawResponse, RequestBuilder, Response,
78};
79// Re-export common types
80pub use common::FinalizedMelt;
81pub use error::Error;
82pub use melt::{MeltQuoteCreateResponse, MeltQuoteRequest, MeltQuoteResponse};
83pub use mint_quote::{MintQuoteRequest, MintQuoteResponse};
84/// Re-export parking_lot for reuse
85pub use parking_lot;