Skip to main content

Crate cdk_spilman

Crate cdk_spilman 

Source
Expand description

Spilman Payment Channels

This module implements Spilman-style unidirectional payment channels for Cashu.

A Spilman channel allows Alice (sender) to make incremental payments to Charlie (receiver) without requiring on-chain transactions for each payment. The channel uses:

  • 2-of-2 multisig funding with expiry-based refund for Alice
  • Deterministic output derivation using a channel secret
  • Off-chain balance updates signed by Alice
  • Final commitment transaction signed by both parties

Structs§

BalanceUpdateMessage
A balance update message from Alice to Charlie
BridgeErrorResponse
HTTP-friendly error for payment/validation failures.
ChannelFunding
Funding data for a channel
ChannelParameters
Parameters for a Spilman payment channel
ChannelPolicy
Funding-time validation thresholds for a given unit, returned by SpilmanHost::get_channel_policy.
ChannelVerificationResult
Result of verifying a channel
ClientChannelFunding
Immutable funding data (saved once when channel is opened)
ClientChannelInfo
Information about a stored channel.
ClientPaymentState
Mutable payment state (updated on each payment)
CloseData
Data needed to close a channel
ClosePreparationError
HTTP-friendly error for close preparation.
CloseSuccess
ClosingData
Data stored when a channel enters CLOSING state
CommitmentOutputs
Commitment outputs for a specific balance distribution Contains the deterministic outputs for both sender (Alice) and receiver (Charlie) at a specific balance point in the channel
ConfigurableClientHost
A configurable client host that holds raw secret keys and uses pluggable storage.
DeterministicOutputsForOneContext
A set of deterministic outputs for a specific pubkey and amount This represents all the deterministic blinded messages, secrets, and blinding factors for splitting a given amount into ecash outputs
DeterministicSecretWithBlinding
Deterministic secret with blinding factor Can hold any type of secret (simple P2PK, P2PK with conditions, HTLC, etc.)
EstablishedChannel
An established Spilman payment channel Contains all channel components after funding transaction is complete
FundChannelResult
KeysetInfo
Keyset information for fee calculations and amount selection
MemoryClientStorage
In-memory storage implementation
OpenChannelResult
Result of opening a new channel.
OrderedListOfAmounts
An ordered list of amounts that sum to a target value
Payment
A signed payment for a Spilman channel.
PaymentProof
Payment proof for a channel
PaymentSuccess
Result of a successful payment
PaymentValidationResult
PreparedClose
Everything needed to execute a close operation after sync validation.
SpilmanBridge
Bridge for processing Spilman payments
SpilmanChannelSender
The sender’s view of a Spilman payment channel
SpilmanClientBridge
Client-side bridge for managing Spilman payment channels.
UnblindResult
Result of unblinding and verifying stage 1 swap response
UnsignedBalanceUpdate
An unsigned balance update, ready for signing.

Enums§

BridgeError
ChannelState
Channel lifecycle states
ChannelVerificationError
Errors that can occur during channel verification
ClientChannelState
Channel lifecycle state
CloseError

Traits§

ClientStorage
Storage trait for client channel data
MintConnection
Trait for mint connection operations needed by Spilman channels
SpilmanAsyncNetworking
Async networking hooks for the Spilman bridge
SpilmanClientAsyncNetworking
Async networking trait for client-side mint communication.
SpilmanClientHost
Trait for client-side host callbacks.
SpilmanClientNetworking
Networking trait for client-side mint communication.
SpilmanHost
Host hooks for the Spilman bridge
SpilmanNetworking
Sync networking hooks for the Spilman bridge

Functions§

attach_signature_to_balance_update
Attach an externally-produced signature to an unsigned balance update.
base64_decode
Base64 decode a string (standard encoding).
build_cashu_a_token
Build a cashuA token string from proofs JSON and a mint URL.
build_cashu_b_token
Build a cashuB (v4) token string from proofs JSON, a mint URL, and a unit.
channel_parameters_get_channel_id
Get channel_id from params JSON, channel secret, and keyset info (all as strings)
compute_channel_from_token
Compute channel parameters from a Cashu token
compute_channel_secret
Compute the channel secret from a secret key and counterparty’s public key
compute_channel_secret_from_hex
Compute channel secret from hex-encoded secret key and public key
compute_funding_token_amount
Compute the minimum funding_token_amount needed for a given capacity
create_funding_outputs
Create funding outputs from params and keyset info
create_funding_swap
Create a swap request for funding a channel from existing proofs
create_signed_balance_update
Create a signed balance update for a channel
create_unsigned_balance_update
Create an unsigned balance update for a channel.
get_signatures_from_swap_request
Extract signatures from a swap request’s first proof witness
parse_keyset_info_from_json
Parse KeysetInfo from JSON
sign_with_tweaked_key_util
Utility function for SpilmanClientHost implementations to sign with a tweaked key.
unblind_and_verify_stage1_response
verify_valid_channel
Verify that a channel is valid

Type Aliases§

ChannelId
Type alias for channel identifiers (hex-encoded).