Bitcoin Core 32.99.0
P2P Digital Currency
bitcoinkernel.h
Go to the documentation of this file.
1// Copyright (c) 2024-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_KERNEL_BITCOINKERNEL_H
6#define BITCOIN_KERNEL_BITCOINKERNEL_H
7
8#ifndef __cplusplus
9#include <stddef.h>
10#include <stdint.h>
11#else
12#include <cstddef>
13#include <cstdint>
14#endif // __cplusplus
15
16#ifndef BITCOINKERNEL_API
17 #ifdef BITCOINKERNEL_BUILD
18 #if defined(_WIN32)
19 #define BITCOINKERNEL_API __declspec(dllexport)
20 #else
21 #define BITCOINKERNEL_API __attribute__((visibility("default")))
22 #endif
23 #else
24 #if defined(_WIN32) && !defined(BITCOINKERNEL_STATIC)
25 #define BITCOINKERNEL_API __declspec(dllimport)
26 #else
27 #define BITCOINKERNEL_API
28 #endif
29 #endif
30#endif
31
41#if defined(__GNUC__)
42 #define BITCOINKERNEL_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
43#else
44 #define BITCOINKERNEL_WARN_UNUSED_RESULT
45#endif
46
57#if !defined(BITCOINKERNEL_BUILD) && defined(__GNUC__)
58 #define BITCOINKERNEL_ARG_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
59#else
60 #define BITCOINKERNEL_ARG_NONNULL(...)
61#endif
62
63#ifdef __cplusplus
64extern "C" {
65#endif // __cplusplus
66
135
140
145
155
164
176
192
205
214
225
229typedef struct btck_Block btck_Block;
230
238
243
248typedef struct btck_Chain btck_Chain;
249
257
270
279
286typedef struct btck_Coin btck_Coin;
287
294
301
308
315
325
331typedef struct btck_Txid btck_Txid;
332
338typedef struct btck_Wtxid btck_Wtxid;
339
344
347#define btck_SynchronizationState_INIT_REINDEX ((btck_SynchronizationState)(0))
348#define btck_SynchronizationState_INIT_DOWNLOAD ((btck_SynchronizationState)(1))
349#define btck_SynchronizationState_POST_INIT ((btck_SynchronizationState)(2))
350
352typedef uint8_t btck_Warning;
353#define btck_Warning_UNKNOWN_NEW_RULES_ACTIVATED ((btck_Warning)(0))
354#define btck_Warning_LARGE_WORK_INVALID_CHAIN ((btck_Warning)(1))
355
359typedef uint8_t btck_LogCategory;
360#define btck_LogCategory_NONE ((btck_LogCategory)(0))
361#define btck_LogCategory_BENCH ((btck_LogCategory)(1))
362#define btck_LogCategory_BLOCKSTORAGE ((btck_LogCategory)(2))
363#define btck_LogCategory_COINDB ((btck_LogCategory)(3))
364#define btck_LogCategory_LEVELDB ((btck_LogCategory)(4))
365#define btck_LogCategory_MEMPOOL ((btck_LogCategory)(5))
366#define btck_LogCategory_PRUNE ((btck_LogCategory)(6))
367#define btck_LogCategory_RAND ((btck_LogCategory)(7))
368#define btck_LogCategory_REINDEX ((btck_LogCategory)(8))
369#define btck_LogCategory_VALIDATION ((btck_LogCategory)(9))
370#define btck_LogCategory_KERNEL ((btck_LogCategory)(10))
371#define btck_LogCategory_TXPACKAGES ((btck_LogCategory)(11))
372#define btck_LogCategory_LOCK ((btck_LogCategory)(12))
373
377typedef uint8_t btck_LogLevel;
378#define btck_LogLevel_TRACE ((btck_LogLevel)(0))
379#define btck_LogLevel_DEBUG ((btck_LogLevel)(1))
380#define btck_LogLevel_INFO ((btck_LogLevel)(2))
381#define btck_LogLevel_WARNING ((btck_LogLevel)(3))
382#define btck_LogLevel_ERROR ((btck_LogLevel)(4))
383
390typedef struct {
393 const char* message;
397 const char* thread_name;
405 int64_t mocktime_s;
407 const char* file_name;
411 const char* function_name;
415 uint32_t line;
421
438typedef void (*btck_LogCallback)(void* user_data, const btck_LogEntry* entry);
439
443typedef void (*btck_DestroyCallback)(void* user_data);
444
448typedef void (*btck_NotifyBlockTip)(void* user_data, btck_SynchronizationState state, const btck_BlockTreeEntry* entry, double verification_progress);
449typedef void (*btck_NotifyHeaderTip)(void* user_data, btck_SynchronizationState state, int64_t height, int64_t timestamp, int presync);
450typedef void (*btck_NotifyProgress)(void* user_data, const char* title, size_t title_len, int progress_percent, int resume_possible);
451typedef void (*btck_NotifyWarningSet)(void* user_data, btck_Warning warning, const char* message, size_t message_len);
452typedef void (*btck_NotifyWarningUnset)(void* user_data, btck_Warning warning);
453typedef void (*btck_NotifyFlushError)(void* user_data, const char* message, size_t message_len);
454typedef void (*btck_NotifyFatalError)(void* user_data, const char* message, size_t message_len);
455
459typedef void (*btck_ValidationInterfaceBlockChecked)(void* user_data, btck_Block* block, const btck_BlockValidationState* state);
460typedef void (*btck_ValidationInterfacePoWValidBlock)(void* user_data, btck_Block* block, const btck_BlockTreeEntry* entry);
461typedef void (*btck_ValidationInterfaceBlockConnected)(void* user_data, btck_Block* block, const btck_BlockTreeEntry* entry);
462typedef void (*btck_ValidationInterfaceBlockDisconnected)(void* user_data, btck_Block* block, const btck_BlockTreeEntry* entry);
463
473typedef int (*btck_WriteBytes)(const void* bytes, size_t size, void* userdata);
474
479typedef uint8_t btck_ValidationMode;
480#define btck_ValidationMode_VALID ((btck_ValidationMode)(0))
481#define btck_ValidationMode_INVALID ((btck_ValidationMode)(1))
482#define btck_ValidationMode_INTERNAL_ERROR ((btck_ValidationMode)(2))
483
488#define btck_BlockValidationResult_UNSET ((btck_BlockValidationResult)(0))
489#define btck_BlockValidationResult_CONSENSUS ((btck_BlockValidationResult)(1))
490#define btck_BlockValidationResult_CACHED_INVALID ((btck_BlockValidationResult)(2))
491#define btck_BlockValidationResult_INVALID_HEADER ((btck_BlockValidationResult)(3))
492#define btck_BlockValidationResult_MUTATED ((btck_BlockValidationResult)(4))
493#define btck_BlockValidationResult_MISSING_PREV ((btck_BlockValidationResult)(5))
494#define btck_BlockValidationResult_INVALID_PREV ((btck_BlockValidationResult)(6))
495#define btck_BlockValidationResult_TIME_FUTURE ((btck_BlockValidationResult)(7))
496#define btck_BlockValidationResult_HEADER_LOW_WORK ((btck_BlockValidationResult)(8))
497
502typedef uint32_t btck_TxValidationResult;
503#define btck_TxValidationResult_UNSET ((btck_TxValidationResult)(0))
504#define btck_TxValidationResult_CONSENSUS ((btck_TxValidationResult)(1))
505#define btck_TxValidationResult_INPUTS_NOT_STANDARD ((btck_TxValidationResult)(2))
506#define btck_TxValidationResult_NOT_STANDARD ((btck_TxValidationResult)(3))
507#define btck_TxValidationResult_MISSING_INPUTS ((btck_TxValidationResult)(4))
508#define btck_TxValidationResult_PREMATURE_SPEND ((btck_TxValidationResult)(5))
509#define btck_TxValidationResult_WITNESS_MUTATED ((btck_TxValidationResult)(6))
510#define btck_TxValidationResult_WITNESS_STRIPPED ((btck_TxValidationResult)(7))
511#define btck_TxValidationResult_CONFLICT ((btck_TxValidationResult)(8))
512#define btck_TxValidationResult_MEMPOOL_POLICY ((btck_TxValidationResult)(9))
513#define btck_TxValidationResult_NO_MEMPOOL ((btck_TxValidationResult)(10))
514#define btck_TxValidationResult_RECONSIDERABLE ((btck_TxValidationResult)(11))
515#define btck_TxValidationResult_UNKNOWN ((btck_TxValidationResult)(12))
516
523typedef struct {
524 void* user_data;
535
548typedef struct {
549 void* user_data;
561
566#define btck_ScriptVerifyStatus_OK ((btck_ScriptVerifyStatus)(0))
567#define btck_ScriptVerifyStatus_ERROR_INVALID_FLAGS_COMBINATION ((btck_ScriptVerifyStatus)(1))
568#define btck_ScriptVerifyStatus_ERROR_SPENT_OUTPUTS_REQUIRED ((btck_ScriptVerifyStatus)(2))
569
574#define btck_ScriptVerificationFlags_NONE ((btck_ScriptVerificationFlags)(0))
575#define btck_ScriptVerificationFlags_P2SH ((btck_ScriptVerificationFlags)(1U << 0))
576#define btck_ScriptVerificationFlags_DERSIG ((btck_ScriptVerificationFlags)(1U << 2))
577#define btck_ScriptVerificationFlags_NULLDUMMY ((btck_ScriptVerificationFlags)(1U << 4))
578#define btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY ((btck_ScriptVerificationFlags)(1U << 9))
579#define btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY ((btck_ScriptVerificationFlags)(1U << 10))
580#define btck_ScriptVerificationFlags_WITNESS ((btck_ScriptVerificationFlags)(1U << 11))
581#define btck_ScriptVerificationFlags_TAPROOT ((btck_ScriptVerificationFlags)(1U << 17))
582#define btck_ScriptVerificationFlags_ALL ((btck_ScriptVerificationFlags)(btck_ScriptVerificationFlags_P2SH | \
583 btck_ScriptVerificationFlags_DERSIG | \
584 btck_ScriptVerificationFlags_NULLDUMMY | \
585 btck_ScriptVerificationFlags_CHECKLOCKTIMEVERIFY | \
586 btck_ScriptVerificationFlags_CHECKSEQUENCEVERIFY | \
587 btck_ScriptVerificationFlags_WITNESS | \
588 btck_ScriptVerificationFlags_TAPROOT))
589
590typedef uint8_t btck_ChainType;
591#define btck_ChainType_MAINNET ((btck_ChainType)(0))
592#define btck_ChainType_TESTNET ((btck_ChainType)(1))
593#define btck_ChainType_TESTNET_4 ((btck_ChainType)(2))
594#define btck_ChainType_SIGNET ((btck_ChainType)(3))
595#define btck_ChainType_REGTEST ((btck_ChainType)(4))
596
601
606
612
623
628
630
635
644 const void* raw_transaction, size_t raw_transaction_len);
645
654 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
655
667 const btck_Transaction* transaction,
668 btck_WriteBytes writer,
669 void* user_data) BITCOINKERNEL_ARG_NONNULL(1, 2);
670
678 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
679
690 const btck_Transaction* transaction, size_t output_index) BITCOINKERNEL_ARG_NONNULL(1);
691
702 const btck_Transaction* transaction, size_t input_index) BITCOINKERNEL_ARG_NONNULL(1);
703
711 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
712
720 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
721
729 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
730
739 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
740
748 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
749
758 const btck_Transaction* transaction) BITCOINKERNEL_ARG_NONNULL(1);
759
777 const btck_Transaction* tx,
778 btck_TxValidationState* validation_state) BITCOINKERNEL_ARG_NONNULL(1, 2);
779
784
786
791
802 const btck_Transaction* tx_to,
803 const btck_TransactionOutput** spent_outputs, size_t spent_outputs_len) BITCOINKERNEL_ARG_NONNULL(1);
804
813
818
820
825
833 const void* script_pubkey, size_t script_pubkey_len);
834
842 const btck_ScriptPubkey* script_pubkey) BITCOINKERNEL_ARG_NONNULL(1);
843
863 const btck_ScriptPubkey* script_pubkey,
864 int64_t amount,
865 const btck_Transaction* tx_to,
866 const btck_PrecomputedTransactionData* precomputed_txdata,
867 unsigned int input_index,
870
881 const btck_ScriptPubkey* script_pubkey,
882 btck_WriteBytes writer,
883 void* user_data) BITCOINKERNEL_ARG_NONNULL(1, 2);
884
889
891
896
905 const btck_ScriptPubkey* script_pubkey,
906 int64_t amount) BITCOINKERNEL_ARG_NONNULL(1);
907
917 const btck_TransactionOutput* transaction_output) BITCOINKERNEL_ARG_NONNULL(1);
918
926 const btck_TransactionOutput* transaction_output) BITCOINKERNEL_ARG_NONNULL(1);
927
935 const btck_TransactionOutput* transaction_output) BITCOINKERNEL_ARG_NONNULL(1);
936
941
943
948
959
975 btck_LogCallback log_callback,
976 void* user_data,
977 btck_DestroyCallback user_data_destroy_callback) BITCOINKERNEL_ARG_NONNULL(1);
978
983
985
990
999 btck_ChainType chain_type);
1000
1011 const void* challenge, size_t challenge_len);
1012
1017 const btck_ChainParameters* chain_parameters) BITCOINKERNEL_ARG_NONNULL(1);
1018
1028 const btck_ChainParameters* chain_parameters) BITCOINKERNEL_ARG_NONNULL(1);
1029
1034
1036
1041
1046
1055 btck_ContextOptions* context_options,
1056 const btck_ChainParameters* chain_parameters) BITCOINKERNEL_ARG_NONNULL(1, 2);
1057
1066 btck_ContextOptions* context_options,
1068
1080 btck_ContextOptions* context_options,
1081 btck_ValidationInterfaceCallbacks validation_interface_callbacks) BITCOINKERNEL_ARG_NONNULL(1);
1082
1087
1089
1094
1105 const btck_ContextOptions* context_options);
1106
1112
1122
1127
1129
1134
1143 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1);
1144
1152 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1);
1153
1161 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1);
1162
1170 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1);
1171
1181 const btck_BlockTreeEntry* entry1, const btck_BlockTreeEntry* entry2) BITCOINKERNEL_ARG_NONNULL(1, 2);
1182
1191 const btck_BlockTreeEntry* block_tree_entry,
1192 int32_t height) BITCOINKERNEL_ARG_NONNULL(1);
1193
1195
1200
1213 const btck_Context* context,
1214 const char* data_directory,
1215 size_t data_directory_len,
1216 const char* blocks_directory,
1217 size_t blocks_directory_len) BITCOINKERNEL_ARG_NONNULL(1);
1218
1228 btck_ChainstateManagerOptions* chainstate_manager_options,
1229 int worker_threads) BITCOINKERNEL_ARG_NONNULL(1);
1230
1244 btck_ChainstateManagerOptions* chainstate_manager_options,
1245 uint64_t database_cache_bytes) BITCOINKERNEL_ARG_NONNULL(1);
1246
1260 btck_ChainstateManagerOptions* chainstate_manager_options,
1261 int wipe_block_tree_db,
1262 int wipe_chainstate_db) BITCOINKERNEL_ARG_NONNULL(1);
1263
1271 btck_ChainstateManagerOptions* chainstate_manager_options,
1272 int block_tree_db_in_memory) BITCOINKERNEL_ARG_NONNULL(1);
1273
1281 btck_ChainstateManagerOptions* chainstate_manager_options,
1282 int chainstate_db_in_memory) BITCOINKERNEL_ARG_NONNULL(1);
1283
1288
1290
1295
1305 const btck_ChainstateManagerOptions* chainstate_manager_options) BITCOINKERNEL_ARG_NONNULL(1);
1306
1315 const btck_ChainstateManager* chainstate_manager) BITCOINKERNEL_ARG_NONNULL(1);
1316
1325 btck_ChainstateManager* chainstate_manager,
1326 const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1, 2);
1327
1340 btck_ChainstateManager* chainstate_manager,
1341 const char** block_file_paths_data, size_t* block_file_paths_lens,
1342 size_t block_file_paths_data_len) BITCOINKERNEL_ARG_NONNULL(1);
1343
1362 btck_ChainstateManager* chainstate_manager,
1363 const btck_Block* block,
1364 int* new_block) BITCOINKERNEL_ARG_NONNULL(1, 2, 3);
1365
1381 const btck_ChainstateManager* chainstate_manager) BITCOINKERNEL_ARG_NONNULL(1);
1382
1392 const btck_ChainstateManager* chainstate_manager,
1393 const btck_BlockHash* block_hash) BITCOINKERNEL_ARG_NONNULL(1, 2);
1394
1399
1401
1406
1416 const btck_ChainstateManager* chainstate_manager,
1417 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1, 2);
1418
1427 const void* raw_block, size_t raw_block_len);
1428
1437 const btck_Block* block) BITCOINKERNEL_ARG_NONNULL(1);
1438
1440typedef uint32_t btck_BlockCheckFlags;
1441#define btck_BlockCheckFlags_BASE ((btck_BlockCheckFlags)0)
1442#define btck_BlockCheckFlags_POW ((btck_BlockCheckFlags)(1U << 0))
1443#define btck_BlockCheckFlags_MERKLE ((btck_BlockCheckFlags)(1U << 1))
1444#define btck_BlockCheckFlags_ALL ((btck_BlockCheckFlags)(btck_BlockCheckFlags_POW | btck_BlockCheckFlags_MERKLE))
1445
1469 const btck_Block* block,
1470 const btck_ConsensusParams* consensus_params,
1472 btck_BlockValidationState* validation_state) BITCOINKERNEL_ARG_NONNULL(1, 2, 4);
1473
1481 const btck_Block* block) BITCOINKERNEL_ARG_NONNULL(1);
1482
1492 const btck_Block* block, size_t transaction_index) BITCOINKERNEL_ARG_NONNULL(1);
1493
1503 const btck_Block* block) BITCOINKERNEL_ARG_NONNULL(1);
1504
1512 const btck_Block* block) BITCOINKERNEL_ARG_NONNULL(1);
1513
1525 const btck_Block* block,
1526 btck_WriteBytes writer,
1527 void* user_data) BITCOINKERNEL_ARG_NONNULL(1, 2);
1528
1533
1535
1540
1545
1550 const btck_BlockValidationState* block_validation_state) BITCOINKERNEL_ARG_NONNULL(1);
1551
1556 const btck_BlockValidationState* block_validation_state) BITCOINKERNEL_ARG_NONNULL(1);
1557
1565 const btck_BlockValidationState* block_validation_state) BITCOINKERNEL_ARG_NONNULL(1);
1566
1571 btck_BlockValidationState* block_validation_state);
1572
1574
1579
1587 const btck_Chain* chain) BITCOINKERNEL_ARG_NONNULL(1);
1588
1599 const btck_Chain* chain,
1600 int32_t block_height) BITCOINKERNEL_ARG_NONNULL(1);
1601
1611 const btck_Chain* chain,
1612 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1, 2);
1613
1615
1620
1630 const btck_ChainstateManager* chainstate_manager,
1631 const btck_BlockTreeEntry* block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1, 2);
1632
1640 const btck_BlockSpentOutputs* block_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1);
1641
1650 const btck_BlockSpentOutputs* block_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1);
1651
1662 const btck_BlockSpentOutputs* block_spent_outputs,
1663 size_t transaction_spent_outputs_index) BITCOINKERNEL_ARG_NONNULL(1);
1664
1669
1671
1676
1684 const btck_TransactionSpentOutputs* transaction_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1);
1685
1694 const btck_TransactionSpentOutputs* transaction_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1);
1695
1707 const btck_TransactionSpentOutputs* transaction_spent_outputs,
1708 size_t coin_index) BITCOINKERNEL_ARG_NONNULL(1);
1709
1714
1716
1721
1729 const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1);
1730
1739 const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1);
1740
1748 const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1);
1749
1758 const btck_TransactionInput* transaction_input) BITCOINKERNEL_ARG_NONNULL(1);
1759
1770 const btck_TransactionInput* transaction_input,
1771 btck_WriteBytes writer,
1772 void* user_data) BITCOINKERNEL_ARG_NONNULL(1, 2);
1773
1778
1780
1785
1793 const btck_WitnessStack* witness_stack) BITCOINKERNEL_ARG_NONNULL(1);
1794
1807 const btck_WitnessStack* witness_stack,
1808 size_t index,
1809 btck_WriteBytes writer,
1810 void* user_data) BITCOINKERNEL_ARG_NONNULL(1, 3);
1811
1819 const btck_WitnessStack* witness_stack) BITCOINKERNEL_ARG_NONNULL(1);
1820
1825
1827
1832
1840 const btck_TransactionOutPoint* transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1);
1841
1849 const btck_TransactionOutPoint* transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1);
1850
1859 const btck_TransactionOutPoint* transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1);
1860
1865
1867
1872
1880 const btck_Txid* txid) BITCOINKERNEL_ARG_NONNULL(1);
1881
1890 const btck_Txid* txid1, const btck_Txid* txid2) BITCOINKERNEL_ARG_NONNULL(1, 2);
1891
1899 const btck_Txid* txid, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1, 2);
1900
1905
1907
1912
1920 const btck_Wtxid* wtxid) BITCOINKERNEL_ARG_NONNULL(1);
1921
1930 const btck_Wtxid* wtxid1, const btck_Wtxid* wtxid2) BITCOINKERNEL_ARG_NONNULL(1, 2);
1931
1939 const btck_Wtxid* wtxid, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1, 2);
1940
1945
1947
1952
1960 const btck_Coin* coin) BITCOINKERNEL_ARG_NONNULL(1);
1961
1970 const btck_Coin* coin) BITCOINKERNEL_ARG_NONNULL(1);
1971
1979 const btck_Coin* coin) BITCOINKERNEL_ARG_NONNULL(1);
1980
1989 const btck_Coin* coin) BITCOINKERNEL_ARG_NONNULL(1);
1990
1995
1997
2002
2007 const unsigned char block_hash[32]) BITCOINKERNEL_ARG_NONNULL(1);
2008
2017 const btck_BlockHash* hash1, const btck_BlockHash* hash2) BITCOINKERNEL_ARG_NONNULL(1, 2);
2018
2026 const btck_BlockHash* block_hash) BITCOINKERNEL_ARG_NONNULL(1);
2027
2035 const btck_BlockHash* block_hash, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1, 2);
2036
2041
2043
2049
2058 const void* raw_block_header, size_t raw_block_header_len) BITCOINKERNEL_ARG_NONNULL(1);
2059
2068
2077
2087
2095 const btck_BlockHeader* header, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1, 2);
2096
2105
2114
2123
2132
2142 const btck_BlockHeader* header, unsigned char output[80]) BITCOINKERNEL_ARG_NONNULL(1, 2);
2143
2148
2150
2155
2170
2172
2173#ifdef __cplusplus
2174} // extern "C"
2175#endif // __cplusplus
2176
2177#endif // BITCOIN_KERNEL_BITCOINKERNEL_H
int flags
Definition: bitcoin-tx.cpp:531
#define BITCOINKERNEL_API
Definition: bitcoinkernel.h:27
BITCOINKERNEL_API btck_TransactionInput *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_copy(const btck_TransactionInput *transaction_input) BITCOINKERNEL_ARG_NONNULL(1)
Copy a transaction input.
BITCOINKERNEL_API const btck_Txid * btck_transaction_out_point_get_txid(const btck_TransactionOutPoint *transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1)
Get the txid from the transaction out point.
BITCOINKERNEL_API uint32_t btck_transaction_out_point_get_index(const btck_TransactionOutPoint *transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1)
Get the output position from the transaction out point.
BITCOINKERNEL_API int btck_block_check(const btck_Block *block, const btck_ConsensusParams *consensus_params, btck_BlockCheckFlags flags, btck_BlockValidationState *validation_state) BITCOINKERNEL_ARG_NONNULL(1
Perform context-free validation checks on a btck_Block.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API void btck_block_header_destroy(btck_BlockHeader *header)
Destroy the btck_BlockHeader.
BITCOINKERNEL_API const btck_Transaction * btck_block_get_transaction_at(const btck_Block *block, size_t transaction_index) BITCOINKERNEL_ARG_NONNULL(1)
Get the transaction at the provided index.
uint8_t btck_LogLevel
The severity of a log statement.
BITCOINKERNEL_API int BITCOINKERNEL_API btck_BlockHash *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_hash_copy(const btck_BlockHash *block_hash) BITCOINKERNEL_ARG_NONNULL(1)
Copy a block hash.
BITCOINKERNEL_API btck_TransactionOutput *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_output_copy(const btck_TransactionOutput *transaction_output) BITCOINKERNEL_ARG_NONNULL(1)
Copy a transaction output.
BITCOINKERNEL_API const btck_TransactionOutput * btck_coin_get_output(const btck_Coin *coin) BITCOINKERNEL_ARG_NONNULL(1)
Return the transaction output of a coin.
BITCOINKERNEL_API void btck_logging_connection_destroy(btck_LoggingConnection *logging_connection)
Stop logging and destroy the logging connection.
BITCOINKERNEL_API btck_BlockHeader *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_header_copy(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Copy a btck_BlockHeader.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_header_to_bytes(const btck_BlockHeader *header, unsigned char output[80]) BITCOINKERNEL_ARG_NONNULL(1
Serializes the btck_BlockHeader to bytes.
BITCOINKERNEL_API btck_BlockValidationState *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_validation_state_create()
Create a new btck_BlockValidationState.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_set_mock_time(int64_t timestamp)
Override the current time with a fixed timestamp for testing.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API btck_WitnessStack *BITCOINKERNEL_WARN_UNUSED_RESULT btck_witness_stack_copy(const btck_WitnessStack *witness_stack) BITCOINKERNEL_ARG_NONNULL(1)
Copy a witness stack.
int(* btck_WriteBytes)(const void *bytes, size_t size, void *userdata)
Function signature for serializing data.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_options_set_database_cache_bytes(btck_ChainstateManagerOptions *chainstate_manager_options, uint64_t database_cache_bytes) BITCOINKERNEL_ARG_NONNULL(1)
Set the total database cache used by the chainstate manager.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_context_interrupt(btck_Context *context) BITCOINKERNEL_ARG_NONNULL(1)
Interrupt can be used to halt long-running validation functions like when reindexing,...
BITCOINKERNEL_API int btck_block_hash_equals(const btck_BlockHash *hash1, const btck_BlockHash *hash2) BITCOINKERNEL_ARG_NONNULL(1
Check if two block hashes are equal.
#define BITCOINKERNEL_WARN_UNUSED_RESULT
BITCOINKERNEL_WARN_UNUSED_RESULT is a compiler attribute used to indicate that ignoring a function's ...
Definition: bitcoinkernel.h:44
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_to_bytes(const btck_Transaction *transaction, btck_WriteBytes writer, void *user_data) BITCOINKERNEL_ARG_NONNULL(1
Serializes the transaction through the passed in callback to bytes.
uint32_t btck_TxValidationResult
Indicates the reason why a transaction failed validation.
BITCOINKERNEL_API const btck_TransactionSpentOutputs * btck_block_spent_outputs_get_transaction_spent_outputs_at(const btck_BlockSpentOutputs *block_spent_outputs, size_t transaction_spent_outputs_index) BITCOINKERNEL_ARG_NONNULL(1)
Returns a transaction spent outputs contained in the block spent outputs at a certain index.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_to_bytes(const btck_Block *block, btck_WriteBytes writer, void *user_data) BITCOINKERNEL_ARG_NONNULL(1
Serializes the block through the passed in callback to bytes.
BITCOINKERNEL_API btck_BlockHeader *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_header_create(const void *raw_block_header, size_t raw_block_header_len) BITCOINKERNEL_ARG_NONNULL(1)
Create a btck_BlockHeader from serialized data.
BITCOINKERNEL_API int btck_txid_equals(const btck_Txid *txid1, const btck_Txid *txid2) BITCOINKERNEL_ARG_NONNULL(1
Check if two txids are equal.
uint8_t btck_ChainType
BITCOINKERNEL_API uint32_t btck_coin_confirmation_height(const btck_Coin *coin) BITCOINKERNEL_ARG_NONNULL(1)
Returns the block height where the transaction that created this coin was included in.
BITCOINKERNEL_API const btck_Wtxid * btck_transaction_get_wtxid(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Get the wtxid of a transaction.
BITCOINKERNEL_API const btck_ConsensusParams * btck_chain_parameters_get_consensus_params(const btck_ChainParameters *chain_parameters) BITCOINKERNEL_ARG_NONNULL(1)
Get btck_ConsensusParams from btck_ChainParameters.
BITCOINKERNEL_API int BITCOINKERNEL_API const btck_BlockTreeEntry * btck_block_tree_entry_get_ancestor(const btck_BlockTreeEntry *block_tree_entry, int32_t height) BITCOINKERNEL_ARG_NONNULL(1)
Return the ancestor of a btck_BlockTreeEntry at the given height.
void(* btck_ValidationInterfaceBlockChecked)(void *user_data, btck_Block *block, const btck_BlockValidationState *state)
Function signatures for the validation interface.
BITCOINKERNEL_API btck_ChainParameters *BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_parameters_create(btck_ChainType chain_type)
Creates a chain parameters struct with default parameters based on the passed in chain type.
BITCOINKERNEL_API const btck_Txid * btck_transaction_get_txid(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Get the txid of a transaction.
BITCOINKERNEL_API btck_Context *BITCOINKERNEL_WARN_UNUSED_RESULT btck_context_create(const btck_ContextOptions *context_options)
Create a new kernel context.
BITCOINKERNEL_API btck_BlockSpentOutputs *BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API btck_BlockSpentOutputs *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_spent_outputs_copy(const btck_BlockSpentOutputs *block_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1)
Copy a block's spent outputs.
uint32_t btck_BlockValidationResult
A granular "reason" why a block was invalid.
BITCOINKERNEL_API const btck_Coin * btck_transaction_spent_outputs_get_coin_at(const btck_TransactionSpentOutputs *transaction_spent_outputs, size_t coin_index) BITCOINKERNEL_ARG_NONNULL(1)
Returns a coin contained in the transaction spent outputs at a certain index.
BITCOINKERNEL_API int BITCOINKERNEL_API void BITCOINKERNEL_API void btck_txid_destroy(btck_Txid *txid)
Destroy the txid.
BITCOINKERNEL_API const btck_TransactionOutput * btck_transaction_get_output_at(const btck_Transaction *transaction, size_t output_index) BITCOINKERNEL_ARG_NONNULL(1)
Get the transaction outputs at the provided index.
BITCOINKERNEL_API const btck_TransactionInput * btck_transaction_get_input_at(const btck_Transaction *transaction, size_t input_index) BITCOINKERNEL_ARG_NONNULL(1)
Get the transaction input at the provided index.
uint8_t btck_ValidationMode
Whether a validated data structure is valid, invalid, or an error was encountered during processing.
BITCOINKERNEL_API void btck_witness_stack_destroy(btck_WitnessStack *witness_stack)
Destroy the witness stack.
BITCOINKERNEL_API btck_Block *BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API btck_Block *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_create(const void *raw_block, size_t raw_block_len)
Parse a serialized raw block into a new block object.
BITCOINKERNEL_API const btck_BlockTreeEntry * btck_chainstate_manager_get_best_entry(const btck_ChainstateManager *chainstate_manager) BITCOINKERNEL_ARG_NONNULL(1)
Get the btck_BlockTreeEntry whose associated btck_BlockHeader has the most known cumulative proof of ...
void(* btck_LogCallback)(void *user_data, const btck_LogEntry *entry)
Callback function types.
void(* btck_ValidationInterfacePoWValidBlock)(void *user_data, btck_Block *block, const btck_BlockTreeEntry *entry)
BITCOINKERNEL_API btck_BlockValidationResult btck_block_validation_state_get_block_validation_result(const btck_BlockValidationState *block_validation_state) BITCOINKERNEL_ARG_NONNULL(1)
Returns the validation result from an opaque btck_BlockValidationState pointer.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API const btck_Chain * btck_chainstate_manager_get_active_chain(const btck_ChainstateManager *chainstate_manager) BITCOINKERNEL_ARG_NONNULL(1)
Returns the best known currently active chain.
BITCOINKERNEL_API uint32_t btck_transaction_get_version(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Get a transaction's version.
BITCOINKERNEL_API const btck_BlockHash * btck_block_header_get_prev_hash(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Get the previous btck_BlockHash from btck_BlockHeader.
uint8_t btck_SynchronizationState
Current sync state passed to tip changed callbacks.
BITCOINKERNEL_API void btck_context_options_destroy(btck_ContextOptions *context_options)
Destroy the context options.
void(* btck_NotifyProgress)(void *user_data, const char *title, size_t title_len, int progress_percent, int resume_possible)
void(* btck_NotifyWarningUnset)(void *user_data, btck_Warning warning)
BITCOINKERNEL_API btck_Block *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_copy(const btck_Block *block) BITCOINKERNEL_ARG_NONNULL(1)
Copy a block.
void(* btck_ValidationInterfaceBlockDisconnected)(void *user_data, btck_Block *block, const btck_BlockTreeEntry *entry)
BITCOINKERNEL_API const btck_BlockTreeEntry * btck_chainstate_manager_get_block_tree_entry_by_hash(const btck_ChainstateManager *chainstate_manager, const btck_BlockHash *block_hash) BITCOINKERNEL_ARG_NONNULL(1
Retrieve a block tree entry by its block hash.
BITCOINKERNEL_API const btck_TransactionOutPoint * btck_transaction_input_get_out_point(const btck_TransactionInput *transaction_input) BITCOINKERNEL_ARG_NONNULL(1)
Get the transaction out point.
BITCOINKERNEL_API void btck_chainstate_manager_options_update_chainstate_db_in_memory(btck_ChainstateManagerOptions *chainstate_manager_options, int chainstate_db_in_memory) BITCOINKERNEL_ARG_NONNULL(1)
Sets chainstate db in memory in the options.
BITCOINKERNEL_API void btck_chainstate_manager_options_destroy(btck_ChainstateManagerOptions *chainstate_manager_options)
Destroy the chainstate manager options.
BITCOINKERNEL_API btck_BlockHash *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_header_get_hash(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Get the btck_BlockHash.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_options_set_wipe_dbs(btck_ChainstateManagerOptions *chainstate_manager_options, int wipe_block_tree_db, int wipe_chainstate_db) BITCOINKERNEL_ARG_NONNULL(1)
Sets wipe db in the options.
BITCOINKERNEL_API btck_Wtxid *BITCOINKERNEL_WARN_UNUSED_RESULT btck_wtxid_copy(const btck_Wtxid *wtxid) BITCOINKERNEL_ARG_NONNULL(1)
Copy a wtxid.
BITCOINKERNEL_API btck_ContextOptions *BITCOINKERNEL_WARN_UNUSED_RESULT btck_context_options_create()
Creates an empty context options.
#define BITCOINKERNEL_ARG_NONNULL(...)
BITCOINKERNEL_ARG_NONNULL is a compiler attribute used to indicate that certain pointer arguments to ...
Definition: bitcoinkernel.h:60
void(* btck_DestroyCallback)(void *user_data)
Function signature for freeing user data.
BITCOINKERNEL_API void btck_precomputed_transaction_data_destroy(btck_PrecomputedTransactionData *precomputed_txdata)
Destroy the precomputed transaction data.
BITCOINKERNEL_API int btck_coin_is_coinbase(const btck_Coin *coin) BITCOINKERNEL_ARG_NONNULL(1)
Returns whether the containing transaction was a coinbase.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API void btck_transaction_input_destroy(btck_TransactionInput *transaction_input)
Destroy the transaction input.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_witness_stack_get_item_at(const btck_WitnessStack *witness_stack, size_t index, btck_WriteBytes writer, void *user_data) BITCOINKERNEL_ARG_NONNULL(1
Serialize a witness stack item at a given index through the passed in callback.
uint32_t btck_ScriptVerificationFlags
Script verification flags that may be composed with each other.
BITCOINKERNEL_API btck_TransactionSpentOutputs *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_spent_outputs_copy(const btck_TransactionSpentOutputs *transaction_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1)
Copy a transaction's spent outputs.
BITCOINKERNEL_API uint32_t btck_transaction_get_locktime(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Get a transaction's nLockTime value.
BITCOINKERNEL_API btck_Context *BITCOINKERNEL_WARN_UNUSED_RESULT btck_context_copy(const btck_Context *context) BITCOINKERNEL_ARG_NONNULL(1)
Copy the context.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_process_block(btck_ChainstateManager *chainstate_manager, const btck_Block *block, int *new_block) BITCOINKERNEL_ARG_NONNULL(1
Process and validate the passed in block with the chainstate manager.
BITCOINKERNEL_API int64_t btck_transaction_output_get_amount(const btck_TransactionOutput *transaction_output) BITCOINKERNEL_ARG_NONNULL(1)
Get the amount in the output.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_script_pubkey_verify(const btck_ScriptPubkey *script_pubkey, int64_t amount, const btck_Transaction *tx_to, const btck_PrecomputedTransactionData *precomputed_txdata, unsigned int input_index, btck_ScriptVerificationFlags flags, btck_ScriptVerifyStatus *status) BITCOINKERNEL_ARG_NONNULL(1
Verify if the input at input_index of tx_to spends the script pubkey under the constraints specified ...
BITCOINKERNEL_API btck_PrecomputedTransactionData *BITCOINKERNEL_WARN_UNUSED_RESULT btck_precomputed_transaction_data_create(const btck_Transaction *tx_to, const btck_TransactionOutput **spent_outputs, size_t spent_outputs_len) BITCOINKERNEL_ARG_NONNULL(1)
Create precomputed transaction data for script verification.
BITCOINKERNEL_API btck_Transaction *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_create(const void *raw_transaction, size_t raw_transaction_len)
Create a new transaction from the serialized data.
BITCOINKERNEL_API void btck_chainstate_manager_options_set_worker_threads_num(btck_ChainstateManagerOptions *chainstate_manager_options, int worker_threads) BITCOINKERNEL_ARG_NONNULL(1)
Set the number of available worker threads used during validation.
BITCOINKERNEL_API btck_Txid *BITCOINKERNEL_WARN_UNUSED_RESULT btck_txid_copy(const btck_Txid *txid) BITCOINKERNEL_ARG_NONNULL(1)
Copy a txid.
BITCOINKERNEL_API const btck_BlockTreeEntry BITCOINKERNEL_API void btck_chainstate_manager_destroy(btck_ChainstateManager *chainstate_manager)
Destroy the chainstate manager.
BITCOINKERNEL_API btck_ScriptPubkey *BITCOINKERNEL_WARN_UNUSED_RESULT btck_script_pubkey_create(const void *script_pubkey, size_t script_pubkey_len)
Create a script pubkey from serialized data.
BITCOINKERNEL_API int BITCOINKERNEL_API size_t btck_block_count_transactions(const btck_Block *block) BITCOINKERNEL_ARG_NONNULL(1)
Count the number of transactions contained in a block.
BITCOINKERNEL_API int32_t btck_chain_get_height(const btck_Chain *chain) BITCOINKERNEL_ARG_NONNULL(1)
Return the height of the tip of the chain.
BITCOINKERNEL_API btck_Coin *BITCOINKERNEL_WARN_UNUSED_RESULT btck_coin_copy(const btck_Coin *coin) BITCOINKERNEL_ARG_NONNULL(1)
Copy a coin.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_script_pubkey_to_bytes(const btck_ScriptPubkey *script_pubkey, btck_WriteBytes writer, void *user_data) BITCOINKERNEL_ARG_NONNULL(1
Serializes the script pubkey through the passed in callback to bytes.
BITCOINKERNEL_API void btck_block_validation_state_destroy(btck_BlockValidationState *block_validation_state)
Destroy the btck_BlockValidationState.
BITCOINKERNEL_API int BITCOINKERNEL_API void BITCOINKERNEL_API void btck_wtxid_destroy(btck_Wtxid *wtxid)
Destroy the wtxid.
BITCOINKERNEL_API btck_ChainstateManager *BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_create(const btck_ChainstateManagerOptions *chainstate_manager_options) BITCOINKERNEL_ARG_NONNULL(1)
Create a chainstate manager.
BITCOINKERNEL_API uint32_t btck_transaction_input_get_sequence(const btck_TransactionInput *transaction_input) BITCOINKERNEL_ARG_NONNULL(1)
Get a transaction input's nSequence value.
BITCOINKERNEL_API btck_PrecomputedTransactionData *BITCOINKERNEL_WARN_UNUSED_RESULT btck_precomputed_transaction_data_copy(const btck_PrecomputedTransactionData *precomputed_txdata) BITCOINKERNEL_ARG_NONNULL(1)
Copy precomputed transaction data.
BITCOINKERNEL_API void btck_transaction_output_destroy(btck_TransactionOutput *transaction_output)
Destroy the transaction output.
BITCOINKERNEL_API btck_TxValidationState *BITCOINKERNEL_WARN_UNUSED_RESULT btck_tx_validation_state_create()
Create a new btck_TxValidationState.
BITCOINKERNEL_API int btck_chain_contains(const btck_Chain *chain, const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1
Return true if the passed in chain contains the block tree entry.
BITCOINKERNEL_API btck_TransactionOutput *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_output_create(const btck_ScriptPubkey *script_pubkey, int64_t amount) BITCOINKERNEL_ARG_NONNULL(1)
Create a transaction output from a script pubkey and an amount.
BITCOINKERNEL_API uint32_t btck_block_header_get_nonce(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Get the nonce from btck_BlockHeader.
BITCOINKERNEL_API btck_BlockHeader *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_get_header(const btck_Block *block) BITCOINKERNEL_ARG_NONNULL(1)
Get the btck_BlockHeader from the block.
BITCOINKERNEL_API const btck_BlockHash * btck_block_tree_entry_get_block_hash(const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1)
Return the block hash associated with a block tree entry.
BITCOINKERNEL_API btck_BlockSpentOutputs *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_spent_outputs_read(const btck_ChainstateManager *chainstate_manager, const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1
Reads the block spent coins data the passed in block tree entry points to from disk and returns it.
BITCOINKERNEL_API const btck_ScriptPubkey * btck_transaction_output_get_script_pubkey(const btck_TransactionOutput *transaction_output) BITCOINKERNEL_ARG_NONNULL(1)
Get the script pubkey of the output.
uint8_t btck_ScriptVerifyStatus
A collection of status codes that may be issued by the script verify function.
BITCOINKERNEL_API int32_t btck_block_tree_entry_get_height(const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1)
Return the height of a certain block tree entry.
BITCOINKERNEL_API void BITCOINKERNEL_API uint32_t btck_block_header_get_timestamp(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Get the timestamp from btck_BlockHeader.
BITCOINKERNEL_API void btck_logging_set_min_level(btck_LogLevel level)
Set the minimum log level.
BITCOINKERNEL_API btck_Block *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_read(const btck_ChainstateManager *chainstate_manager, const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1
Reads the block the passed in block tree entry points to from disk and returns it.
BITCOINKERNEL_API void btck_transaction_out_point_destroy(btck_TransactionOutPoint *transaction_out_point)
Destroy the transaction out point.
BITCOINKERNEL_API void btck_tx_validation_state_destroy(btck_TxValidationState *state)
Destroy the btck_TxValidationState.
void(* btck_NotifyBlockTip)(void *user_data, btck_SynchronizationState state, const btck_BlockTreeEntry *entry, double verification_progress)
Function signatures for the kernel notifications.
uint8_t btck_LogCategory
A collection of logging categories that may be encountered by kernel code.
BITCOINKERNEL_API size_t btck_transaction_spent_outputs_count(const btck_TransactionSpentOutputs *transaction_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1)
Returns the number of previous transaction outputs contained in the transaction spent outputs data.
void(* btck_ValidationInterfaceBlockConnected)(void *user_data, btck_Block *block, const btck_BlockTreeEntry *entry)
BITCOINKERNEL_API void btck_transaction_spent_outputs_destroy(btck_TransactionSpentOutputs *transaction_spent_outputs)
Destroy the transaction spent outputs.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API size_t btck_transaction_count_outputs(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Get the number of outputs of a transaction.
BITCOINKERNEL_API void btck_chain_parameters_destroy(btck_ChainParameters *chain_parameters)
Destroy the chain parameters.
BITCOINKERNEL_API int btck_transaction_check(const btck_Transaction *tx, btck_TxValidationState *validation_state) BITCOINKERNEL_ARG_NONNULL(1
Run context-free consensus validation on a btck_Transaction.
BITCOINKERNEL_API int BITCOINKERNEL_API void btck_transaction_destroy(btck_Transaction *transaction)
Destroy the transaction.
uint32_t btck_BlockCheckFlags
Bitflags to control context-free block checks (optional).
BITCOINKERNEL_API uint32_t btck_block_header_get_bits(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Get the nBits difficulty target from btck_BlockHeader.
uint8_t btck_Warning
Possible warning types issued by validation.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API void btck_block_destroy(btck_Block *block)
Destroy the block.
BITCOINKERNEL_API btck_BlockHeader *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_tree_entry_get_block_header(const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1)
Return the btck_BlockHeader associated with this entry.
BITCOINKERNEL_API btck_Transaction *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_copy(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Copy a transaction.
BITCOINKERNEL_API void btck_coin_destroy(btck_Coin *coin)
Destroy the coin.
void(* btck_NotifyHeaderTip)(void *user_data, btck_SynchronizationState state, int64_t height, int64_t timestamp, int presync)
BITCOINKERNEL_API void BITCOINKERNEL_API void btck_context_options_set_notifications(btck_ContextOptions *context_options, btck_NotificationInterfaceCallbacks notifications) BITCOINKERNEL_ARG_NONNULL(1)
Set the kernel notifications for the context options.
BITCOINKERNEL_API btck_BlockHash *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_get_hash(const btck_Block *block) BITCOINKERNEL_ARG_NONNULL(1)
Calculate and return the hash of a block.
BITCOINKERNEL_API btck_ValidationMode btck_block_validation_state_get_validation_mode(const btck_BlockValidationState *block_validation_state) BITCOINKERNEL_ARG_NONNULL(1)
Returns the validation mode from an opaque btck_BlockValidationState pointer.
BITCOINKERNEL_API const btck_WitnessStack * btck_transaction_input_get_witness_stack(const btck_TransactionInput *transaction_input) BITCOINKERNEL_ARG_NONNULL(1)
Get the witness stack of a transaction input.
BITCOINKERNEL_API size_t btck_block_spent_outputs_count(const btck_BlockSpentOutputs *block_spent_outputs) BITCOINKERNEL_ARG_NONNULL(1)
Returns the number of transaction spent outputs whose data is contained in block spent outputs.
BITCOINKERNEL_API void btck_block_spent_outputs_destroy(btck_BlockSpentOutputs *block_spent_outputs)
Destroy the block spent outputs.
BITCOINKERNEL_API btck_BlockValidationState *BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_process_block_header(btck_ChainstateManager *chainstate_manager, const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1
Processes and validates the provided btck_BlockHeader.
BITCOINKERNEL_API btck_ChainstateManagerOptions *BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_options_create(const btck_Context *context, const char *data_directory, size_t data_directory_len, const char *blocks_directory, size_t blocks_directory_len) BITCOINKERNEL_ARG_NONNULL(1)
Create options for the chainstate manager.
BITCOINKERNEL_API int btck_wtxid_equals(const btck_Wtxid *wtxid1, const btck_Wtxid *wtxid2) BITCOINKERNEL_ARG_NONNULL(1
Check if two wtxids are equal.
BITCOINKERNEL_API int BITCOINKERNEL_API void btck_txid_to_bytes(const btck_Txid *txid, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1
Serializes the txid to bytes.
BITCOINKERNEL_API btck_TransactionOutPoint *BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_out_point_copy(const btck_TransactionOutPoint *transaction_out_point) BITCOINKERNEL_ARG_NONNULL(1)
Copy a transaction out point.
BITCOINKERNEL_API int btck_block_tree_entry_equals(const btck_BlockTreeEntry *entry1, const btck_BlockTreeEntry *entry2) BITCOINKERNEL_ARG_NONNULL(1
Check if two block tree entries are equal.
BITCOINKERNEL_API void btck_context_options_set_chainparams(btck_ContextOptions *context_options, const btck_ChainParameters *chain_parameters) BITCOINKERNEL_ARG_NONNULL(1
Sets the chain params for the context options.
BITCOINKERNEL_API void BITCOINKERNEL_API void btck_block_hash_destroy(btck_BlockHash *block_hash)
Destroy the block hash.
BITCOINKERNEL_API btck_ChainParameters *BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_parameters_create_signet(const void *challenge, size_t challenge_len)
Create a signet chain parameters struct with a user-provided challenge.
BITCOINKERNEL_API btck_BlockHash *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_hash_create(const unsigned char block_hash[32]) BITCOINKERNEL_ARG_NONNULL(1)
Create a block hash from its raw data.
BITCOINKERNEL_API void btck_block_hash_to_bytes(const btck_BlockHash *block_hash, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1
Serializes the block hash to bytes.
BITCOINKERNEL_API int32_t btck_block_header_get_version(const btck_BlockHeader *header) BITCOINKERNEL_ARG_NONNULL(1)
Get the version from btck_BlockHeader.
BITCOINKERNEL_API int btck_transaction_has_witness(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Check whether a transaction has witness data.
BITCOINKERNEL_API void btck_chainstate_manager_options_update_block_tree_db_in_memory(btck_ChainstateManagerOptions *chainstate_manager_options, int block_tree_db_in_memory) BITCOINKERNEL_ARG_NONNULL(1)
Sets block tree db in memory in the options.
void(* btck_NotifyWarningSet)(void *user_data, btck_Warning warning, const char *message, size_t message_len)
BITCOINKERNEL_API btck_ScriptPubkey *BITCOINKERNEL_WARN_UNUSED_RESULT btck_script_pubkey_copy(const btck_ScriptPubkey *script_pubkey) BITCOINKERNEL_ARG_NONNULL(1)
Copy a script pubkey.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API void btck_script_pubkey_destroy(btck_ScriptPubkey *script_pubkey)
Destroy the script pubkey.
BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_transaction_input_get_script_sig(const btck_TransactionInput *transaction_input, btck_WriteBytes writer, void *user_data) BITCOINKERNEL_ARG_NONNULL(1
Serialize the script sig of a transaction input through the passed in callback.
BITCOINKERNEL_API int BITCOINKERNEL_API void btck_wtxid_to_bytes(const btck_Wtxid *wtxid, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1
Serializes the wtxid to bytes.
BITCOINKERNEL_API void btck_context_destroy(btck_Context *context)
Destroy the context.
BITCOINKERNEL_API btck_BlockValidationState *BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_validation_state_copy(const btck_BlockValidationState *block_validation_state) BITCOINKERNEL_ARG_NONNULL(1)
Copies the btck_BlockValidationState.
BITCOINKERNEL_API btck_ValidationMode btck_tx_validation_state_get_validation_mode(const btck_TxValidationState *state) BITCOINKERNEL_ARG_NONNULL(1)
Returns the validation mode from an opaque btck_TxValidationState pointer.
BITCOINKERNEL_API void btck_context_options_set_validation_interface(btck_ContextOptions *context_options, btck_ValidationInterfaceCallbacks validation_interface_callbacks) BITCOINKERNEL_ARG_NONNULL(1)
Set the validation interface callbacks for the context options.
BITCOINKERNEL_API void btck_block_header_get_merkle_root(const btck_BlockHeader *header, unsigned char output[32]) BITCOINKERNEL_ARG_NONNULL(1
Get the Merkle root from btck_BlockHeader.
BITCOINKERNEL_API const btck_BlockTreeEntry * btck_block_tree_entry_get_previous(const btck_BlockTreeEntry *block_tree_entry) BITCOINKERNEL_ARG_NONNULL(1)
Returns the previous block tree entry in the tree, or null if the current block tree entry is the gen...
BITCOINKERNEL_API btck_BlockValidationState *BITCOINKERNEL_WARN_UNUSED_RESULT BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_chainstate_manager_import_blocks(btck_ChainstateManager *chainstate_manager, const char **block_file_paths_data, size_t *block_file_paths_lens, size_t block_file_paths_data_len) BITCOINKERNEL_ARG_NONNULL(1)
Triggers the start of a reindex if the wipe options were previously set for the chainstate manager.
void(* btck_NotifyFatalError)(void *user_data, const char *message, size_t message_len)
BITCOINKERNEL_API btck_TxValidationResult btck_tx_validation_state_get_tx_validation_result(const btck_TxValidationState *state) BITCOINKERNEL_ARG_NONNULL(1)
Returns the validation result from an opaque btck_TxValidationState pointer.
void(* btck_NotifyFlushError)(void *user_data, const char *message, size_t message_len)
BITCOINKERNEL_API btck_LoggingConnection *BITCOINKERNEL_WARN_UNUSED_RESULT btck_logging_connection_create(btck_LogCallback log_callback, void *user_data, btck_DestroyCallback user_data_destroy_callback) BITCOINKERNEL_ARG_NONNULL(1)
Start logging messages through the provided callback.
BITCOINKERNEL_API size_t btck_witness_stack_count_items(const btck_WitnessStack *witness_stack) BITCOINKERNEL_ARG_NONNULL(1)
Return the number of items in a witness stack.
BITCOINKERNEL_API size_t btck_transaction_count_inputs(const btck_Transaction *transaction) BITCOINKERNEL_ARG_NONNULL(1)
Get the number of inputs of a transaction.
BITCOINKERNEL_API const btck_BlockTreeEntry * btck_chain_get_by_height(const btck_Chain *chain, int32_t block_height) BITCOINKERNEL_ARG_NONNULL(1)
Retrieve a block tree entry by its height in the currently active chain.
BITCOINKERNEL_API btck_ChainParameters *BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_parameters_copy(const btck_ChainParameters *chain_parameters) BITCOINKERNEL_ARG_NONNULL(1)
Copy the chain parameters.
A log entry passed to the logging callback.
const char * thread_name
Name of the thread that produced the log message.
size_t function_name_len
Length of function_name.
int64_t timestamp_ns
Wall-clock time when the entry was logged, in nanoseconds since the Unix epoch.
const char * function_name
Name of the function that produced the log message.
size_t file_name_len
Length of file_name.
uint32_t line
Line number of the source code that produced the log statement.
const char * message
Log message text.
const char * file_name
Name of the source file that produced the log statement.
int64_t mocktime_s
Mock time in effect when the entry was logged, in seconds since the Unix epoch, or 0 if no mock time ...
btck_LogCategory category
Log category.
size_t message_len
Length of message.
size_t thread_name_len
Length of thread_name.
btck_LogLevel level
Log severity level.
A struct for holding the kernel notification callbacks.
btck_NotifyWarningUnset warning_unset
A previous condition leading to the issuance of a warning is no longer given.
btck_NotifyBlockTip block_tip
The chain's tip was updated to the provided block entry.
btck_NotifyWarningSet warning_set
A warning issued by the kernel library during validation.
btck_NotifyFlushError flush_error
An error encountered when flushing data to disk.
btck_NotifyProgress progress
Reports on current block synchronization progress.
btck_NotifyFatalError fatal_error
An unrecoverable system error encountered by the library.
btck_DestroyCallback user_data_destroy
Frees the provided user data structure.
void * user_data
Holds a user-defined opaque structure that is passed to the notification callbacks.
btck_NotifyHeaderTip header_tip
A new best block header was added.
Holds the validation interface callbacks.
btck_DestroyCallback user_data_destroy
Frees the provided user data structure.
btck_ValidationInterfaceBlockConnected block_connected
Called when a block is valid and has now been connected to the best chain.
btck_ValidationInterfaceBlockChecked block_checked
Called when a new block has been fully validated.
btck_ValidationInterfaceBlockDisconnected block_disconnected
Called during a re-org when a block has been removed from the best chain.
void * user_data
Holds a user-defined opaque structure that is passed to the validation interface callbacks.
btck_ValidationInterfacePoWValidBlock pow_valid_block
Called when a new block extends the header chain and has a valid transaction and segwit merkle root.
WalletContext context