Skip to main content
Glama

explain_script

Decode Bitcoin Script hex to break down opcodes for understanding transaction logic and validation.

Instructions

Decode a Bitcoin Script hex and break down the opcodes.

Args: hex_script: Script in hex format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hex_scriptYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The `explain_script` tool handler in `src/bitcoin_mcp/server.py`. It decodes a Bitcoin Script hex string using the RPC `decodescript` method and processes the asm field.
    @mcp.tool()
    def explain_script(hex_script: str) -> str:
        """Decode a Bitcoin Script hex and break down the opcodes.
    
        Args:
            hex_script: Script in hex format
        """
        try:
            result = get_rpc().decodescript(hex_script)
        except Exception as e:
            return json.dumps({"error": str(e)})
        if "asm" in result:
            result["opcodes"] = result["asm"].split()
        return json.dumps(result)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Bortlesboat/bitcoin-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server