CSV Adapter Bitcoin
Bitcoin adapter for CSV (Client-Side Validation) with UTXO seals and SPV proofs.
Overview
This crate implements the AnchorLayer trait for Bitcoin, using UTXOs as single-use seals and Tapret/Opret for commitment publication. Bitcoin provides L1 Structural single-use enforcement through its UTXO model — when a UTXO is spent, it is consumed forever.
Key Features
- UTXO Seals: Native Bitcoin single-use enforcement (structural guarantee)
- Tapret Commitments: Taproot-based commitment anchoring (BIP-341)
- SPV Proofs: Simplified Payment Verification with Merkle proofs
- BIP-86 Wallets: Taproot key path derivation
- Signet/Testnet/Regtest: Full network support
- RPC Integration: Optional Bitcoin Core RPC client
Installation
Or in your Cargo.toml:
[]
= "0.1"
Features
| Feature | Description | Default |
|---|---|---|
rpc |
Enable Bitcoin Core RPC client (bitcoincore-rpc) |
❌ |
signet-rest |
Enable Signet REST API client (mempool.space) | ❌ |
production |
Enable all production-ready features (rpc) |
❌ |
Quick Start
Creating a Bitcoin Anchor Layer
use ;
// Create adapter for Signet (test network)
let adapter = signet?;
// Or for mainnet
// let adapter = BitcoinAnchorLayer::mainnet()?;
Working with UTXO Seals
use ;
use ;
let adapter = signet?;
// Create a seal from a UTXO
let seal = adapter.create_seal?;
// Publish a commitment (anchors a Right to Bitcoin)
let commitment = new;
let anchor = adapter.publish?;
Taproot Commitments
use ;
// Create a Tapret commitment
let tapret = new?;
// Mine a nonce for the Tapret script
let nonce = mine_tapret_nonce?;
SPV Proof Verification
use SpvVerifier;
// Verify a Merkle proof against a block header
let verifier = new;
let is_valid = verifier.verify?;
Architecture
BitcoinAnchorLayer
├── UTXO Seals ← Native single-use (L1 Structural)
├── Tapret/Opret ← Commitment publication
├── SPV Proofs ← Merkle tree verification
├── BIP-86 Wallets ← Taproot key derivation
└── RPC/REST Clients ← Network interaction
Seal Lifecycle
- Create: Derive a seal from an unspent UTXO
- Consume: Spend the UTXO (seal is gone forever)
- Anchor: Publish commitment via Tapret/Opret
- Verify: SPV proof confirms the transaction in a block
Examples
See the examples/ directory for usage patterns:
signet_real_tx_demo— Real transaction on Signet (requiressignet-restfeature)signet_funding_addr— Generate funding addresses (requiressignet-restfeature)signet_fixed_seed— Deterministic wallet generation (requiressignet-restfeature)
Run examples with:
License
This project is dual-licensed under either:
- Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contributing
We welcome contributions! Please see our GitHub repository for more information.