kernel: align height parameters to int32_t in btck API
What changed, and why it matters
This commit is a minor type-cleanup change in Bitcoin Core's internal kernel API. It changes several height-related function parameters and return values from the generic `int` type to the explicitly-sized `int32_t` type. There is no security-relevant behavior change, no bug fix, and no disclosed vulnerability.
No security action required. Treat as a normal code-quality / API-consistency change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch aligns btck_chain_get_height, btck_chain_get_by_height, and the C++ wrapper’s CountEntries/GetByHeight methods to use int32_t consistently for block height parameters and return values. This is a type-signature refactor across src/kernel/bitcoinkernel.cpp, src/kernel/bitcoinkernel.h, and src/kernel/bitcoinkernel_wrapper.h. On platforms where int is already 32 bits, the compiled code is functionally identical. No logic, bounds checking, locking, or memory handling is altered.
Changed components
src/kernel/bitcoinkernel.cppsrc/kernel/bitcoinkernel.hsrc/kernel/bitcoinkernel_wrapper.hInspect captured patch +5 / −5
diff --git a/src/kernel/bitcoinkernel.cpp b/src/kernel/bitcoinkernel.cpp
index dc03be71..4ba60c1b 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 d3028b49..a0483b96 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 cb7af8b3..38dd709f 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");
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.