"""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 validate_args(args: dict) -> dict: if set(args) != {"net", "type"} or args["net"] != "test" or args["type"] not in ("segwit", "taproot"): raise ValueError("invalid tool arguments") return dict(args)