Skip to content

Class BSV::Wallet::Substrates::HTTPWalletWire

Inherits: Object

Binary wire transport that transmits BRC-100 wallet wire messages over HTTP.

Implements the single-method WalletWire interface: given a raw binary frame (as an Array of byte integers), parses the call code, maps it to a URL path, and POSTs the payload to the remote wallet endpoint.

@example

wire = BSV::Wallet::Substrates::HTTPWalletWire.new('http://localhost:3301')
response_bytes = wire.transmit_to_wallet(frame_bytes)

Public Instance Methods

initialize(base_url, originator: = nil, http_client: = nil)

  • @param base_url [String] the base URL of the remote wallet (e.g. 'http://localhost:3301')
  • @param originator [String, nil] FQDN of the calling application (sent as Origin header)
  • @param http_client [#call, nil] injectable HTTP client for testing; nil uses Net::HTTP
  • @return [HTTPWalletWire] a new instance of HTTPWalletWire

transmit_to_wallet(message)

Transmits a binary wallet wire message to the remote wallet.

Parses the call code from byte 0, reads the originator from the header, and POSTs the remaining payload bytes to the appropriate URL path. - @param message [Array] raw wire frame as array of byte integers - @raise [ArgumentError] if the message is empty or contains an unknown call code - @raise [RuntimeError] if the HTTP response indicates an error (non-2xx) - @return [Array] response body as array of byte integers