Skip to content

Class BSV::Transaction::ChainTrackers::WhatsOnChain

Inherits: BSV::Transaction::ChainTracker

Chain tracker that verifies merkle roots using the WhatsOnChain API.

Queries the WoC block header endpoint to retrieve the merkle root for a given block height and compares it with the provided root.

@example

tracker = BSV::Transaction::ChainTrackers::WhatsOnChain.new
tracker.valid_root_for_height?('abcd...', 800_000)

Constants

BASE_URL

Not documented.

NETWORKS

Not documented.

Public Instance Methods

current_height()

Return the current blockchain height. - @return [Integer]

initialize(network: = :main, api_key: = nil, http_client: = nil)

  • @param network [Symbol] :main, :mainnet, :test, :testnet, or :stn
  • @param api_key [String, nil] optional WoC API key
  • @param http_client [#request, nil] injectable HTTP client for testing
  • @return [WhatsOnChain] a new instance of WhatsOnChain

valid_root_for_height?(root, height)

Verify that a merkle root is valid for the given block height. - @param root [String] merkle root as a hex string - @param height [Integer] block height - @return [Boolean]