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
| Name | Required | Description | Default |
|---|---|---|---|
| hex_script | Yes |
Output Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/bitcoin_mcp/server.py:801-814 (handler)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)