This commit is contained in:
dni
2026-07-13 09:09:41 +02:00
parent 730d1e2aaf
commit 69c72e1d86
2 changed files with 7 additions and 8 deletions
+6 -6
View File
@@ -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
+1 -2
View File
@@ -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):