This is a PoC of utxo chat proposed by Tadge Dryja. A decentralized chat system that uses Bitcoin UTXOs for spam protection without bloating the blockchain.
-
Basic Message Validation
- UTXO verification through Bitcoin RPC
- Message signature verification (only p2pkh)
- Message size limits (10KB per UTXO) (not test!!!!)
-
Configuration
- Comprehensive JSON-based configuration
- RPC settings for Bitcoin node
- Network, database, and blockchain settings
- Debug and profiling options
-
Basic Client/Server
- HTTP server for message reception (should we change it to wss or other protocol)
- Test client for sending messages
- In-memory message storage
-
UTXO Verification Improvements
- Proper verification of UTXO ownership
- Script validation for different UTXO types
- Better error handling and logging
-
P2P Network Layer
- Peer discovery mechanism
- Message propagation between nodes
- Connection management
- Peer health monitoring
-
Data Persistence
- Persistent storage for messages
- UTXO tracking
- Message history
- Copy the example configuration:
cp config-example.json config.json
- Edit
config.json
with your settings. Here's what each section controls:
{
"DataDir": ".utxochat", // Directory for data storage
"Network": {
"ListenAddr": "0.0.0.0:8335", // Network listening address
"KnownPeers": [], // List of known peer addresses
"HandshakeTimeout": 60 // Peer handshake timeout in seconds
},
"Bitcoin": {
"RPCURL": "http://localhost:8332", // Bitcoin node RPC URL
"RPCUser": "your-username", // RPC username
"RPCPass": "your-password", // RPC password
"DisableTLS": true // Whether to disable TLS
},
"Database": {
"Type": "memory", // Database type (memory/leveldb)
"Path": ".utxochat/utxochat.db" // Database file path
},
"Blockchain": {
"NotificationsEnabled": true, // Enable block notifications
"MaxReorgDepth": 6, // Maximum reorg depth to handle
"ScanFullBlocks": true, // Whether to scan full blocks
"PollInterval": 30 // Block polling interval in seconds
},
"Message": {
"MaxPayloadSize": 65434, // Maximum message payload size
"MaxMessageSize": 65536 // Maximum total message size
},
"Debug": {
"Profile": "", // HTTP profiling port
"CPUProfile": "", // CPU profile output file
"MemoryProfile": "", // Memory profile output file
"TraceProfile": "", // Execution trace output file
"LogLevel": "info" // Logging level
}
}
- Start the server:
go run main.go
- Test with client:
cd cmd/client
go run main.go -message "Your test message"
-
Priority 1: UTXO Verification
- Implement proper script validation
- Add support for different UTXO types
- Improve error handling
-
Priority 2: P2P Network
- Design peer discovery protocol
- Implement message propagation
- Add connection management
-
Priority 3: Storage
- Design database schema
- Implement persistent storage
- Add message history queries
This project provides scripts to set up and test a Bitcoin regtest environment for UTXO chat development.
- Bitcoin Core installed and in your PATH
- Basic understanding of Bitcoin's regtest mode
- Make the scripts executable:
chmod +x scripts/*.sh
- Start the regtest environment:
./scripts/setup_regtest.sh
This will:
- Create three nodes (node1, node2, node3)
- Start them with different configurations
- Connect them together
- Generate initial blocks for testing
Use the test script to interact with the regtest environment:
./scripts/test_utxo_chat.sh
The script provides several functions:
get_new_address
: Get a new address from a nodeget_balance
: Check wallet balancesend_coins
: Send coins between addressesmine_blocks
: Mine new blocks
Example usage:
# Get a new address from node1
get_new_address "node1" "wallet1"
# Check balance
get_balance "node1" "wallet1"
# Mine blocks
mine_blocks "node1" 1
When you're done testing, clean up the environment:
./scripts/cleanup_regtest.sh
This will:
- Stop all regtest nodes
- Remove the regtest directories
- node1: Descriptor wallet, RPC port 18443
- node2: Non-descriptor wallet, RPC port 18444
- node3: Descriptor wallet, RPC port 18445
If you encounter issues:
- Check if Bitcoin Core is properly installed
- Ensure no other regtest nodes are running
- Check the regtest directories for any leftover files
- Try running the cleanup script before starting fresh