Skip to main content

cdk_spilman/
lib.rs

1//! Spilman Payment Channels
2//!
3//! This module implements Spilman-style unidirectional payment channels for Cashu.
4//!
5//! A Spilman channel allows Alice (sender) to make incremental payments to Charlie (receiver)
6//! without requiring on-chain transactions for each payment. The channel uses:
7//!
8//! - 2-of-2 multisig funding with expiry-based refund for Alice
9//! - Deterministic output derivation using a channel secret
10//! - Off-chain balance updates signed by Alice
11//! - Final commitment transaction signed by both parties
12
13#[cfg(feature = "spilman-axum")]
14pub mod axum;
15mod balance_update;
16mod bindings;
17mod bridge;
18mod client_bridge;
19mod client_storage;
20mod configurable_client_host;
21#[cfg(feature = "configurable-host")]
22pub mod configurable_host;
23#[cfg(feature = "configurable-host-reqwest")]
24pub mod configurable_networking;
25mod deterministic;
26mod established_channel;
27mod keysets_and_amounts;
28mod params;
29mod sender_and_receiver;
30
31pub use balance_update::{
32    get_signatures_from_swap_request, BalanceUpdateMessage, UnsignedBalanceUpdate,
33};
34pub use bindings::{
35    attach_signature_to_balance_update, build_cashu_a_token, build_cashu_b_token,
36    channel_parameters_get_channel_id, compute_channel_from_token, compute_channel_secret_from_hex,
37    compute_funding_token_amount, create_funding_outputs, create_funding_swap,
38    create_signed_balance_update, create_unsigned_balance_update, parse_keyset_info_from_json,
39    sign_with_tweaked_key_util,
40};
41#[cfg(feature = "wallet")]
42pub use bindings::{
43    complete_funding_swap, construct_proofs, create_plain_blinded_messages, mint_proofs_from_mint,
44};
45pub use bridge::{
46    unblind_and_verify_stage1_response, BridgeError, BridgeErrorResponse, ChannelFunding,
47    ChannelPolicy, ChannelState, CloseData, CloseError, ClosePreparationError, CloseSuccess,
48    ClosingData, FundChannelResult, Payment, PaymentProof, PaymentSuccess, PaymentValidationResult,
49    PreparedClose, SpilmanAsyncNetworking, SpilmanBridge, SpilmanHost, SpilmanNetworking,
50    UnblindResult,
51};
52pub use client_bridge::{
53    base64_decode, ClientChannelInfo, OpenChannelResult, SpilmanClientAsyncNetworking,
54    SpilmanClientBridge, SpilmanClientHost, SpilmanClientNetworking,
55};
56pub use client_storage::{
57    ClientChannelFunding, ClientChannelState, ClientPaymentState, ClientStorage,
58    MemoryClientStorage,
59};
60pub use configurable_client_host::ConfigurableClientHost;
61pub use deterministic::{
62    CommitmentOutputs, DeterministicOutputsForOneContext, DeterministicSecretWithBlinding,
63    MintConnection,
64};
65pub use established_channel::EstablishedChannel;
66pub use keysets_and_amounts::{KeysetInfo, OrderedListOfAmounts};
67pub use params::{compute_channel_secret, ChannelId, ChannelParameters};
68pub use sender_and_receiver::{
69    verify_valid_channel, ChannelVerificationError, ChannelVerificationResult, SpilmanChannelSender,
70};