Bitcoin CTV & CSFS Proof-of-Concept Showcase
A comprehensive collection of Bitcoin use cases showcasingOP_CHECKTEMPLATEVERIFY (CTV) and OP_CHECKSIGFROMSTACK (CSFS).
Built for Mutinynet signet with CTV and CSFS activation
β οΈ Disclaimer: This is an experimental project for educational purposes.
Doko demonstrates Bitcoin smart contract capabilities through multiple proof-of-concept implementations. Each use case showcases different aspects of covenant-based Bitcoin programming using CTV for transaction templates and CSFS for signature delegation.
| Use Case | Description | Key Features |
|---|---|---|
| Simple Vault | Basic time-locked Bitcoin vault | CTV covenant, CSV timelock, emergency recovery |
| Hybrid Vault | Corporate treasury with delegation | Multi-path Taproot, CTV + CSFS, role-based access |
| Nostr Vault | Key delegation using Nostr | CSFS + Nostr events, onchain signature verification |
| Prediction Market | Nostr based Bitcoin prediction market | Oracle integration, proportional payouts, real Bitcoin |
π Simple Vault (CTV-Only)
A basic Bitcoin vault using CheckTemplateVerify (CTV) covenants for time-locked withdrawals with emergency recovery capabilities.
- CTV Covenant Protection: Funds locked by transaction template
- CSV Timelock: Configurable delay for hot withdrawals
- Emergency Recovery: Immediate cold storage clawback
- NUMS Internal Key: Script-spend only security
ββββββββββββββββ CTV ββββββββββββββββ IF/ELSE ββββββββββββββββ
β Vault β βββββββββΊ β Trigger β βββββββββββββΊ β Final β
β (P2TR) β β (P2TR) β β Destination β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
Covenant Conditional Hot or Cold
Protection Spending Wallet
# Cold recovery scenario
cargo run -- auto-demo --vault-type simple --scenario cold-recovery
# Hot withdrawal scenario
cargo run -- auto-demo --vault-type simple --scenario hot-withdrawal
# Interactive dashboard
cargo run -- dashboard --vault-type simple- Deposit: Fund vault P2TR address with CTV script
- Trigger: Anyone can broadcast exact trigger transaction
- Withdraw: Either hot (after CSV delay) or cold (immediate)
π Hybrid Vault (CTV + CSFS)
Advanced corporate treasury vault combining CTV covenants with CSFS delegation for multi-path Taproot spending scenarios.
- Dual-Path Taproot: CTV covenant + CSFS delegation
- Role-Based Access: Treasurer, operations, hot/cold wallets
- Flexible Spending: Timelock OR delegation paths
- Corporate Treasury: Real-world organizational structure
ββββββββββββββββββββββββββββββββββββ
β Hybrid Vault UTXO (P2TR) β
β (NUMS Internal Key) β
βββββββββββββββββββ¬βββββββββββββββββ
β Script-Path Spend
βΌ
ββββββββββββββββββββββ΄βββββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β Path 1: CTV Covenant Script β β Path 2: CSFS Delegation β
β (<trigger_hash> OP_CTV) β β(<sig> <msg> <pubkey> OP_CSFS)β
ββββββββββββββββ¬ββββββββββββββββ ββββββββββββββββ¬ββββββββββββββββ
β β
βΌ βΌ
ββββββββββ΄βββββββββ βββββββββββββββββββ
β β β Delegated β
βΌ βΌ β Spending β
βββββββββββββββββββ βββββββββββββββββββ β Transaction β
β π₯ HOT PATH β β βοΈ COLD PATH β βββββββββββββββββββ
β (IF Branch) β β (ELSE Branch) β
βββββββββββββββββββ βββββββββββββββββββ
# Hot withdrawal via CTV covenant
cargo run -- auto-demo --vault-type hybrid --scenario hot-withdrawal
# Cold recovery via CTV covenant
cargo run -- auto-demo --vault-type hybrid --scenario cold-recovery
# CSFS delegation spending
cargo run -- auto-demo --vault-type hybrid --scenario csfs-delegation
# Interactive dashboard
cargo run -- dashboard --vault-type hybrid- Treasurer: CSFS delegation authority
- Operations: Delegated spending recipient
- Hot Wallet: Time-locked withdrawals
- Cold Wallet: Emergency recovery
π Nostr Vault (CSFS + Nostr)
Decentralized social signature verification system using CSFS to verify Nostr event signatures directly on the Bitcoin blockchain.
- Nostr Integration: Real Nostr event generation and signing
- Onchain Verification: CSFS validates Nostr signatures
- Social Consensus: Decentralized signature authority
- Event Hash Binding: Cryptographic link to social events
βββββββββββββββββββ Nostr Event βββββββββββββββββββ
β Social Layer β βββββββββββββββββΊ β Bitcoin Layer β
β (Nostr Event) β β (CSFS Spending) β
βββββββββββββββββββ βββββββββββββββββββ
Schnorr Sig Signature Verification
Event Content Onchain Validation
# Nostr signature verification demo
cargo run -- auto-demo --vault-type nostr
# View detailed Nostr event information
cargo run -- auto-demo --vault-type nostr --scenario detailed- Nostr Events: Standard Nostr event format with content and signature
- CSFS Verification: Onchain signature validation using OP_CHECKSIGFROMSTACK
- Event Binding: Hash commitment to specific social events
- Schnorr Signatures: Compatible with Bitcoin's signature format
π Prediction Market (Nostr + CSFS)
Bitcoin prediction market using Nostr oracles and CSFS for outcome verification with real Bitcoin operations.
- Nostr Oracle Integration: Decentralized outcome resolution
- Proportional Payouts: Winners split pool based on bet size
βββββββββββββββββββ Bet βββββββββββββββββββ Oracle βββββββββββββββββββ
β Participants β βββββββββΊ β Market Address β ββββββββββββΊ β Payout CSFS β
β (Bettors) β β (Taproot) β β Transaction β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
Multiple bets Dual outcome Winner claims
Different outcomes scripts A/B Proportional share
# Run full prediction market demo
cargo run --bin demo_prediction_market
# Run with automatic mode (no manual prompts)
cargo run --bin demo_prediction_market -- --auto
# Command-line market management
cargo run --bin nostr_market -- --help- Market Creation: Define question, outcomes, oracle, settlement time
- Betting Phase: Participants fund market with real Bitcoin
- Price Monitoring: Live Bitcoin price tracking via CoinGecko API
- Oracle Settlement: Nostr oracle signs outcome at settlement time
- Payout Distribution: Winners claim proportional shares via CSFS
- Taproot Scripts: Dual-path scripts for binary outcomes A/B
- CSFS Verification: Oracle signatures validated onchain
- Real Transactions: Actual Bitcoin network operations
- Transaction Analysis: Detailed blockchain transaction parsing
- Explorer Integration: Live transaction links and monitoring
- Rust 1.70+
- Access to Mutinynet signet node
- Bitcoin Core with RPC access
git clone https://github.com/AbdelStark/doko.git
cd doko
cargo build --releaseCreate a .env file in the project root:
RPC_URL=127.0.0.1
RPC_PORT=38332
RPC_USER=user
RPC_PASSWORD=password
RPC_WALLET=vault_manager_wallet# Vault demos
cargo run -- auto-demo --vault-type simple --scenario cold-recovery
cargo run -- auto-demo --vault-type hybrid --scenario csfs-delegation
cargo run -- auto-demo --vault-type nostr
# Interactive dashboards
cargo run -- dashboard --vault-type simple
cargo run -- dashboard --vault-type hybrid
# Prediction market
cargo run --bin demo_prediction_market -- --auto
cargo run --bin nostr_market create --question "Bitcoin above $100k?" --outcome-a "Yes" --outcome-b "No"- Real-time Monitoring: Live blockchain state tracking
- Transaction History: Comprehensive transaction logs
- Vault Management: Interactive vault operations
- Balance Tracking: Multi-address balance monitoring
- Network Status: Chain state and confirmation tracking
doko/
βββ src/
β βββ vaults/ # Vault implementations
β βββ prediction_markets/ # Prediction market system
β βββ services/ # Bitcoin network services
β βββ tui/ # Terminal user interface
β βββ config/ # Configuration management
βββ bin/ # Executable binaries
βββ app/ # Web interface (future)
βββ resources/ # Static assets
- Vaults: Simple, Hybrid, and Nostr vault implementations
- Prediction Markets: Nostr-based prediction market system
- Services: RPC client, explorer integration, transaction analysis
- TUI: Interactive terminal dashboards
- Config: Network configuration and environment management
# Run all tests
cargo test
# Run specific test suites
cargo test --test integration_tests
cargo test --lib prediction_markets
# Run with verbose output
cargo test -- --nocaptureThis project is licensed under the MIT License.
