Files
cdk/crates/cdk-cli
lollerfirst e581dcbf62 feat: tor isolated circuits (#1064)
fixes + tor feature in cdk-cli

fix: call `clone_with_prefs` to get a new isolation token

format

remove `new_isolated` from Transport trait

fix: remove tor dependencies under wasm32, disallow compilation with tor feature and wasm32

tor_transport in its own file

fixes

fmt

format

tor: implement Transport::resolve_dns_txt for TorAsync using DoH over Tor; fix tor transport trait changes after rebase; remove unused as_str() call for TorToggle in cdk-cli. Ensure compilation with features: tor,bip353

format

remove double reference

format

feat: circuits pool

format

tor_transport: deterministically select Tor client per request using index_for_request(endpoint path + query + payload)\n\n- Add index_for_request(&Url, Option<&[u8]>) using FNV-1a 64-bit (dependency-free)\n- Replace round-robin next_index() usage in request() with deterministic index\n- Adjust request() to accept Option<Vec<u8>> body to hash payload bytes\n- Update http_get/http_post/resolve_dns_txt to call new request signature\n- Keep next_index() as dead_code for potential fallback

tor_transport: implement Default by bootstrapping with default pool size (blocking)\n\n- Default now attempts to use existing Tokio runtime handle, or creates a temporary runtime\n- Preserves previous behavior for async constructors (new/with_pool_size)

tor_transport: fix Default to avoid nested runtime panic by initializing on a new thread when no Handle available\n\n- If a runtime is present, block_on via current handle\n- Otherwise, spawn a new OS thread and create a runtime inside it, then join

tor_transport: rework Default to use block_in_place + background thread runtime to avoid nested block_on inside tokio\n\n- Always create runtime on a separate OS thread; if inside tokio, enter block_in_place first\n- Avoids 'Cannot start a runtime from within a runtime' panic

fix

more fixes

tor_transport: lazy-initialize Tor client pool on first use via ensure_pool; make Default non-blocking and remove runtime gymnastics\n\n- Introduce Inner with OnceCell<Arc<Vec<TorClient>>> and configured size\n- Default/new/with_pool_size now cheap; actual arti bootstrap happens on first request\n- request() calls ensure_pool() and uses deterministic index with pool.len()\n- Keeps deterministic endpoint/method/body affinity and DoH TXT resolution\n\nThis avoids nested-runtime/block_in_place complexity and makes Default trivial.

tor_transport: make DEFAULT_TOR_POOL_SIZE public and support custom pool sizes via TorAsync::with_pool_size() (lazy)}

remove unneeded async

add salt to keyed circuit selection
2025-10-03 15:39:57 +02:00
..
2025-10-03 15:39:57 +02:00
2025-10-03 15:39:57 +02:00
2025-09-17 09:32:22 +01:00

CDK CLI

crates.io Documentation MIT licensed

Warning

This project is in early development, it does however work with real sats! Always use amounts you don't mind losing.

A command-line Cashu wallet implementation built with the Cashu Development Kit (CDK). This tool allows you to interact with Cashu mints from the terminal, performing operations like minting, melting, and transferring ecash tokens.

Features

  • Multiple Mint Support: Connect to and manage multiple Cashu mints
  • Token Operations: Mint, melt, send, and receive Cashu tokens
  • Wallet Management: Create and manage multiple wallets
  • Lightning Integration: Pay Lightning invoices and receive payments
  • Token Storage: Secure local storage of tokens and mint configurations

Installation

Option 1: Download Pre-built Binary

Download the latest release from the GitHub releases page.

Option 2: Build from Source

git clone https://github.com/cashubtc/cdk.git
cd cdk
cargo build --bin cdk-cli --release
# Binary will be at ./target/release/cdk-cli

Quick Start

1. Add a Mint

# Add a mint (use a real mint URL or start your own with cdk-mintd)
cdk-cli wallet add-mint http://127.0.0.1:8085

2. Mint Tokens

# Create a mint quote for 100 sats
cdk-cli wallet mint-quote 100

# Pay the Lightning invoice shown, then mint the tokens
cdk-cli wallet mint <quote_id>

3. Send Tokens

# Send 50 sats as a token
cdk-cli wallet send 50

4. Receive Tokens

# Receive a token from someone else
cdk-cli wallet receive <cashu_token>

5. Check Balance

# View your current balance
cdk-cli wallet balance

Basic Usage

Wallet Operations

# List all wallets
cdk-cli wallet list

# Create a new wallet
cdk-cli wallet new --name my-wallet

# Set default wallet
cdk-cli wallet set-default my-wallet

# Show wallet info
cdk-cli wallet info

Mint Management

# List connected mints
cdk-cli wallet list-mints

# Remove a mint
cdk-cli wallet remove-mint <mint_url>

# Get mint information
cdk-cli wallet mint-info <mint_url>

Payment Operations

# Pay a Lightning invoice
cdk-cli wallet pay-invoice <lightning_invoice>

# Create melt quote for an invoice
cdk-cli wallet melt-quote <lightning_invoice>

# Execute the melt
cdk-cli wallet melt <quote_id>

Token Management

# List all tokens
cdk-cli wallet list-tokens

# Check token states
cdk-cli wallet check-tokens

# Restore wallet from seed
cdk-cli wallet restore --seed <seed_words>

Configuration

The CLI stores its configuration and wallet data in:

  • Linux/macOS: ~/.config/cdk-cli/
  • Windows: %APPDATA%\cdk-cli\

Examples

Complete Workflow Example

# 1. Start a test mint (in another terminal)
cdk-mintd

# 2. Add the mint
cdk-cli wallet add-mint http://127.0.0.1:8085

# 3. Create a mint quote
cdk-cli wallet mint-quote 1000

# 4. Pay the Lightning invoice (if using real Lightning backend)
# or wait a few seconds if using fake wallet

# 5. Mint the tokens
cdk-cli wallet mint <quote_id>

# 6. Check balance
cdk-cli wallet balance

# 7. Send some tokens
cdk-cli wallet send 100

# 8. The recipient can receive with:
cdk-cli wallet receive <cashu_token_string>

Working with Multiple Wallets

# Create wallets for different purposes
cdk-cli wallet new --name savings
cdk-cli wallet new --name daily

# Switch between wallets
cdk-cli wallet set-default savings
cdk-cli wallet balance

cdk-cli wallet set-default daily
cdk-cli wallet balance

Help and Documentation

# General help
cdk-cli --help

# Help for specific commands
cdk-cli wallet --help
cdk-cli wallet mint-quote --help

License

Code is under the MIT License

Contribution

All contributions are welcome.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.