A robust RGB validation software with advanced Bitcoin smart contract support and multi-network capabilities.
- Mainnet: Production network (real BTC)
- Testnet: Testing network (test BTC)
- Regtest: Local development with Polar
-
Multiple Address Types:
- Taproot (P2TR): Enhanced privacy and smart contracts
- Native SegWit (P2WPKH): Efficient transactions
- Nested SegWit (P2SH-P2WPKH): Backward compatibility
- Legacy (P2PKH): Maximum compatibility
-
HD Wallet Features:
- BIP44/49/84/86 compliant
- Network-specific derivation paths
- Secure key storage and encryption
- Multiple address generation
-
Transaction Management:
- Send bitcoin with custom fee rates
- Add memos to transactions
- UTXO tracking and management
- Freeze specific UTXOs
- Custom fee rate support (sat/vB)
- Freezing Capabilities:
- Create and freeze specific UTXOs
- Add memos to frozen UTXOs
- Track frozen UTXOs separately
- Prevent spending of frozen UTXOs
-
Taproot Capabilities:
- MAST (Merkelized Alternative Script Trees)
- Schnorr signatures
- Complex script conditions
- Enhanced privacy features
-
Contract Types:
- Time-locked contracts
- Multi-signature wallets
- Atomic swaps
- Hash Time Locked Contracts (HTLCs)
- Create and manage fungible tokens
- Network-aware token transfers
- UTXO validation and tracking
- Atomic swap support
- Encrypted wallet storage
- Network isolation
- Secure key management
- Address validation
- Distributed Hash Table (DHT):
- Peer discovery
- Decentralized network topology
- Automatic peer routing
- Gossip Protocol:
- Wallet state synchronization
- Real-time updates
- Efficient message propagation
- Topic-based pub/sub
The easiest way to get started is using Docker:
# Clone the repository
git clone https://github.com/anoncodemonkey/RGBvalidator.git
cd token-validator
# Create .env file
cat > .env << EOL
BITCOIN_RPC_USER=your_username
BITCOIN_RPC_PASSWORD=your_password
SECRET_KEY=your-secret-key-here
EOL
# Start the services
docker-compose up -d
# Check services status
docker-compose ps
# View logs
docker-compose logs -f
The Docker setup provides:
- Automatic Bitcoin Core setup (regtest mode)
- Pre-configured validator service
- Persistent data storage
- Health monitoring
- Automatic restarts
If you prefer not to use Docker:
# Clone the repository
git clone https://github.com/anoncodemonkey/RGBvalidator.git
cd token-validator
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Edit the .env
file:
# Bitcoin RPC settings (used by both services)
BITCOIN_RPC_USER=your_username
BITCOIN_RPC_PASSWORD=your_password
SECRET_KEY=your-secret-key-here
Create a .env
file:
# Choose network: mainnet, testnet, or regtest
BITCOIN_NETWORK=regtest # Default for development
# Bitcoin RPC settings
BITCOIN_RPC_HOST=localhost
BITCOIN_RPC_PORT=18443 # Regtest default
BITCOIN_RPC_USER=your_username
BITCOIN_RPC_PASSWORD=your_password
With Docker:
# Execute commands inside the validator container
docker-compose exec validator python -m validator wallet create my_wallet
docker-compose exec validator python -m validator wallet generate my_wallet
Without Docker:
python -m validator wallet create my_wallet
python -m validator wallet generate my_wallet
- Create wallets for different networks:
# Create Taproot wallet (recommended for new projects)
python -m validator wallet create taproot_wallet --type taproot --network regtest
# Create SegWit wallet
python -m validator wallet create segwit_wallet --type segwit --network testnet
# Create Legacy wallet
python -m validator wallet create legacy_wallet --type legacy --network mainnet
- Generate addresses:
# Generate single address
python -m validator wallet generate wallet_name
# Generate multiple addresses
python -m validator wallet generate wallet_name --count 5
- Send Bitcoin:
# Send with default fee rate (5 sat/vB for regtest)
python -m validator wallet send wallet_name recipient_address 0.1
# Send with custom fee rate and memo
python -m validator wallet send wallet_name recipient_address 0.1 --fee-rate 10 --memo "Payment for services"
- Manage UTXOs:
# Create and freeze a UTXO
python -m validator wallet freeze-utxo wallet_name 0.1 --memo "Reserved for special purpose"
# Check wallet balance (includes frozen UTXOs)
python -m validator wallet balance wallet_name
- View wallet information:
# List all wallets
python -m validator wallet list
# View specific wallet details
python -m validator wallet info wallet_name
# View network-specific addresses
python -m validator wallet network wallet_name
- Use with Polar for testing
- Instant block generation
- Default fee rate: 5 sat/vB
- Address formats:
- Taproot: bcrt1p...
- SegWit: bcrt1q...
- Nested SegWit: 2...
- Legacy: m/n...
- Free test bitcoins
- Dynamic fee estimation
- Address formats:
- Taproot: tb1p...
- SegWit: tb1q...
- Nested SegWit: 2...
- Legacy: m/n...
- Faucet: https://testnet-faucet.mempool.co/
- Real bitcoin transactions
- Dynamic fee estimation
- Address formats:
- Taproot: bc1p...
- SegWit: bc1q...
- Nested SegWit: 3...
- Legacy: 1...
# Example Timelock Contract
{
"contract_type": "timelock",
"unlock_time": "2024-12-31T23:59:59Z",
"conditions": {
"before_timeout": ["pubkey_A"],
"after_timeout": ["pubkey_B"]
}
}
# Example Token Swap
{
"contract_type": "atomic_swap",
"asset_offered": {"type": "bitcoin", "amount": 1.0},
"asset_requested": {"type": "token", "amount": 1000},
"timeout": 24 # hours
}
-
Network Isolation
- Use separate wallets for each network
- Verify address formats before sending
- Use network-specific backups
-
Development Workflow
- Start with regtest/Polar
- Move to testnet for integration
- Thorough testing before mainnet
-
Production Safeguards
- Double-check network settings
- Verify address formats
- Use strong encryption
- Keep secure backups
- Fork the repository
- Create a feature branch
- Test thoroughly on regtest/testnet
- Submit a pull request
MIT License - see LICENSE file
- Start development environment:
docker-compose up -d
- Access logs:
docker-compose logs -f validator # Validator logs
docker-compose logs -f bitcoin # Bitcoin Core logs
- Execute commands:
# Create wallet
docker-compose exec validator python -m validator wallet create dev_wallet
# Generate address
docker-compose exec validator python -m validator wallet generate dev_wallet
# Check balance
docker-compose exec validator python -m validator wallet balance dev_wallet
- Stop environment:
docker-compose down # Stop services
docker-compose down -v # Stop services and remove volumes
Docker volumes are used to persist data:
validator_data
: Wallet and application datavalidator_logs
: Application logsbitcoin_data
: Bitcoin Core data
- Check service status:
docker-compose ps
- View service logs:
docker-compose logs -f
- Restart services:
docker-compose restart
- Reset environment:
docker-compose down -v
docker-compose up -d
The cubaan
command allows you to experiment with DHT and gossip protocol functionality:
- Start the first instance:
# With Docker:
docker-compose exec validator python -m validator cubaan my_wallet --port 8000
# Without Docker:
python -m validator cubaan my_wallet --port 8000
- Start the second instance (in a different terminal):
# Get the multiaddr from the first instance output and use it here
# With Docker:
docker-compose exec validator python -m validator cubaan other_wallet --port 8001 --peer /ip4/127.0.0.1/tcp/8000/p2p/QmHash...
# Without Docker:
python -m validator cubaan other_wallet --port 8001 --peer /ip4/127.0.0.1/tcp/8000/p2p/QmHash...
The instances will:
- Automatically discover each other using DHT
- Share wallet states using gossip protocol
- Broadcast updates every 10 seconds
- Display received messages from other peers
To test different networks:
# Use custom topic for specific network testing
python -m validator cubaan my_wallet --port 8000 --topic testnet-sync
# Connect to specific peer with custom topic
python -m validator cubaan other_wallet --port 8001 --peer /ip4/127.0.0.1/tcp/8000/p2p/QmHash... --topic testnet-sync