# SPDX-License-Identifier: 0BSD def report(role, response): if role != "reporter" or response.get("ok") is not True: raise PermissionError("unavailable") result = response["result"] amount = result["balance_sat"] if type(amount) is not int or amount < 0: raise ValueError("invalid balance") return {"balance_sat": amount} assert report("reporter", {"ok": True, "result": {"balance_sat": 500, "btc_id": "private-scope"}}) == {"balance_sat": 500}