Skip to content

Class BSV::Wallet::Substrates::HTTPWalletWire

Inherits: Object Includes: BSV::Wallet::WalletWire

Concrete {WalletWire} implementation over HTTP/HTTPS.

Transmits binary BRC-103 request frames via HTTP POST to {base_url}/wallet using Content-Type: application/octet-stream, and returns the raw binary response body.

The optional http_client: parameter accepts any object responding to #request(uri, net_http_request) — matching the injectable client convention used throughout this SDK. When omitted, Net::HTTP is used directly.

@example Direct wire usage

wire   = BSV::Wallet::Substrates::HTTPWalletWire.new(base_url: 'https://wallet.example')
client = BSV::Wallet::WalletWireTransceiver.new(wire)
client.get_network  #=> { network: :mainnet }

@example Convenience factory

client = BSV::Wallet::Substrates::HTTPWalletWire.client(base_url: 'https://wallet.example')
client.get_network  #=> { network: :mainnet }

Public Class Methods

client(base_url:, http_client: = nil, headers: = {})

Convenience factory: wraps a new {HTTPWalletWire} in a {WalletWireTransceiver}. - @param base_url [String] - @param http_client [#request, nil] - @param headers [Hash] - @return [WalletWireTransceiver]

Public Instance Methods

initialize(base_url:, http_client: = nil, headers: = {})

  • @param base_url [String] wallet base URL (e.g. 'https://wallet.example')
  • @param http_client [#request, nil] injectable HTTP client for testing; must respond to +#request(uri, net_http_request)+. Defaults to +Net::HTTP+.
  • @param headers [Hash] additional headers merged into every request
  • @return [HTTPWalletWire] a new instance of HTTPWalletWire

transmit_to_wallet(message)

POST binary frame to {base_url}/wallet and return the binary response body. - @param message [String] binary request frame (ASCII-8BIT) - @raise [BSV::Wallet::Error] on non-2xx HTTP status or network failure - @return [String] binary result frame (ASCII-8BIT)