Class: BSV::Network::Protocols::ARC

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

Overview

ARC protocol implementation for submitting transactions to the BSV network.

Extends Protocol with five endpoints and two escape hatches for broadcast logic: EF format preference, rejection detection, and custom headers.

The protocol returns Result objects (never raises). The facade layer (Phase D) is responsible for translating Results to BroadcastResponse / BroadcastError as needed by consumer code.

Example

arc = BSV::Network::Protocols::ARC.new(
  base_url: 'https://arc.taal.com',
  api_key: 'my-api-key'
)
result = arc.call(:broadcast, tx)
result.success? # => true
result.data[:txid] # => "abc123..."

Constant Summary collapse

REJECTED_STATUSES =

ARC response statuses that indicate a transaction was NOT accepted. Matches the TypeScript SDK’s ARC broadcaster failure set.

%w[
  REJECTED
  DOUBLE_SPEND_ATTEMPTED
  INVALID
  MALFORMED
  MINED_IN_STALE_BLOCK
].freeze
ORPHAN_MARKER =

Substring marker for orphan detection in txStatus or extraInfo fields.

'ORPHAN'

Instance Attribute Summary

Attributes inherited from BSV::Network::Protocol

#api_key, #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, network: nil, deployment_id: nil, callback_url: nil, callback_token: nil, http_client: nil) ⇒ ARC

Returns a new instance of ARC.

Parameters:

  • base_url (String)

    ARC base URL (may contain BSV::Network::Protocol#network)

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

    optional bearer token

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

    network name for base URL interpolation

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

    deployment identifier for the XDeployment-ID header; defaults to a per-instance random hex value

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

    optional X-CallbackUrl header value

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

    optional X-CallbackToken header value

  • http_client (#request, nil) (defaults to: nil)

    injectable HTTP client for testing



55
56
57
58
59
60
61
# File 'lib/bsv/network/protocols/arc.rb', line 55

def initialize(base_url:, api_key: nil, network: nil, deployment_id: nil,
               callback_url: nil, callback_token: nil, http_client: nil)
  super(base_url: base_url, api_key: api_key, network: network, http_client: http_client)
  @deployment_id  = deployment_id || "bsv-ruby-sdk-#{SecureRandom.hex(8)}"
  @callback_url   = callback_url
  @callback_token = callback_token
end