example.py
TEXT FILE745 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 review_summary(raw: str) -> str:
19 balance_sat(raw)
20 return "Synthetic response contract accepted; no payment executed."Read-only source · Select a line number to link directly · Raw download above
