example.py
TEXT FILE809 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_request(net: str, kind: str) -> dict:
19 if net != "test" or kind not in ("segwit", "taproot"):
20 raise ValueError("unsupported request")
21 return {"net": net, "type": kind}Read-only source · Select a line number to link directly · Raw download above
