From ba6287a44933b7429dea05d97dadefd3b58b4c8b Mon Sep 17 00:00:00 2001 From: Alexander Wiederin Date: Thu, 16 Apr 2026 16:21:21 +0200 Subject: [PATCH 1/2] kernel: align height parameters to int32_t in btck API Aligns btck_chain_get_height and btck_chain_get_by_height to use int32_t for height parameters and return values. Updates the C++ wrapper accordingly. --- src/kernel/bitcoinkernel.cpp | 4 ++-- src/kernel/bitcoinkernel.h | 2 +- src/kernel/bitcoinkernel_wrapper.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp index dc03be71461..4ba60c1b56c 100644 --- a/src/kernel/bitcoinkernel.cpp +++ b/src/kernel/bitcoinkernel.cpp @@ -1352,13 +1352,13 @@ const btck_Chain* btck_chainstate_manager_get_active_chain(const btck_Chainstate return btck_Chain::ref(&WITH_LOCK(btck_ChainstateManager::get(chainman).m_chainman->GetMutex(), return btck_ChainstateManager::get(chainman).m_chainman->ActiveChain())); } -int btck_chain_get_height(const btck_Chain* chain) +int32_t btck_chain_get_height(const btck_Chain* chain) { LOCK(::cs_main); return btck_Chain::get(chain).Height(); } -const btck_BlockTreeEntry* btck_chain_get_by_height(const btck_Chain* chain, int height) +const btck_BlockTreeEntry* btck_chain_get_by_height(const btck_Chain* chain, int32_t height) { LOCK(::cs_main); return btck_BlockTreeEntry::ref(btck_Chain::get(chain)[height]); diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h index d3028b491d2..a0483b96ee8 100644 --- a/src/kernel/bitcoinkernel.h +++ b/src/kernel/bitcoinkernel.h @@ -1423,7 +1423,7 @@ BITCOINKERNEL_API int32_t BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_get_height */ BITCOINKERNEL_API const btck_BlockTreeEntry* BITCOINKERNEL_WARN_UNUSED_RESULT btck_chain_get_by_height( const btck_Chain* chain, - int block_height) BITCOINKERNEL_ARG_NONNULL(1); + int32_t block_height) BITCOINKERNEL_ARG_NONNULL(1); /** * @brief Return true if the passed in chain contains the block tree entry. diff --git a/src/kernel/bitcoinkernel_wrapper.h b/src/kernel/bitcoinkernel_wrapper.h index cb7af8b35dd..38dd709f948 100644 --- a/src/kernel/bitcoinkernel_wrapper.h +++ b/src/kernel/bitcoinkernel_wrapper.h @@ -1122,12 +1122,12 @@ public: return btck_chain_get_height(get()); } - int CountEntries() const + int32_t CountEntries() const { return btck_chain_get_height(get()) + 1; } - BlockTreeEntry GetByHeight(int height) const + BlockTreeEntry GetByHeight(int32_t height) const { auto index{btck_chain_get_by_height(get(), height)}; if (!index) throw std::runtime_error("No entry in the chain at the provided height"); From 07b9b13b45fa3e9197f992c55d0ca94c964f4fc4 Mon Sep 17 00:00:00 2001 From: Alexander Wiederin Date: Fri, 17 Apr 2026 16:48:09 +0200 Subject: [PATCH 2/2] doc: add integer type conventions in btck api remarks --- src/kernel/bitcoinkernel.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kernel/bitcoinkernel.h b/src/kernel/bitcoinkernel.h index a0483b96ee8..cd837573dff 100644 --- a/src/kernel/bitcoinkernel.h +++ b/src/kernel/bitcoinkernel.h @@ -112,6 +112,12 @@ extern "C" { * object. * * Array lengths follow the pointer argument they describe. + * + * @section types Type conventions + * + * Fixed-width integer types (e.g. int32_t, uint32_t) are used for data values + * such as heights. Plain int and unsigned int are used for boolean-like values + * and flags. */ /**