BitcoinKernel ChainstateManager Class ChainstateManager The chainstate manager — validates blocks, maintains the block index and UTXO set, and exposes the active chain. final class ChainstateManager Mentioned In Getting Started with BitcoinKernel Embedding BitcoinKernel on iOS without an xcframework Overview One chainstate manager per on-disk data directory. Instantiate from a ChainstateManagerOptions (which binds it to a Context), then feed blocks via processBlock(_:) or headers via processBlockHeader(_:state:). BlockchainSync drives the block-feeding loop automatically; direct callers typically only use processBlock(_:) for replay or testing. Wraps the opaque btck_ChainstateManager type; deinit calls btck_chainstate_manager_destroy when the last Swift reference drops. Topics Initializers init(options: ChainstateManagerOptions) throwsCreates a chainstate manager from options. Instance Properties var activeChain: ChainThe active chain — the sequence of blocks from genesis to bestEntry, navigable by height. var bestEntry: BlockTreeEntryThe best (tip) block tree entry — the block with the most cumulative proof-of-work that the kernel currently considers the chain’s head. Instance Methods func blockTreeEntry(byHash: BlockHash) -> BlockTreeEntry?Looks up a block tree entry by its block hash. func importBlocks(from: [String]) -> BoolImports blocks from on-disk block files (blk00000.dat-style). func processBlock(Block) -> (success: Bool, isNew: Bool)Processes a block for validation and potential inclusion in the active chain — the workhorse of every sync run. func processBlockHeader(BlockHeader, state: BlockValidationState) -> BoolProcesses a block header for validation — runs Bitcoin Core’s AcceptBlockHeader checks without requiring the full block body. func readBlock(at: BlockTreeEntry) -> Block?Reads a previously-processed block from disk by its block tree entry. func readBlockSpentOutputs(at: BlockTreeEntry) -> BlockSpentOutputs?Reads the spent outputs (undo data) for a block from disk — the collection of UTXOs that this block consumed.