# Module BSV::Network::Util <a id="module-BSV-Network-Util"></a>

Shared utility methods for protocol implementations.

## Public Class Methods
### `resolve_tx_hex(tx)` <a id="method-c-resolve_tx_hex"></a> <a id="resolve_tx_hex-class_method"></a>
Coerce a transaction input to hex.

Accepts (in order of preference):
1.  Hex string — pass-through, zero conversion
2.  Binary string — convert to hex
3.  Transaction object — prefer EF hex (BRC-30), fall back to raw hex

Detection uses content, not encoding: a string is hex if it has even length
and contains only hex characters. This handles hex strings tagged as
ASCII-8BIT (e.g. read from IO in binary mode).

Empty input is rejected — an empty transaction cannot meaningfully be
broadcast and any downstream `rawTx: ''` body is a sign of a caller bug, not
valid traffic.
- **@param** `tx` [String, #to_ef_hex, #to_hex] transaction in any supported form
- **@raise** [ArgumentError] if `tx` is an empty string
- **@return** [String] hex-encoded transaction

### `safe_parse_json(raw)` <a id="method-c-safe_parse_json"></a> <a id="safe_parse_json-class_method"></a>
Parse JSON, returning a hash with a 'detail' key on parse failure. When the
raw input is nil or empty the detail is nil (not an empty string).
