mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-21 13:55:45 +01:00
Fix cdk cli readme (#1165)
* docs: update cli read me * docs: update postgres link
This commit is contained in:
@@ -11,11 +11,15 @@ A command-line Cashu wallet implementation built with the Cashu Development Kit
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Multiple Mint Support**: Connect to and manage multiple Cashu mints
|
- **Multiple Mint Support**: Connect to and manage multiple Cashu mints simultaneously
|
||||||
- **Token Operations**: Mint, melt, send, and receive Cashu tokens
|
- **Token Operations**: Mint, melt, send, and receive Cashu tokens
|
||||||
- **Wallet Management**: Create and manage multiple wallets
|
- **Lightning Integration**: Pay Lightning invoices (BOLT11, BOLT12, BIP353) and receive payments
|
||||||
- **Lightning Integration**: Pay Lightning invoices and receive payments
|
- **Payment Requests**: Create and pay payment requests with various conditions (P2PK, HTLC)
|
||||||
- **Token Storage**: Secure local storage of tokens and mint configurations
|
- **Token Transfer**: Transfer tokens between different mints
|
||||||
|
- **Multi-Currency Support**: Support for different currency units (sat, usd, eur, etc.)
|
||||||
|
- **Database Options**: SQLite or Redb backend with optional encryption (SQLCipher)
|
||||||
|
- **Tor Support**: Built-in Tor transport support (when compiled with feature)
|
||||||
|
- **Secure Storage**: Local storage of tokens, mint configurations, and seed
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -30,141 +34,379 @@ cargo build --bin cdk-cli --release
|
|||||||
# Binary will be at ./target/release/cdk-cli
|
# Binary will be at ./target/release/cdk-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Build with Optional Features
|
||||||
|
```bash
|
||||||
|
# With Tor support
|
||||||
|
cargo build --bin cdk-cli --release --features tor
|
||||||
|
|
||||||
|
# With SQLCipher encryption
|
||||||
|
cargo build --bin cdk-cli --release --features sqlcipher
|
||||||
|
|
||||||
|
# With Redb database
|
||||||
|
cargo build --bin cdk-cli --release --features redb
|
||||||
|
```
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### 1. Add a Mint
|
### 1. Check Your Balance
|
||||||
```bash
|
```bash
|
||||||
# Add a mint (use a real mint URL or start your own with cdk-mintd)
|
# View your current balance across all mints
|
||||||
cdk-cli wallet add-mint http://127.0.0.1:8085
|
cdk-cli balance
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Mint Tokens
|
### 2. Mint Tokens
|
||||||
```bash
|
```bash
|
||||||
# Create a mint quote for 100 sats
|
# Create and mint tokens from a mint (amount in sats)
|
||||||
cdk-cli wallet mint-quote 100
|
cdk-cli mint http://127.0.0.1:8085 100
|
||||||
|
|
||||||
# Pay the Lightning invoice shown, then mint the tokens
|
# Or with a description
|
||||||
cdk-cli wallet mint <quote_id>
|
cdk-cli mint http://127.0.0.1:8085 100 "My first mint"
|
||||||
|
|
||||||
|
# The command will display a Lightning invoice to pay
|
||||||
|
# After payment, tokens are automatically minted
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Send Tokens
|
### 3. Send Tokens
|
||||||
```bash
|
```bash
|
||||||
# Send 50 sats as a token
|
# Send tokens (you'll be prompted for amount and mint selection interactively)
|
||||||
cdk-cli wallet send 50
|
cdk-cli send
|
||||||
|
|
||||||
|
# Or specify options directly
|
||||||
|
cdk-cli send --mint-url http://127.0.0.1:8085 --memo "Payment for coffee"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 4. Receive Tokens
|
### 4. Receive Tokens
|
||||||
```bash
|
```bash
|
||||||
# Receive a token from someone else
|
# Receive a token from someone else
|
||||||
cdk-cli wallet receive <cashu_token>
|
cdk-cli receive <cashu_token>
|
||||||
|
|
||||||
|
# Receive from untrusted mint with transfer to trusted mint
|
||||||
|
cdk-cli receive <cashu_token> --allow-untrusted --transfer-to http://127.0.0.1:8085
|
||||||
```
|
```
|
||||||
|
|
||||||
### 5. Check Balance
|
## Global Options
|
||||||
|
|
||||||
|
The CLI supports several global options that apply to all commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# View your current balance
|
# Use a specific database engine
|
||||||
cdk-cli wallet balance
|
cdk-cli --engine sqlite balance
|
||||||
|
cdk-cli --engine redb balance
|
||||||
|
|
||||||
|
# Set a custom work directory
|
||||||
|
cdk-cli --work-dir ~/my-wallet balance
|
||||||
|
|
||||||
|
# Set logging level
|
||||||
|
cdk-cli --log-level info balance
|
||||||
|
|
||||||
|
# Use a specific currency unit
|
||||||
|
cdk-cli --unit usd balance
|
||||||
|
|
||||||
|
# Use NIP-98 Wallet Signing Proxy
|
||||||
|
cdk-cli --proxy https://proxy.example.com balance
|
||||||
|
|
||||||
|
# Disable Tor (when built with Tor feature, it's on by default)
|
||||||
|
cdk-cli --tor off balance
|
||||||
```
|
```
|
||||||
|
|
||||||
## Basic Usage
|
## Commands Reference
|
||||||
|
|
||||||
|
### Balance Operations
|
||||||
|
|
||||||
### Wallet Operations
|
|
||||||
```bash
|
```bash
|
||||||
# List all wallets
|
# Check balance across all mints
|
||||||
cdk-cli wallet list
|
cdk-cli balance
|
||||||
|
|
||||||
# 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
|
### Minting Tokens
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# List connected mints
|
# Mint tokens with a Lightning invoice
|
||||||
cdk-cli wallet list-mints
|
cdk-cli mint <MINT_URL> <AMOUNT>
|
||||||
|
|
||||||
# Remove a mint
|
# With options
|
||||||
cdk-cli wallet remove-mint <mint_url>
|
cdk-cli mint http://127.0.0.1:8085 1000 \
|
||||||
|
--method bolt11
|
||||||
|
|
||||||
|
# Using an existing quote
|
||||||
|
cdk-cli mint http://127.0.0.1:8085 --quote-id <quote_id>
|
||||||
|
|
||||||
|
# Claim pending mint quotes that have been paid
|
||||||
|
cdk-cli mint-pending
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sending & Receiving Tokens
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Send tokens (interactive)
|
||||||
|
cdk-cli send
|
||||||
|
|
||||||
|
# Send with specific options
|
||||||
|
cdk-cli send \
|
||||||
|
--memo "Coffee payment" \
|
||||||
|
--mint-url http://127.0.0.1:8085 \
|
||||||
|
--include-fee \
|
||||||
|
--offline
|
||||||
|
|
||||||
|
# Send with P2PK lock
|
||||||
|
cdk-cli send --pubkey <public_key> --required-sigs 1
|
||||||
|
|
||||||
|
# Send with HTLC (Hash Time Locked Contract)
|
||||||
|
cdk-cli send --hash <hash> --locktime <unix_timestamp>
|
||||||
|
|
||||||
|
# Send as V3 token
|
||||||
|
cdk-cli send --v3
|
||||||
|
|
||||||
|
# Send with automatic transfer from other mints if needed
|
||||||
|
cdk-cli send --allow-transfer --max-transfer-amount 1000
|
||||||
|
|
||||||
|
# Receive tokens
|
||||||
|
cdk-cli receive <cashu_token>
|
||||||
|
|
||||||
|
# Receive with signing key (for P2PK)
|
||||||
|
cdk-cli receive <cashu_token> --signing-key <private_key>
|
||||||
|
|
||||||
|
# Receive with HTLC preimage
|
||||||
|
cdk-cli receive <cashu_token> --preimage <preimage>
|
||||||
|
|
||||||
|
# Receive via Nostr
|
||||||
|
cdk-cli receive --nostr-key <nostr_key> --relay wss://relay.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lightning Payments
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Pay a Lightning invoice (interactive - will prompt for invoice)
|
||||||
|
cdk-cli melt
|
||||||
|
|
||||||
|
# Specify mint and payment method
|
||||||
|
cdk-cli melt --mint-url http://127.0.0.1:8085 --method bolt11
|
||||||
|
|
||||||
|
# Pay BOLT12 offer
|
||||||
|
cdk-cli melt --method bolt12
|
||||||
|
|
||||||
|
# Pay BIP353 address
|
||||||
|
cdk-cli melt --method bip353
|
||||||
|
|
||||||
|
# Multi-path payment
|
||||||
|
cdk-cli melt --mpp
|
||||||
|
```
|
||||||
|
|
||||||
|
### Payment Requests
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create a payment request (interactive via Nostr)
|
||||||
|
cdk-cli create-request
|
||||||
|
|
||||||
|
# Create with specific amount
|
||||||
|
cdk-cli create-request --amount 1000 "Invoice for services"
|
||||||
|
|
||||||
|
# Create with P2PK condition
|
||||||
|
cdk-cli create-request --amount 500 \
|
||||||
|
--pubkey <pubkey1> \
|
||||||
|
--pubkey <pubkey2> \
|
||||||
|
--num-sigs 2
|
||||||
|
|
||||||
|
# Create with HTLC
|
||||||
|
cdk-cli create-request --amount 1000 --hash <hash>
|
||||||
|
# Or use preimage instead
|
||||||
|
cdk-cli create-request --amount 1000 --preimage <preimage>
|
||||||
|
|
||||||
|
# Create with HTTP transport
|
||||||
|
cdk-cli create-request --amount 1000 \
|
||||||
|
--transport http \
|
||||||
|
--http-url https://myserver.com/payment
|
||||||
|
|
||||||
|
# Create without transport (just print the request)
|
||||||
|
cdk-cli create-request --amount 1000 --transport none
|
||||||
|
|
||||||
|
# Pay a payment request
|
||||||
|
cdk-cli pay-request <payment_request>
|
||||||
|
|
||||||
|
# Decode a payment request
|
||||||
|
cdk-cli decode-request <payment_request>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Token Transfer Between Mints
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Transfer tokens between mints (interactive)
|
||||||
|
cdk-cli transfer
|
||||||
|
|
||||||
|
# Transfer specific amount
|
||||||
|
cdk-cli transfer \
|
||||||
|
--source-mint http://mint1.example.com \
|
||||||
|
--target-mint http://mint2.example.com \
|
||||||
|
--amount 1000
|
||||||
|
|
||||||
|
# Transfer full balance from one mint to another
|
||||||
|
cdk-cli transfer \
|
||||||
|
--source-mint http://mint1.example.com \
|
||||||
|
--target-mint http://mint2.example.com \
|
||||||
|
--full-balance
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mint Information & Management
|
||||||
|
|
||||||
|
```bash
|
||||||
# Get mint information
|
# Get mint information
|
||||||
cdk-cli wallet mint-info <mint_url>
|
cdk-cli mint-info <MINT_URL>
|
||||||
|
|
||||||
|
# Update mint URL (if mint has migrated)
|
||||||
|
cdk-cli update-mint-url <OLD_URL> <NEW_URL>
|
||||||
|
|
||||||
|
# List proofs from mint
|
||||||
|
cdk-cli list-mint-proofs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Payment Operations
|
### Token & Proof Management
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pay a Lightning invoice
|
# Decode a Cashu token
|
||||||
cdk-cli wallet pay-invoice <lightning_invoice>
|
cdk-cli decode-token <cashu_token>
|
||||||
|
|
||||||
# Create melt quote for an invoice
|
# Check pending proofs and reclaim if no longer pending
|
||||||
cdk-cli wallet melt-quote <lightning_invoice>
|
cdk-cli check-pending
|
||||||
|
|
||||||
# Execute the melt
|
# Burn spent tokens (cleanup)
|
||||||
cdk-cli wallet melt <quote_id>
|
cdk-cli burn
|
||||||
|
|
||||||
|
# Restore proofs from seed for a specific mint
|
||||||
|
cdk-cli restore <MINT_URL>
|
||||||
```
|
```
|
||||||
|
|
||||||
### Token Management
|
### Advanced Features
|
||||||
|
|
||||||
|
#### Blind Authentication (NUT-14)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# List all tokens
|
# Mint blind authentication proofs
|
||||||
cdk-cli wallet list-tokens
|
cdk-cli mint-blind-auth <MINT_URL> --amount <AMOUNT>
|
||||||
|
```
|
||||||
|
|
||||||
# Check token states
|
#### CAT (Cashu Authentication Tokens)
|
||||||
cdk-cli wallet check-tokens
|
|
||||||
|
|
||||||
# Restore wallet from seed
|
```bash
|
||||||
cdk-cli wallet restore --seed <seed_words>
|
# Login with username/password
|
||||||
|
cdk-cli cat-login --username <username> --password <password>
|
||||||
|
|
||||||
|
# Login with device code flow (OAuth-style)
|
||||||
|
cdk-cli cat-device-login
|
||||||
```
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
### Storage Location
|
||||||
|
|
||||||
The CLI stores its configuration and wallet data in:
|
The CLI stores its configuration and wallet data in:
|
||||||
- **Linux/macOS**: `~/.config/cdk-cli/`
|
- **Linux/macOS**: `~/.cdk-cli/`
|
||||||
- **Windows**: `%APPDATA%\cdk-cli\`
|
- **Windows**: `%USERPROFILE%\.cdk-cli\`
|
||||||
|
|
||||||
|
You can override this with the `--work-dir` option.
|
||||||
|
|
||||||
|
### Database Options
|
||||||
|
|
||||||
|
The CLI supports multiple database backends:
|
||||||
|
|
||||||
|
#### SQLite (default)
|
||||||
|
```bash
|
||||||
|
cdk-cli --engine sqlite balance
|
||||||
|
```
|
||||||
|
|
||||||
|
#### SQLCipher (encrypted SQLite)
|
||||||
|
```bash
|
||||||
|
# Requires building with --features sqlcipher
|
||||||
|
cdk-cli --engine sqlite --password mypassword balance
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Redb
|
||||||
|
```bash
|
||||||
|
# Requires building with --features redb
|
||||||
|
cdk-cli --engine redb balance
|
||||||
|
```
|
||||||
|
|
||||||
|
### Seed Management
|
||||||
|
|
||||||
|
The wallet seed is automatically generated and stored in `<work-dir>/seed` on first run. This seed is used to derive all keys and can be used to restore your wallet.
|
||||||
|
|
||||||
|
**Important**: Back up your seed file securely. Anyone with access to the seed can spend your tokens.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Complete Workflow Example
|
### Complete Workflow Example
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 1. Start a test mint (in another terminal)
|
# 1. Start a test mint (in another terminal)
|
||||||
cdk-mintd
|
cdk-mintd
|
||||||
|
|
||||||
# 2. Add the mint
|
# 2. Mint some tokens
|
||||||
cdk-cli wallet add-mint http://127.0.0.1:8085
|
cdk-cli mint http://127.0.0.1:8085 1000 "Initial mint"
|
||||||
|
# Pay the displayed Lightning invoice
|
||||||
|
|
||||||
# 3. Create a mint quote
|
# 3. Check balance
|
||||||
cdk-cli wallet mint-quote 1000
|
cdk-cli balance
|
||||||
|
|
||||||
# 4. Pay the Lightning invoice (if using real Lightning backend)
|
# 4. Send some tokens
|
||||||
# or wait a few seconds if using fake wallet
|
cdk-cli send
|
||||||
|
# Follow interactive prompts
|
||||||
|
|
||||||
# 5. Mint the tokens
|
# 5. The recipient can receive with:
|
||||||
cdk-cli wallet mint <quote_id>
|
cdk-cli receive <cashu_token_string>
|
||||||
|
|
||||||
# 6. Check balance
|
# 6. Pay a Lightning invoice
|
||||||
cdk-cli wallet balance
|
cdk-cli melt
|
||||||
|
# Follow prompts to enter invoice
|
||||||
# 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
|
### Multi-Mint Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create wallets for different purposes
|
# Mint from multiple mints
|
||||||
cdk-cli wallet new --name savings
|
cdk-cli mint http://mint1.example.com 5000
|
||||||
cdk-cli wallet new --name daily
|
cdk-cli mint http://mint2.example.com 3000
|
||||||
|
|
||||||
# Switch between wallets
|
# Check balance (shows breakdown by mint)
|
||||||
cdk-cli wallet set-default savings
|
cdk-cli balance
|
||||||
cdk-cli wallet balance
|
|
||||||
|
|
||||||
cdk-cli wallet set-default daily
|
# Transfer between mints
|
||||||
cdk-cli wallet balance
|
cdk-cli transfer \
|
||||||
|
--source-mint http://mint1.example.com \
|
||||||
|
--target-mint http://mint2.example.com \
|
||||||
|
--amount 2000
|
||||||
|
```
|
||||||
|
|
||||||
|
### Payment Request Workflow
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Recipient creates a payment request
|
||||||
|
cdk-cli create-request --amount 1000 "Payment for services"
|
||||||
|
# Copy the payment request string
|
||||||
|
|
||||||
|
# Sender pays the request
|
||||||
|
cdk-cli pay-request <payment_request_string>
|
||||||
|
```
|
||||||
|
|
||||||
|
### P2PK (Pay to Public Key) Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Send tokens locked to a public key
|
||||||
|
cdk-cli send --pubkey <recipient_pubkey> --required-sigs 1
|
||||||
|
|
||||||
|
# Recipient receives with their private key
|
||||||
|
cdk-cli receive <cashu_token> --signing-key <private_key>
|
||||||
|
```
|
||||||
|
|
||||||
|
### HTLC (Hash Time Locked Contract) Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create a preimage and hash (externally)
|
||||||
|
# hash = SHA256(preimage)
|
||||||
|
|
||||||
|
# Send with HTLC
|
||||||
|
cdk-cli send --hash <hash> --locktime 1700000000
|
||||||
|
|
||||||
|
# Recipient receives with preimage
|
||||||
|
cdk-cli receive <cashu_token> --preimage <preimage>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Help and Documentation
|
## Help and Documentation
|
||||||
@@ -174,8 +416,35 @@ cdk-cli wallet balance
|
|||||||
cdk-cli --help
|
cdk-cli --help
|
||||||
|
|
||||||
# Help for specific commands
|
# Help for specific commands
|
||||||
cdk-cli wallet --help
|
cdk-cli mint --help
|
||||||
cdk-cli wallet mint-quote --help
|
cdk-cli send --help
|
||||||
|
cdk-cli receive --help
|
||||||
|
cdk-cli create-request --help
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Pending Tokens
|
||||||
|
If you have pending tokens (sent but not received, or mint quotes paid but not claimed):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check and reclaim pending proofs
|
||||||
|
cdk-cli check-pending
|
||||||
|
|
||||||
|
# Claim paid mint quotes
|
||||||
|
cdk-cli mint-pending
|
||||||
|
```
|
||||||
|
|
||||||
|
### Cleaning Up
|
||||||
|
```bash
|
||||||
|
# Remove spent tokens from database
|
||||||
|
cdk-cli burn
|
||||||
|
```
|
||||||
|
|
||||||
|
### Restore from Seed
|
||||||
|
```bash
|
||||||
|
# Restore proofs from a specific mint
|
||||||
|
cdk-cli restore <MINT_URL>
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ For complete configuration options, see the [example configuration file](./examp
|
|||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- **[Configuration Examples](./example.config.toml)** - Complete configuration reference
|
- **[Configuration Examples](./example.config.toml)** - Complete configuration reference
|
||||||
- **[PostgreSQL Setup Guide](../../POSTGRES.md)** - Database setup instructions
|
- **[PostgreSQL Setup Guide](../../docker-compose.postgres.yaml)** - Database setup with Docker Compose
|
||||||
- **[Development Guide](../../DEVELOPMENT.md)** - Contributing and development setup
|
- **[Development Guide](../../DEVELOPMENT.md)** - Contributing and development setup
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|||||||
Reference in New Issue
Block a user