Skip to content

Class BSV::Network::ARC

Inherits: Object

ARC broadcaster for submitting transactions to the BSV network.

This facade preserves the legacy public API contract while delegating all HTTP logic to Protocols::ARC. It translates Result objects returned by the protocol into BroadcastResponse instances or raised BroadcastError exceptions as required by consumer code.

Any object responding to #broadcast(tx) can serve as a broadcaster; this class implements that contract using the ARC API.

Constants

REJECTED_STATUSES

ARC response statuses that indicate the transaction was NOT accepted.

Public Class Methods

default(testnet: = false, api_key: = nil, http_client: = nil, **opts)

Returns an ARC instance pointed at the GorillaPool public ARC endpoint. - @param testnet [Boolean] when true, uses the GorillaPool testnet endpoint - @param api_key [String, nil] optional bearer token for Authorization - @param http_client [#request, nil] injectable HTTP client for testing - @param opts [Hash] ARC-specific options forwarded to the protocol (e.g. +deployment_id:+, +callback_url:+, +callback_token:+) - @return [ARC]

Public Instance Methods

broadcast(tx, wait_for: = nil, skip_fee_validation: = nil, skip_script_validation: = nil)

Submit a transaction to ARC. - @param tx [Transaction] the transaction to broadcast - @param wait_for [String, nil] ARC wait condition - @param skip_fee_validation [Boolean, nil] when truthy, sends X-SkipFeeValidation header - @param skip_script_validation [Boolean, nil] when truthy, sends X-SkipScriptValidation header - @raise [BroadcastError] when ARC returns a non-2xx HTTP status or a rejected/orphan +txStatus+ - @return [BroadcastResponse]

broadcast_many(txs, wait_for: = nil, skip_fee_validation: = nil, skip_script_validation: = nil)

Submit multiple transactions to ARC in a single batch request.

Returns a mixed array of {BroadcastResponse} and {BroadcastError} objects. Per-transaction rejections are returned as {BroadcastError} values rather than raised. Only HTTP-level errors raise a {BroadcastError} for the whole batch. - @param txs [Array] transactions to broadcast - @param wait_for [String, nil] ARC wait condition - @param skip_fee_validation [Boolean, nil] - @param skip_script_validation [Boolean, nil] - @raise [BroadcastError] when ARC returns a non-2xx HTTP status - @return [Array]

initialize(url_or_protocol, api_key: = nil, deployment_id: = nil, callback_url: = nil, callback_token: = nil, http_client: = nil)

  • @param url_or_protocol [String, Protocols::ARC] ARC base URL (without trailing slash) or a pre-configured +Protocols::ARC+ instance. When a URL string is supplied, the remaining keyword arguments are forwarded to the underlying protocol constructor. When a protocol instance is supplied, all keyword arguments are ignored.
  • @param api_key [String, nil] optional bearer token for Authorization
  • @param deployment_id [String, nil] optional deployment identifier for the +XDeployment-ID+ header; defaults to a per-instance random value
  • @param callback_url [String, nil] optional +X-CallbackUrl+ for ARC status callbacks
  • @param callback_token [String, nil] optional +X-CallbackToken+ for ARC status callback authentication
  • @param http_client [#request, nil] injectable HTTP client for testing
  • @return [ARC] a new instance of ARC

status(txid)

Query the status of a previously submitted transaction. - @param txid [String] transaction ID to query - @raise [BroadcastError] on failure - @return [BroadcastResponse]