Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
2001*/2002BITCOINKERNEL_API btck_BlockHash* BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_header_get_hash(2003const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1);2005/**2006* @brief Get the previous btck_BlockHash from btck_BlockHeader. The returned hash2007* is unowned and only valid for the lifetime of the btck_BlockHeader.2008*2009* @param[in] header Non-null btck_BlockHeader2010* @return Previous btck_BlockHash2011*/2012BITCOINKERNEL_API const btck_BlockHash* btck_block_header_get_prev_hash(2013const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1);2015/**2016* @brief Get the timestamp from btck_BlockHeader.2017*2018* @param[in] header Non-null btck_BlockHeader2019* @return Block timestamp (Unix epoch seconds)2020*/2021BITCOINKERNEL_API uint32_t btck_block_header_get_timestamp(2022const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1);2024/**2025* @brief Get the nBits difficulty target from btck_BlockHeader.2026*2027* @param[in] header Non-null btck_BlockHeader2028* @return Difficulty target (compact format)2029*/2030BITCOINKERNEL_API uint32_t btck_block_header_get_bits(2031const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1);2033/**2034* @brief Get the version from btck_BlockHeader.2035*2036* @param[in] header Non-null btck_BlockHeader2037* @return Block version2038*/2039BITCOINKERNEL_API int32_t btck_block_header_get_version(2040const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1);2042/**2043* @brief Get the nonce from btck_BlockHeader.2044*2045* @param[in] header Non-null btck_BlockHeader2046* @return Nonce2047*/2048BITCOINKERNEL_API uint32_t btck_block_header_get_nonce(2049const btck_BlockHeader* header) BITCOINKERNEL_ARG_NONNULL(1);2051/**2052* @brief Serializes the btck_BlockHeader to bytes.2053* This is consensus serialization that is also used for the P2P network.2054*2055* @param[in] header Non-null.2056* @param[out] output The serialized block header (80 bytes).2057* @return 0 on success.2058*/2059BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_block_header_to_bytes(2060const btck_BlockHeader* header, unsigned char output[80]) BITCOINKERNEL_ARG_NONNULL(1, 2);2062/**2063* Destroy the btck_BlockHeader.2064*/2065BITCOINKERNEL_API void btck_block_header_destroy(btck_BlockHeader* header);2067///@}2069/** @name Testing2070* Functions intended for testing purposes only.2071*/2072///@{2074/**2075* @brief Override the current time with a fixed timestamp for testing.2076*2077* Affects all kernel time reads globally. The caller is responsible2078* for gating usage (e.g. restricting to regtest) if desired.2079*2080* The upper bound (4294967295) matches the maximum value of a block header2081* timestamp.2082*2083* @param[in] timestamp Unix epoch seconds, or 0 to restore the system clock.2084* @return 0 on success, non-zero if timestamp is outside the2085* valid [0, 4294967295] range.2086*/2087BITCOINKERNEL_API int BITCOINKERNEL_WARN_UNUSED_RESULT btck_set_mock_time(int64_t timestamp);2089///@}2091#ifdef __cplusplus2092} // extern "C"2093#endif // __cplusplus2095#endif // BITCOIN_KERNEL_BITCOINKERNEL_H