Skip to content

feat(core): expose Block::check_context_free#177

Draft
pzafonte wants to merge 1 commit into
sedited:masterfrom
pzafonte:context-free-block-validation
Draft

feat(core): expose Block::check_context_free#177
pzafonte wants to merge 1 commit into
sedited:masterfrom
pzafonte:context-free-block-validation

Conversation

@pzafonte
Copy link
Copy Markdown
Contributor

@pzafonte pzafonte commented May 7, 2026

Wraps btck_block_check from bitcoin/bitcoin#33908. The function performs context-free validation of a block (size, weight, coinbase, transactions, sigops), with optional proof-of-work and merkle-root checks toggled via the BLOCK_CHECK_BASE / _POW / _MERKLE / _ALL flags. Useful for early rejection of invalid blocks before any chainstate-dependent validation runs.

The Rust signature mirrors the C contract: validation_state is filled in-place and the function returns a bool. Adds an AsPtr<btck_ChainParameters> impl on ChainParams and re-exports the owned BlockValidationState type since callers now need to construct one. The flag constants follow the existing VERIFY_* pattern and are also exposed via a block_check_flags submodule mirroring verify_flags.

Test mirrors upstream's btck_check_block_context_free case-by-case (valid block, mutated merkle, bad PoW, tampered coinbase, truncated bytes), reusing a single state to verify the documented reset-on-entry behavior.

Draft until subtree is synced, but tested locally on updated subree.

Closes #155.

Wraps btck_block_check from bitcoin/bitcoin#33908 to validate
a block's structure without chainstate or block index access.
Proof-of-work and merkle-root checks are optional via the
BLOCK_CHECK_BASE / _POW / _MERKLE / _ALL flags, exposed through
a block_check_flags submodule mirroring verify_flags.

Adds AsPtr<btck_ChainParameters> for ChainParams and re-exports
the owned BlockValidationState so callers can construct one.
Test mirrors upstream's btck_check_block_context_free case-by-case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add context-free Block Validation

1 participant