Skip to main content

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