example.py
TEXT FILE764 B · Public source code for developers, search crawlers and AI agents
1"""Offline reference: no network, no credentials, no transaction execution."""
2import json
3
4FIXTURE = '{"ok":true,"result":{"balance_sat":12500}}'
5
6def balance_sat(raw: str) -> int:
7 envelope = json.loads(raw)
8 if not isinstance(envelope, dict) or envelope.get("ok") is not True:
9 raise ValueError("engine did not report success")
10 result = envelope.get("result")
11 if not isinstance(result, dict):
12 raise ValueError("missing result")
13 amount = result.get("balance_sat")
14 if type(amount) is not int or amount < 0:
15 raise ValueError("invalid satoshi amount")
16 return amount
17
18def dispatch(name: str, raw: str) -> int:
19 if name != "fixture_balance":
20 raise ValueError("tool not allowed")
21 return balance_sat(raw)Read-only source · Select a line number to link directly · Raw download above
