"""Offline reference: no network, no credentials, no transaction execution.""" import json FIXTURE = '{"ok":true,"result":{"balance_sat":12500}}' def balance_sat(raw: str) -> int: envelope = json.loads(raw) if not isinstance(envelope, dict) or envelope.get("ok") is not True: raise ValueError("engine did not report success") result = envelope.get("result") if not isinstance(result, dict): raise ValueError("missing result") amount = result.get("balance_sat") if type(amount) is not int or amount < 0: raise ValueError("invalid satoshi amount") return amount def dispatch(name: str, raw: str) -> int: if name != "fixture_balance": raise ValueError("tool not allowed") return balance_sat(raw)