Class: BSV::Network::Protocols::TAALBinary

Inherits:
BSV::Network::Protocol show all
Defined in:
lib/bsv/network/protocols/taal_binary.rb

Overview

TAALBinary implements the TAAL broadcast API using raw binary transaction submission over HTTP.

TAAL quirks handled here:

  • Content-Type is application/octet-stream (not JSON)

  • Authorization header is applied via the standard apply_auth mechanism

  • A response containing txn-already-known in the error field is treated as success (the transaction is already in the mempool — idempotent)

Example

protocol = BSV::Network::Protocols::TAALBinary.new(
  base_url: 'https://api.taal.com',
  auth: { api_key: 'mainnet_your_key_here' }
)
result = protocol.call(:broadcast, tx)
puts result.data[:txid] if result.success?

Instance Attribute Summary

Attributes inherited from BSV::Network::Protocol

#api_key, #auth, #base_url, #http_client, #network

Instance Method Summary collapse

Methods inherited from BSV::Network::Protocol

#call, commands, #default_call, endpoint, endpoints, inherited, subscription, subscriptions

Constructor Details

#initialize(base_url:, api_key: nil, auth: nil, http_client: nil) ⇒ TAALBinary

Returns a new instance of TAALBinary.

Parameters:

  • base_url (String)

    base URL for the TAAL binary API

  • api_key (String, nil) (defaults to: nil)

    legacy API key shorthand (no Bearer prefix) — use auth: for new code

  • auth (Hash, Symbol, nil) (defaults to: nil)

    auth config; takes precedence over api_key:

  • http_client (Object, nil) (defaults to: nil)

    injectable HTTP client for testing



32
33
34
35
36
37
# File 'lib/bsv/network/protocols/taal_binary.rb', line 32

def initialize(base_url:, api_key: nil, auth: nil, http_client: nil)
  # Translate legacy api_key: to auth: { api_key: } so the base class sends
  # the raw key without a Bearer prefix, matching TAAL's expected auth format.
  resolved_auth = auth || (api_key ? { api_key: api_key } : nil)
  super(base_url: base_url, auth: resolved_auth, http_client: http_client)
end