From ad80abc73df38f94d887a905773c4500ca0c2961 Mon Sep 17 00:00:00 2001 From: TheCharlatan Date: Mon, 17 Jun 2024 22:50:23 +0200 Subject: [PATCH] kernel: Add block validation to C header The added function allows the user process and validate a given block with the chainstate manager. The *_process_block(...) function does some preliminary checks on the block before passing it to `ProcessNewBlock(...)`. These are similar to the checks in the `submitblock()` rpc. Richer processing of the block validation result will be made available in the following commits through the validation interface. The commits also adds a utility for deserializing a `CBlock` (`kernel_block_create()`) that may then be passed to the library for processing. The tests exercise the function for both mainnet and regtest. The commit also adds the data of 206 regtest blocks (some blocks also contain transactions). --- src/kernel/bitcoinkernel.cpp | 56 +++++++- src/kernel/bitcoinkernel.h | 77 +++++++++++ src/kernel/bitcoinkernel_wrapper.h | 40 ++++++ src/test/kernel/block_data.h | 213 +++++++++++++++++++++++++++++ src/test/kernel/test_kernel.cpp | 93 +++++++++++++ 5 files changed, 477 insertions(+), 2 deletions(-) create mode 100644 src/test/kernel/block_data.h diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp index 8eec1bc721a..7a08b6c9008 100644 --- a/src/kernel/bitcoinkernel.cpp +++ b/src/kernel/bitcoinkernel.cpp @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include