5#ifndef BITCOIN_KERNEL_BITCOINKERNEL_WRAPPER_H
6#define BITCOIN_KERNEL_BITCOINKERNEL_WRAPPER_H
110template <BitmaskEnum T>
113 return static_cast<T>(
114 static_cast<std::underlying_type_t<T>
>(lhs) |
static_cast<std::underlying_type_t<T>
>(rhs));
117template <BitmaskEnum T>
120 return static_cast<T>(
121 static_cast<std::underlying_type_t<T>
>(lhs) &
static_cast<std::underlying_type_t<T>
>(rhs));
124template <BitmaskEnum T>
127 return static_cast<T>(
128 static_cast<std::underlying_type_t<T>
>(lhs) ^
static_cast<std::underlying_type_t<T>
>(rhs));
131template <BitmaskEnum T>
134 return static_cast<T>(~static_cast<std::underlying_type_t<T>>(value));
137template <BitmaskEnum T>
140 return lhs = lhs | rhs;
143template <BitmaskEnum T>
146 return lhs = lhs & rhs;
149template <BitmaskEnum T>
152 return lhs = lhs ^ rhs;
158 if (ptr ==
nullptr) {
159 throw std::runtime_error(
"failed to instantiate btck object");
164template <
typename Collection,
typename ValueType>
210template <
typename Container,
typename SizeFunc,
typename GetFunc>
211concept IndexedContainer =
requires(
const Container& c, SizeFunc size_func, GetFunc get_func, std::size_t i) {
212 { std::invoke(size_func, c) } -> std::convertible_to<std::size_t>;
213 { std::invoke(get_func, c, i) };
216template <
typename Container, auto SizeFunc, auto GetFunc>
221 using value_type = std::invoke_result_t<
decltype(GetFunc),
const Container&,
size_t>;
232 static_assert(std::ranges::random_access_range<Range>);
249 if (index >=
size()) {
250 throw std::out_of_range(
"Index out of range");
252 return (*
this)[index];
259#define MAKE_RANGE_METHOD(method_name, ContainerType, SizeFunc, GetFunc, container_expr) \
260 auto method_name() const & { \
261 return Range<ContainerType, SizeFunc, GetFunc>{container_expr}; \
263 auto method_name() const && = delete;
268 std::vector<std::byte> bytes;
270 std::vector<std::byte>* bytes;
271 std::exception_ptr exception;
273 UserData user_data = UserData{.bytes = &bytes, .exception =
nullptr};
275 constexpr auto const write = +[](
const void* buffer,
size_t len,
void* user_data) ->
int {
276 auto&
data = *
reinterpret_cast<UserData*
>(user_data);
277 auto& bytes = *
data.bytes;
279 auto const* first =
static_cast<const std::byte*
>(buffer);
280 auto const* last = first + len;
281 bytes.insert(bytes.end(), first, last);
284 data.exception = std::current_exception();
289 if (to_bytes(
object, write, &user_data) != 0) {
290 std::rethrow_exception(user_data.exception);
295template <
typename CType>
307template <
typename CType, CType* (*CopyFunc)(const CType*),
void (*DestroyFunc)(CType*)>
321 if (
this != &other) {
333 m_ptr = std::exchange(other.m_ptr,
nullptr);
337 template <
typename ViewType>
338 requires std::derived_from<ViewType, View<CType>>
350template <
typename CType,
void (*DestroyFunc)(CType*)>
357 if (ptr) DestroyFunc(ptr);
360 std::unique_ptr<CType, Deleter>
m_ptr;
370class TransactionOutput;
372template <
typename Derived>
378 return static_cast<const Derived*
>(
this)->get();
387 std::span<const TransactionOutput> spent_outputs,
388 unsigned int input_index,
414template <
typename Derived>
420 return static_cast<const Derived*
>(
this)->get();
454template <
typename Derived>
460 return static_cast<const Derived*
>(
this)->get();
479 std::array<std::byte, 32> hash;
498template <
typename Derived>
504 return static_cast<const Derived*
>(
this)->get();
528class OutPoint :
public Handle<btck_TransactionOutPoint, btck_transaction_out_point_copy, btck_transaction_out_point_destroy>,
public OutPointApi<OutPoint>
535template <
typename Derived>
541 return static_cast<const Derived*
>(
this)->get();
567template <
typename Derived>
573 return static_cast<const Derived*
>(
this)->get();
628template <
typename Derived>
631 const std::span<const TransactionOutput> spent_outputs,
632 unsigned int input_index,
637 std::vector<const btck_TransactionOutput*> raw_spent_outputs;
638 if (spent_outputs.size() > 0) {
639 raw_spent_outputs.reserve(spent_outputs.size());
641 for (
const auto& output : spent_outputs) {
642 raw_spent_outputs.push_back(output.get());
644 spent_outputs_ptr = raw_spent_outputs.data();
650 spent_outputs_ptr, spent_outputs.size(),
657template <
typename Derived>
663 return static_cast<const Derived*
>(
this)->get();
679 std::array<std::byte, 32> hash;
694 explicit BlockHash(
const std::array<std::byte, 32>& hash)
704class Block :
public Handle<btck_Block, btck_block_copy, btck_block_destroy>
707 Block(
const std::span<const std::byte> raw_block)
763concept Log =
requires(
T a, std::string_view message) {
764 { a.LogMessage(message) } -> std::same_as<void>;
773 +[](void* user_data, const char* message, size_t message_len) {
static_cast<T*
>(user_data)->LogMessage({message, message_len}); },
775 +[](
void* user_data) {
delete static_cast<T*
>(user_data); })}
791 if (!entry)
return std::nullopt;
815 virtual void ProgressHandler(std::string_view title,
int progress_percent,
bool resume_possible) {}
864class ChainParams :
public Handle<btck_ChainParameters, btck_chain_parameters_copy, btck_chain_parameters_destroy>
881 template <
typename T>
884 static_assert(std::is_base_of_v<KernelNotifications, T>);
885 auto heap_notifications = std::make_unique<std::shared_ptr<T>>(std::move(notifications));
886 using user_type = std::shared_ptr<T>*;
890 .
user_data = heap_notifications.release(),
891 .user_data_destroy = +[](
void* user_data) {
delete static_cast<user_type
>(user_data); },
893 .header_tip = +[](
void* user_data,
btck_SynchronizationState state, int64_t height, int64_t timestamp,
int presync) { (*
static_cast<user_type
>(user_data))->HeaderTipHandler(
static_cast<SynchronizationState>(state), height, timestamp, presync == 1); },
894 .progress = +[](
void* user_data,
const char* title,
size_t title_len,
int progress_percent,
int resume_possible) { (*
static_cast<user_type
>(user_data))->ProgressHandler({title, title_len}, progress_percent, resume_possible == 1); },
895 .warning_set = +[](
void* user_data,
btck_Warning warning,
const char* message,
size_t message_len) { (*
static_cast<user_type
>(user_data))->WarningSetHandler(
static_cast<Warning>(warning), {message, message_len}); },
896 .warning_unset = +[](
void* user_data,
btck_Warning warning) { (*
static_cast<user_type
>(user_data))->WarningUnsetHandler(
static_cast<Warning>(warning)); },
897 .flush_error = +[](
void* user_data,
const char* error,
size_t error_len) { (*
static_cast<user_type
>(user_data))->FlushErrorHandler({error, error_len}); },
898 .fatal_error = +[](
void* user_data,
const char* error,
size_t error_len) { (*
static_cast<user_type
>(user_data))->FatalErrorHandler({error, error_len}); },
902 template <
typename T>
905 static_assert(std::is_base_of_v<ValidationInterface, T>);
906 auto heap_vi = std::make_unique<std::shared_ptr<T>>(std::move(validation_interface));
907 using user_type = std::shared_ptr<T>*;
912 .user_data_destroy = +[](
void* user_data) {
delete static_cast<user_type
>(user_data); },
921class Context :
public Handle<btck_Context, btck_context_copy, btck_context_destroy>
993 if (!index)
throw std::runtime_error(
"No entry in the chain at the provided height");
1005template <
typename Derived>
1011 return static_cast<const Derived*
>(
this)->get();
1042template <
typename Derived>
1048 return static_cast<const Derived*
>(
this)->get();
1087 :
Handle{block_spent_outputs}
1114 std::vector<const char*> c_paths;
1115 std::vector<size_t> c_paths_lens;
1116 c_paths.reserve(paths.size());
1117 c_paths_lens.reserve(paths.size());
1118 for (
const auto& path : paths) {
1119 c_paths.push_back(path.c_str());
1120 c_paths_lens.push_back(path.length());
1130 if (new_block) *new_block = _new_block == 1;
1142 if (!entry)
return std::nullopt;
1149 if (!block)
return std::nullopt;
int btck_block_to_bytes(const btck_Block *block, btck_WriteBytes writer, void *user_data)
void btck_logging_disable()
This disables the global internal logger.
int btck_script_pubkey_to_bytes(const btck_ScriptPubkey *script_pubkey_, btck_WriteBytes writer, void *user_data)
int btck_chainstate_manager_import_blocks(btck_ChainstateManager *chainman, const char **block_file_paths_data, size_t *block_file_paths_lens, size_t block_file_paths_data_len)
Triggers the start of a reindex if the wipe options were previously set for the chainstate manager.
const btck_Coin * btck_transaction_spent_outputs_get_coin_at(const btck_TransactionSpentOutputs *transaction_spent_outputs, size_t coin_index)
Returns a coin contained in the transaction spent outputs at a certain index.
const btck_TransactionInput * btck_transaction_get_input_at(const btck_Transaction *transaction, size_t input_index)
Get the transaction input at the provided index.
void btck_logging_enable_category(btck_LogCategory category)
Enable a specific log category for the global internal logger.
uint32_t btck_coin_confirmation_height(const btck_Coin *coin)
Returns the block height where the transaction that created this coin was included in.
void btck_context_options_set_notifications(btck_ContextOptions *options, btck_NotificationInterfaceCallbacks notifications)
Set the kernel notifications for the context options.
btck_ContextOptions * btck_context_options_create()
Creates an empty context options.
int64_t btck_transaction_output_get_amount(const btck_TransactionOutput *output)
Get the amount in the output.
void btck_chainstate_manager_options_update_chainstate_db_in_memory(btck_ChainstateManagerOptions *chainman_opts, int chainstate_db_in_memory)
Sets chainstate db in memory in the options.
const btck_Txid * btck_transaction_out_point_get_txid(const btck_TransactionOutPoint *out_point)
Get the txid from the transaction out point.
void btck_logging_disable_category(btck_LogCategory category)
Disable a specific log category for the global internal logger.
const btck_BlockTreeEntry * btck_block_tree_entry_get_previous(const btck_BlockTreeEntry *entry)
Returns the previous block tree entry in the tree, or null if the current block tree entry is the gen...
size_t btck_transaction_count_outputs(const btck_Transaction *transaction)
Get the number of outputs of a transaction.
btck_ScriptPubkey * btck_script_pubkey_create(const void *script_pubkey, size_t script_pubkey_len)
Create a script pubkey from serialized data.
btck_ChainParameters * btck_chain_parameters_create(const btck_ChainType chain_type)
Creates a chain parameters struct with default parameters based on the passed in chain type.
btck_ValidationMode btck_block_validation_state_get_validation_mode(const btck_BlockValidationState *block_validation_state_)
Returns the validation mode from an opaque block validation state pointer.
btck_Block * btck_block_create(const void *raw_block, size_t raw_block_length)
Parse a serialized raw block into a new block object.
void btck_chainstate_manager_options_update_block_tree_db_in_memory(btck_ChainstateManagerOptions *chainman_opts, int block_tree_db_in_memory)
Sets block tree db in memory in the options.
size_t btck_block_count_transactions(const btck_Block *block)
Count the number of transactions contained in a block.
btck_LoggingConnection * btck_logging_connection_create(btck_LogCallback callback, void *user_data, btck_DestroyCallback user_data_destroy_callback)
Start logging messages through the provided callback.
const btck_TransactionOutPoint * btck_transaction_input_get_out_point(const btck_TransactionInput *input)
Get the transaction out point.
btck_BlockSpentOutputs * btck_block_spent_outputs_read(const btck_ChainstateManager *chainman, const btck_BlockTreeEntry *entry)
btck_ChainstateManager * btck_chainstate_manager_create(const btck_ChainstateManagerOptions *chainman_opts)
Create a chainstate manager.
btck_BlockHash * btck_block_get_hash(const btck_Block *block)
Calculate and return the hash of a block.
const btck_TransactionSpentOutputs * btck_block_spent_outputs_get_transaction_spent_outputs_at(const btck_BlockSpentOutputs *block_spent_outputs, size_t transaction_index)
Returns a transaction spent outputs contained in the block spent outputs at a certain index.
btck_Context * btck_context_create(const btck_ContextOptions *options)
Create a new kernel context.
const btck_TransactionOutput * btck_coin_get_output(const btck_Coin *coin)
Return the transaction output of a coin.
int btck_coin_is_coinbase(const btck_Coin *coin)
Returns whether the containing transaction was a coinbase.
void btck_txid_to_bytes(const btck_Txid *txid, unsigned char output[32])
int btck_script_pubkey_verify(const btck_ScriptPubkey *script_pubkey, const int64_t amount, const btck_Transaction *tx_to, const btck_TransactionOutput **spent_outputs_, size_t spent_outputs_len, const unsigned int input_index, const btck_ScriptVerificationFlags flags, btck_ScriptVerifyStatus *status)
int btck_chainstate_manager_options_set_wipe_dbs(btck_ChainstateManagerOptions *chainman_opts, int wipe_block_tree_db, int wipe_chainstate_db)
Sets wipe db in the options.
int btck_context_interrupt(btck_Context *context)
Interrupt can be used to halt long-running validation functions like when reindexing,...
const btck_TransactionOutput * btck_transaction_get_output_at(const btck_Transaction *transaction, size_t output_index)
Get the transaction outputs at the provided index.
void btck_logging_set_level_category(btck_LogCategory category, btck_LogLevel level)
Set the log level of the global internal logger.
void btck_context_options_set_chainparams(btck_ContextOptions *options, const btck_ChainParameters *chain_parameters)
const btck_BlockTreeEntry * btck_chain_get_tip(const btck_Chain *chain)
Get the block tree entry of the current chain tip.
btck_BlockHash * btck_block_hash_create(const unsigned char block_hash[32])
Create a block hash from its raw data.
void btck_context_options_set_validation_interface(btck_ContextOptions *options, btck_ValidationInterfaceCallbacks vi_cbs)
Set the validation interface callbacks for the context options.
uint32_t btck_transaction_out_point_get_index(const btck_TransactionOutPoint *out_point)
Get the output position from the transaction out point.
btck_Block * btck_block_read(const btck_ChainstateManager *chainman, const btck_BlockTreeEntry *entry)
const btck_Txid * btck_transaction_get_txid(const btck_Transaction *transaction)
Get the txid of a transaction.
int btck_chain_contains(const btck_Chain *chain, const btck_BlockTreeEntry *entry)
const btck_BlockTreeEntry * btck_chainstate_manager_get_block_tree_entry_by_hash(const btck_ChainstateManager *chainman, const btck_BlockHash *block_hash)
size_t btck_block_spent_outputs_count(const btck_BlockSpentOutputs *block_spent_outputs)
Returns the number of transaction spent outputs whose data is contained in block spent outputs.
const btck_BlockTreeEntry * btck_chain_get_by_height(const btck_Chain *chain, int height)
Retrieve a block tree entry by its height in the currently active chain.
int btck_block_hash_equals(const btck_BlockHash *hash1, const btck_BlockHash *hash2)
int32_t btck_block_tree_entry_get_height(const btck_BlockTreeEntry *entry)
Return the height of a certain block tree entry.
const btck_ScriptPubkey * btck_transaction_output_get_script_pubkey(const btck_TransactionOutput *output)
Get the script pubkey of the output.
int btck_chainstate_manager_process_block(btck_ChainstateManager *chainman, const btck_Block *block, int *_new_block)
size_t btck_transaction_count_inputs(const btck_Transaction *transaction)
Get the number of inputs of a transaction.
int btck_chain_get_height(const btck_Chain *chain)
Return the height of the tip of the chain.
int btck_txid_equals(const btck_Txid *txid1, const btck_Txid *txid2)
btck_Transaction * btck_transaction_create(const void *raw_transaction, size_t raw_transaction_len)
Create a new transaction from the serialized data.
const btck_BlockHash * btck_block_tree_entry_get_block_hash(const btck_BlockTreeEntry *entry)
Return the block hash associated with a block tree entry.
void btck_logging_set_options(const btck_LoggingOptions options)
Set some options for the global internal logger.
void btck_chainstate_manager_options_set_worker_threads_num(btck_ChainstateManagerOptions *opts, int worker_threads)
Set the number of available worker threads used during validation.
int btck_transaction_to_bytes(const btck_Transaction *transaction, btck_WriteBytes writer, void *user_data)
btck_TransactionOutput * btck_transaction_output_create(const btck_ScriptPubkey *script_pubkey, int64_t amount)
Create a transaction output from a script pubkey and an amount.
const btck_BlockTreeEntry * btck_chain_get_genesis(const btck_Chain *chain)
Get the block tree entry of the genesis block.
const btck_Transaction * btck_block_get_transaction_at(const btck_Block *block, size_t index)
Get the transaction at the provided index.
const btck_Chain * btck_chainstate_manager_get_active_chain(const btck_ChainstateManager *chainman)
Returns the best known currently active chain.
btck_ChainstateManagerOptions * btck_chainstate_manager_options_create(const btck_Context *context, const char *data_dir, size_t data_dir_len, const char *blocks_dir, size_t blocks_dir_len)
btck_BlockValidationResult btck_block_validation_state_get_block_validation_result(const btck_BlockValidationState *block_validation_state_)
Returns the validation result from an opaque block validation state pointer.
void btck_block_hash_to_bytes(const btck_BlockHash *block_hash, unsigned char output[32])
size_t btck_transaction_spent_outputs_count(const btck_TransactionSpentOutputs *transaction_spent_outputs)
Returns the number of previous transaction outputs contained in the transaction spent outputs data.
#define btck_ChainType_REGTEST
#define btck_ScriptVerificationFlags_P2SH
evaluate P2SH (BIP16) subscripts
uint8_t btck_LogLevel
The level at which logs should be produced.
#define btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY
enable CHECKLOCKTIMEVERIFY (BIP65)
int(* btck_WriteBytes)(const void *bytes, size_t size, void *userdata)
Function signature for serializing data.
#define btck_ChainType_MAINNET
#define btck_BlockValidationResult_HEADER_LOW_WORK
the block header may be on a too-little-work chain
#define btck_Warning_UNKNOWN_NEW_RULES_ACTIVATED
#define btck_BlockValidationResult_INVALID_PREV
A block this one builds on is invalid.
#define btck_LogCategory_MEMPOOL
#define btck_LogLevel_TRACE
#define btck_ChainType_TESTNET
#define btck_SynchronizationState_INIT_REINDEX
#define btck_ScriptVerifyStatus_ERROR_INVALID_FLAGS_COMBINATION
The flags were combined in an invalid way.
uint32_t btck_BlockValidationResult
A granular "reason" why a block was invalid.
#define btck_LogCategory_BENCH
uint8_t btck_ValidationMode
Whether a validated data structure is valid, invalid, or an error was encountered during processing.
#define btck_ScriptVerificationFlags_ALL
#define btck_LogCategory_PRUNE
uint8_t btck_SynchronizationState
Current sync state passed to tip changed callbacks.
#define btck_ChainType_TESTNET_4
#define btck_LogCategory_COINDB
#define btck_ScriptVerificationFlags_TAPROOT
enable TAPROOT (BIPs 341 & 342)
#define btck_ScriptVerifyStatus_ERROR_SPENT_OUTPUTS_REQUIRED
The taproot flag was set, so valid spent_outputs have to be provided.
#define btck_ScriptVerificationFlags_WITNESS
enable WITNESS (BIP141)
uint32_t btck_ScriptVerificationFlags
Script verification flags that may be composed with each other.
#define btck_LogCategory_VALIDATION
#define btck_LogCategory_REINDEX
#define btck_LogLevel_DEBUG
#define btck_ScriptVerifyStatus_OK
#define btck_ScriptVerificationFlags_NONE
#define btck_LogCategory_RAND
#define btck_BlockValidationResult_CONSENSUS
invalid by consensus rules (excluding any below reasons)
#define btck_BlockValidationResult_UNSET
initial value. Block has not yet been rejected
#define btck_SynchronizationState_POST_INIT
#define btck_BlockValidationResult_MISSING_PREV
We don't have the previous block the checked one is built on.
#define btck_LogCategory_ALL
uint8_t btck_ScriptVerifyStatus
A collection of status codes that may be issued by the script verify function.
#define btck_ValidationMode_INTERNAL_ERROR
uint8_t btck_LogCategory
A collection of logging categories that may be encountered by kernel code.
#define btck_ValidationMode_INVALID
#define btck_ChainType_SIGNET
#define btck_ScriptVerificationFlags_NULLDUMMY
enforce NULLDUMMY (BIP147)
#define btck_BlockValidationResult_INVALID_HEADER
invalid proof of work or time too old
uint8_t btck_Warning
Possible warning types issued by validation.
#define btck_BlockValidationResult_TIME_FUTURE
block timestamp was > 2 hours in the future (or our clock is bad)
#define btck_LogCategory_LEVELDB
#define btck_BlockValidationResult_CACHED_INVALID
this block was cached as being invalid and we didn't store the reason why
#define btck_Warning_LARGE_WORK_INVALID_CHAIN
#define btck_LogLevel_INFO
#define btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY
enable CHECKSEQUENCEVERIFY (BIP112)
#define btck_LogCategory_BLOCKSTORAGE
#define btck_ValidationMode_VALID
#define btck_LogCategory_KERNEL
#define btck_ScriptVerificationFlags_DERSIG
enforce strict DER (BIP66) compliance
#define btck_BlockValidationResult_MUTATED
the block's data didn't match the data committed to by the PoW
#define btck_SynchronizationState_INIT_DOWNLOAD
#define MAKE_RANGE_METHOD(method_name, ContainerType, SizeFunc, GetFunc, container_expr)
bool operator==(const Derived &other) const
std::array< std::byte, 32 > ToBytes() const
bool operator!=(const Derived &other) const
BlockHash(const std::array< std::byte, 32 > &hash)
BlockHash(btck_BlockHash *hash)
BlockHash(const BlockHashView &view)
BlockHashView(const btck_BlockHash *ptr)
BlockHash GetHash() const
std::vector< std::byte > ToBytes() const
TransactionView GetTransaction(size_t index) const
size_t CountTransactions() const
Block(const std::span< const std::byte > raw_block)
TransactionSpentOutputsView GetTxSpentOutputs(size_t tx_undo_index) const
BlockSpentOutputs(btck_BlockSpentOutputs *block_spent_outputs)
int32_t GetHeight() const
BlockTreeEntry(const btck_BlockTreeEntry *entry)
std::optional< BlockTreeEntry > GetPrevious() const
BlockHashView GetHash() const
BlockValidationResult GetBlockValidationResult() const
BlockValidationState(BlockValidationState &&)=delete
BlockValidationState(const btck_BlockValidationState *state)
BlockValidationState & operator=(BlockValidationState &&)=delete
BlockValidationState & operator=(const BlockValidationState &)=delete
ValidationMode GetValidationMode() const
BlockValidationState(const BlockValidationState &)=delete
const btck_BlockValidationState * m_state
std::optional< BlockTreeEntry > GetBlockTreeEntry(const BlockHash &block_hash) const
std::optional< Block > ReadBlock(const BlockTreeEntry &entry) const
BlockSpentOutputs ReadBlockSpentOutputs(const BlockTreeEntry &entry) const
ChainView GetChain() const
ChainMan(const Context &context, const ChainstateManagerOptions &chainman_opts)
bool ImportBlocks(const std::span< const std::string > paths)
bool ProcessBlock(const Block &block, bool *new_block)
ChainParams(ChainType chain_type)
ChainView(const btck_Chain *ptr)
BlockTreeEntry GetByHeight(int height) const
BlockTreeEntry Tip() const
bool Contains(BlockTreeEntry &entry) const
BlockTreeEntry Genesis() const
ChainstateManagerOptions(const Context &context, const std::string &data_dir, const std::string &blocks_dir)
void SetWorkerThreads(int worker_threads)
void UpdateBlockTreeDbInMemory(bool block_tree_db_in_memory)
void UpdateChainstateDbInMemory(bool chainstate_db_in_memory)
bool SetWipeDbs(bool wipe_block_tree, bool wipe_chainstate)
uint32_t GetConfirmationHeight() const
TransactionOutputView GetOutput() const
Coin(const CoinView &view)
CoinView(const btck_Coin *ptr)
Context(ContextOptions &opts)
void SetValidationInterface(std::shared_ptr< T > validation_interface)
void SetChainParams(ChainParams &chain_params)
void SetNotifications(std::shared_ptr< T > notifications)
Handle & operator=(const Handle &other)
Handle & operator=(Handle &&other) noexcept
Handle(const ViewType &view)
Handle(Handle &&other) noexcept
const CType * get() const
Handle(const Handle &other)
std::random_access_iterator_tag iterator_category
auto operator-(difference_type n) const
auto operator+(difference_type n) const
Iterator(const Collection *ptr)
auto & operator-=(difference_type n)
const Collection * m_collection
auto operator<=>(const Iterator &other) const
std::random_access_iterator_tag iterator_concept
friend Iterator operator+(difference_type n, const Iterator &it)
Iterator(const Collection *ptr, size_t idx)
auto & operator+=(difference_type n)
auto operator-(const Iterator &other) const
bool operator==(const Iterator &other) const
std::ptrdiff_t difference_type
ValueType operator[](difference_type n) const
virtual void FatalErrorHandler(std::string_view error)
virtual void WarningSetHandler(Warning warning, std::string_view message)
virtual void BlockTipHandler(SynchronizationState state, BlockTreeEntry entry, double verification_progress)
virtual ~KernelNotifications()=default
virtual void ProgressHandler(std::string_view title, int progress_percent, bool resume_possible)
virtual void WarningUnsetHandler(Warning warning)
virtual void FlushErrorHandler(std::string_view error)
virtual void HeaderTipHandler(SynchronizationState state, int64_t height, int64_t timestamp, bool presync)
Logger(std::unique_ptr< T > log)
OutPoint(const OutPointView &view)
OutPointView(const btck_TransactionOutPoint *ptr)
Iterator< Range, value_type > iterator
const Container * m_container
const_iterator cbegin() const
value_type operator[](size_t index) const
Range(const Container &container)
const_iterator cend() const
std::ptrdiff_t difference_type
value_type at(size_t index) const
std::invoke_result_t< decltype(GetFunc), const Container &, size_t > value_type
ScriptPubkeyApi()=default
bool Verify(int64_t amount, const Transaction &tx_to, std::span< const TransactionOutput > spent_outputs, unsigned int input_index, ScriptVerificationFlags flags, ScriptVerifyStatus &status) const
std::vector< std::byte > ToBytes() const
ScriptPubkey(std::span< const std::byte > raw)
ScriptPubkey(const ScriptPubkeyView &view)
ScriptPubkeyView(const btck_ScriptPubkey *ptr)
TransactionInputView GetInput(size_t index) const
TransactionOutputView GetOutput(size_t index) const
size_t CountInputs() const
std::vector< std::byte > ToBytes() const
size_t CountOutputs() const
Transaction(std::span< const std::byte > raw_transaction)
Transaction(const TransactionView &view)
TransactionOutputApi()=default
ScriptPubkeyView GetScriptPubkey() const
TransactionOutput(const TransactionOutputView &view)
TransactionOutput(const ScriptPubkey &script_pubkey, int64_t amount)
TransactionOutputView(const btck_TransactionOutput *ptr)
CoinView GetCoin(size_t index) const
TransactionSpentOutputsApi()=default
TransactionSpentOutputs(btck_TransactionSpentOutputs *transaction_spent_outputs)
TransactionSpentOutputs(const TransactionSpentOutputsView &view)
TransactionSpentOutputsView(const btck_TransactionSpentOutputs *ptr)
TransactionView(const btck_Transaction *ptr)
bool operator==(const TxidApi &other) const
std::array< std::byte, 32 > ToBytes() const
bool operator!=(const TxidApi &other) const
Txid(const TxidView &view)
TxidView(const btck_Txid *ptr)
const CType * get() const
std::unique_ptr< CType, Deleter > m_ptr
virtual void BlockChecked(Block block, const BlockValidationState state)
virtual void PowValidBlock(BlockTreeEntry entry, Block block)
virtual void BlockConnected(Block block, BlockTreeEntry entry)
virtual ~ValidationInterface()=default
virtual void BlockDisconnected(Block block, BlockTreeEntry entry)
const CType * get() const
#define T(expected, seed, data)
constexpr T & operator|=(T &lhs, T rhs)
constexpr T & operator&=(T &lhs, T rhs)
constexpr T operator~(T value)
std::vector< std::byte > write_bytes(const T *object, int(*to_bytes)(const T *, btck_WriteBytes, void *))
void logging_set_options(const btck_LoggingOptions &logging_options)
constexpr T operator&(T lhs, T rhs)
constexpr T operator|(T lhs, T rhs)
void logging_set_level_category(LogCategory category, LogLevel level)
@ ERROR_INVALID_FLAGS_COMBINATION
@ ERROR_SPENT_OUTPUTS_REQUIRED
@ UNKNOWN_NEW_RULES_ACTIVATED
@ LARGE_WORK_INVALID_CHAIN
void logging_enable_category(LogCategory category)
constexpr T operator^(T lhs, T rhs)
void logging_disable_category(LogCategory category)
constexpr T & operator^=(T &lhs, T rhs)
@ OK
The message verification was successful.
void operator()(CType *ptr) const noexcept
Options controlling the format of log messages.
A struct for holding the kernel notification callbacks.
void * user_data
Holds a user-defined opaque structure that is passed to the notification callbacks.
Holds the validation interface callbacks.
void * user_data
Holds a user-defined opaque structure that is passed to the validation interface callbacks.