#33820 kernel: trim Chain interface

full analysis

https://github.com/bitcoin/bitcoin/pull/33820 · stickies-v · +2/-33 in 3 files, 2 commits · labels: Validation

Goal

  • Trim redundant accessor functions from the public libbitcoinkernel C API
  • Reduces public API surface where height lookups already cover genesis and tip queries

Removes btck_chain_get_genesis and btck_chain_get_tip from the libbitcoinkernel C API. Both operations can be performed by calling btck_chain_get_by_height with height 0 or the current chain height.

Problem: Redundant accessor methods expand the public kernel surface without providing extra guarantees or thread safety over existing height-based lookups.

Category: Kernel (libbitcoinkernel) (#16 of 18)

P4 · cleanup

  • P4 because this is routine API surface trimming with no downstream blocker or safety improvement
  • The removed methods offer marginal utility and are trivially replaced by existing height lookups

P4 because this is routine API surface trimming with no downstream blocker or safety improvement. The author notes both functions 'are trivially replaced with btck_chain_get_by_height', and TheCharlatan agreed their utility is marginal.

Membership: Modifies the libbitcoinkernel C API wrapper in src/kernel/bitcoinkernel_wrapper.h.

Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0

Reviewability: Stale: Author silent

  • Author has been silent for over 300 days

The author has been silent for 311 days, exceeding the project stale threshold of 60 days.

Author status: silent since 2025-11-10

Resolved concerns:

  • maflcko pointed out a potential exception when querying tip height during a reorg that lowers chain height, which TheCharlatan noted exists on master as well and belongs to external synchronization.

Agreement: Strong

  • Strong consensus to remove redundant accessors from the public kernel interface
  • Agrees the calls should be removed and synchronization belongs to external callers (TheCharlatan)
  • Approves removing redundant methods (yuvicc)

Strong: yuvicc and TheCharlatan agree the redundant accessors should be removed.

Both reviewers supported trimming the API after resolving an inline discussion on thread safety and reorg edge cases.

  • yuvicc: 'ACK f4b3ba1 ... This makes sense to me.'
  • TheCharlatan: 'External callers should provide synchronization for this. So the two calls should just be removed imo.'

Review verdicts (DrahtBot): 1

Files

0 lines under test/bench/ci.

File list not available for this run.

Card

This PR removes btck_chain_get_genesis and btck_chain_get_tip from the libbitcoinkernel C API, trimming redundant methods that can be achieved via btck_chain_get_by_height. It is a minor API cleanup that does not affect validation logic or unlock external consumers. Reviewers TheCharlatan and yuvicc agreed the methods are redundant and safe to remove, but the PR has been inactive for over ten months.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T16:16, confidence high, input hash fbb2400e330e296f