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§
- Balance
Update Message - A balance update message from Alice to Charlie
- Bridge
Error Response - HTTP-friendly error for payment/validation failures.
- Channel
Funding - Funding data for a channel
- Channel
Parameters - Parameters for a Spilman payment channel
- Channel
Policy - Funding-time validation thresholds for a given unit, returned by
SpilmanHost::get_channel_policy. - Channel
Verification Result - Result of verifying a channel
- Client
Channel Funding - Immutable funding data (saved once when channel is opened)
- Client
Channel Info - Information about a stored channel.
- Client
Payment State - Mutable payment state (updated on each payment)
- Close
Data - Data needed to close a channel
- Close
Preparation Error - HTTP-friendly error for close preparation.
- Close
Success - Closing
Data - Data stored when a channel enters CLOSING state
- Commitment
Outputs - 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
- Configurable
Client Host - A configurable client host that holds raw secret keys and uses pluggable storage.
- Deterministic
Outputs ForOne Context - 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
- Deterministic
Secret With Blinding - Deterministic secret with blinding factor Can hold any type of secret (simple P2PK, P2PK with conditions, HTLC, etc.)
- Established
Channel - An established Spilman payment channel Contains all channel components after funding transaction is complete
- Fund
Channel Result - Keyset
Info - Keyset information for fee calculations and amount selection
- Memory
Client Storage - In-memory storage implementation
- Open
Channel Result - Result of opening a new channel.
- Ordered
List OfAmounts - An ordered list of amounts that sum to a target value
- Payment
- A signed payment for a Spilman channel.
- Payment
Proof - Payment proof for a channel
- Payment
Success - Result of a successful payment
- Payment
Validation Result - Prepared
Close - Everything needed to execute a close operation after sync validation.
- Spilman
Bridge - Bridge for processing Spilman payments
- Spilman
Channel Sender - The sender’s view of a Spilman payment channel
- Spilman
Client Bridge - Client-side bridge for managing Spilman payment channels.
- Unblind
Result - Result of unblinding and verifying stage 1 swap response
- Unsigned
Balance Update - An unsigned balance update, ready for signing.
Enums§
- Bridge
Error - Channel
State - Channel lifecycle states
- Channel
Verification Error - Errors that can occur during channel verification
- Client
Channel State - Channel lifecycle state
- Close
Error
Traits§
- Client
Storage - Storage trait for client channel data
- Mint
Connection - Trait for mint connection operations needed by Spilman channels
- Spilman
Async Networking - Async networking hooks for the Spilman bridge
- Spilman
Client Async Networking - Async networking trait for client-side mint communication.
- Spilman
Client Host - Trait for client-side host callbacks.
- Spilman
Client Networking - Networking trait for client-side mint communication.
- Spilman
Host - Host hooks for the Spilman bridge
- Spilman
Networking - 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§
- Channel
Id - Type alias for channel identifiers (hex-encoded).