Framework
BitcoinKernel
BitcoinKernel is a Swift library wrapping Bitcoin Core’s libbitcoinkernel C API for block validation, chainstate management, chain sync, and script verification on iOS, iPadOS, macOS, and Linux.
Mentioned In
Overview
The BitcoinKernel module wraps Bitcoin Core’s libbitcoinkernel behind a type-safe Swift API modeled on Apple’s swift-crypto framework. The wrapped surface covers block validation, chainstate management, chain sync, and script verification. Network, wallet, and GUI subsystems are excluded by design.
Every opaque C handle is owned by a Swift class whose deinit calls the matching btck_*_destroy. Memory management is invisible to callers and OpaquePointer does not appear in public signatures. The BlockchainSync engine drives a ChainstateManager from any BlockSource and emits typed AsyncSequence progress per SE-0298.
The package is part of the 21.dev Swift Bitcoin ecosystem alongside swift-tor for privacy-routed sync, swift-event for async TCP sockets and a future P2P block-source substrate, and swift-openssl for TLS and crypto.
import BitcoinKernel
let params = ChainParameters(.regtest)
let options = ContextOptions()
options.setChainParams(params)
let context = try Context(options: options)
Where to start
To ship BitcoinKernel inside an iPhone, iPad, or Apple Silicon Mac app, read Embedding BitcoinKernel on iOS without an xcframework. It covers the SwiftPM target topology, data-directory placement, the cross-compile invocation, and the iOS-specific caveats for App Store review.
Topics
Guides
Essentials
Context and Configuration
Chainstate Management
Chain Sync
Blocks
Transactions
Script Verification
Validation
Logging
Functions
Extended Modules