Class: BSV::MCP::Tools::DecodeTx

Inherits:
MCP::Tool
  • Object
show all
Defined in:
lib/bsv/mcp/tools/decode_tx.rb

Overview

Decodes a raw BSV transaction from hex and returns a structured human-readable representation.

Supports standard raw hex only (not BEEF format). The txid is returned in display byte order (reversed from the wire hash), matching block explorer conventions.

Class Method Summary collapse

Class Method Details

.call(hex:) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/bsv/mcp/tools/decode_tx.rb', line 50

def self.call(hex:, **)
  tx = BSV::Transaction::Transaction.from_hex(hex)
  result = Helpers.transaction_to_h(tx)

  ::MCP::Tool::Response.new(
    [::MCP::Content::Text.new(result.to_json)],
    structured_content: result
  )
rescue ArgumentError => e
  Helpers.error_response(e.message)
end