Class: BSV::MCP::Tools::FetchUtxos
- Inherits:
-
MCP::Tool
- Object
- MCP::Tool
- BSV::MCP::Tools::FetchUtxos
- Defined in:
- lib/bsv/mcp/tools/fetch_utxos.rb
Overview
Fetches unspent transaction outputs (UTXOs) for a BSV address using the WhatsOnChain API.
The http_client dependency is injectable for testing — pass a compatible mock object to new_woc.
Class Method Summary collapse
Class Method Details
.call(address:, network: nil, server_context: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/bsv/mcp/tools/fetch_utxos.rb', line 51 def self.call(address:, network: nil, server_context: nil) net_sym = Helpers.resolve_network_sym(network, server_context) woc = BSV::Network::WhatsOnChain.new(network: net_sym) utxos = woc.fetch_utxos(address) result = { address: address, network: net_sym.to_s, utxos: utxos.map { |u| Helpers.utxo_to_h(u) } } ::MCP::Tool::Response.new( [::MCP::Content::Text.new(result.to_json)], structured_content: result ) rescue BSV::Network::ChainProviderError => e Helpers.error_response("#{e.} (HTTP #{e.status_code})") end |