From 69c72e1d86e33cd3ca5a34673bc49fa44eb0e812 Mon Sep 17 00:00:00 2001 From: dni Date: Tue, 23 Jun 2026 06:11:16 +0200 Subject: [PATCH] fix ruff --- lnbits/core/views/blockexplorer_api.py | 12 ++++++------ lnbits/utils/electrum.py | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lnbits/core/views/blockexplorer_api.py b/lnbits/core/views/blockexplorer_api.py index 512c36f7a..09c02dc6a 100644 --- a/lnbits/core/views/blockexplorer_api.py +++ b/lnbits/core/views/blockexplorer_api.py @@ -40,7 +40,7 @@ async def api_tip() -> BlockHeader: async with _client() as c: return await c.get_tip() except ElectrumError as e: - raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) + raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) from e @blockexplorer_router.get("/fees") @@ -57,12 +57,12 @@ async def api_fees() -> FeeResponse: histogram = await c.fee_histogram() estimates = { str(blocks): fee - for blocks, fee in zip([1, 3, 6, 144], estimates_raw) + for blocks, fee in zip([1, 3, 6, 144], estimates_raw, strict=False) if fee >= 0 } return FeeResponse(estimates=estimates, histogram=histogram) except ElectrumError as e: - raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) + raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) from e @blockexplorer_router.get("/tx/{txid}") @@ -73,7 +73,7 @@ async def api_tx(txid: str) -> Transaction: raw_hex = await c.get_transaction(txid, verbose=False) return parse_raw_tx(raw_hex) except ElectrumError as e: - raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) + raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) from e @blockexplorer_router.get("/address/{address}") @@ -82,7 +82,7 @@ async def api_address(address: str) -> AddressResponse: try: scripthash = scripthash_from_address(address) except ValueError as e: - raise HTTPException(HTTPStatus.BAD_REQUEST, detail=str(e)) + raise HTTPException(HTTPStatus.BAD_REQUEST, detail=str(e)) from e try: async with _client() as c: balance, history = await asyncio.gather( @@ -91,4 +91,4 @@ async def api_address(address: str) -> AddressResponse: ) return AddressResponse(balance=balance, history=history) except ElectrumError as e: - raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) + raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) from e diff --git a/lnbits/utils/electrum.py b/lnbits/utils/electrum.py index 0ba1e1d09..06d41a8e9 100644 --- a/lnbits/utils/electrum.py +++ b/lnbits/utils/electrum.py @@ -52,7 +52,7 @@ def _b58decode_check(s: str) -> bytes: def address_to_scriptpubkey(address: str) -> bytes: - """Convert a Bitcoin address (P2PKH/P2SH/P2WPKH/P2WSH/P2TR) to scriptPubKey bytes.""" + """Convert a Bitcoin address (P2PKH/P2SH/P2WPKH/P2WSH/P2TR) to scriptPubKey.""" lower = address.lower() if lower.startswith(("bc1", "tb1", "bcrt1")): _, data = bech32_decode(address) @@ -291,7 +291,6 @@ def parse_raw_tx(hex_str: str) -> Transaction: ) ) - vout_start = i vout_count, i = _read_varint(data, i) vout: list[TxOutput] = [] for n_out in range(vout_count):