Skip to content

Class BSV::Transaction::ChainTrackers::WhatsOnChain

Inherits: BSV::Transaction::ChainTracker

Chain tracker that verifies merkle roots using the WhatsOnChain API.

Delegates all HTTP communication to {BSV::Network::Protocols::WoCREST}. The constructor signature and {ChainTracker} contract are preserved.

Note: the WoC API key is sent as a raw Authorization header value (not Bearer-prefixed) to match the existing WoC API convention.

@example

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

Public Class Methods

default(testnet: = false, **opts)

Returns a WhatsOnChain chain tracker using the provider default. - @param testnet [Boolean] when true, uses the testnet endpoint - @param opts [Hash] forwarded to the underlying protocol (e.g. +api_key:+, +http_client:+) - @return [WhatsOnChain]

Public Instance Methods

current_height()

Return the current blockchain height. - @raise [BSV::Network::ChainProviderError] on network or API error - @return [Integer]

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

  • @param network [Symbol] :main, :mainnet, :test, :testnet (legacy compat)
  • @param api_key [String, nil] optional WoC API key
  • @param http_client [#request, nil] injectable HTTP client for testing
  • @param protocol [BSV::Network::Protocols::WoCREST, nil] pre-configured protocol
  • @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 - @raise [BSV::Network::ChainProviderError] on network or API error - @return [Boolean]