fix ruff
This commit is contained in:
@@ -40,7 +40,7 @@ async def api_tip() -> BlockHeader:
|
|||||||
async with _client() as c:
|
async with _client() as c:
|
||||||
return await c.get_tip()
|
return await c.get_tip()
|
||||||
except ElectrumError as e:
|
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")
|
@blockexplorer_router.get("/fees")
|
||||||
@@ -57,12 +57,12 @@ async def api_fees() -> FeeResponse:
|
|||||||
histogram = await c.fee_histogram()
|
histogram = await c.fee_histogram()
|
||||||
estimates = {
|
estimates = {
|
||||||
str(blocks): fee
|
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
|
if fee >= 0
|
||||||
}
|
}
|
||||||
return FeeResponse(estimates=estimates, histogram=histogram)
|
return FeeResponse(estimates=estimates, histogram=histogram)
|
||||||
except ElectrumError as e:
|
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}")
|
@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)
|
raw_hex = await c.get_transaction(txid, verbose=False)
|
||||||
return parse_raw_tx(raw_hex)
|
return parse_raw_tx(raw_hex)
|
||||||
except ElectrumError as e:
|
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}")
|
@blockexplorer_router.get("/address/{address}")
|
||||||
@@ -82,7 +82,7 @@ async def api_address(address: str) -> AddressResponse:
|
|||||||
try:
|
try:
|
||||||
scripthash = scripthash_from_address(address)
|
scripthash = scripthash_from_address(address)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise HTTPException(HTTPStatus.BAD_REQUEST, detail=str(e))
|
raise HTTPException(HTTPStatus.BAD_REQUEST, detail=str(e)) from e
|
||||||
try:
|
try:
|
||||||
async with _client() as c:
|
async with _client() as c:
|
||||||
balance, history = await asyncio.gather(
|
balance, history = await asyncio.gather(
|
||||||
@@ -91,4 +91,4 @@ async def api_address(address: str) -> AddressResponse:
|
|||||||
)
|
)
|
||||||
return AddressResponse(balance=balance, history=history)
|
return AddressResponse(balance=balance, history=history)
|
||||||
except ElectrumError as e:
|
except ElectrumError as e:
|
||||||
raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e))
|
raise HTTPException(HTTPStatus.SERVICE_UNAVAILABLE, detail=str(e)) from e
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def _b58decode_check(s: str) -> bytes:
|
|||||||
|
|
||||||
|
|
||||||
def address_to_scriptpubkey(address: 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()
|
lower = address.lower()
|
||||||
if lower.startswith(("bc1", "tb1", "bcrt1")):
|
if lower.startswith(("bc1", "tb1", "bcrt1")):
|
||||||
_, data = bech32_decode(address)
|
_, 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_count, i = _read_varint(data, i)
|
||||||
vout: list[TxOutput] = []
|
vout: list[TxOutput] = []
|
||||||
for n_out in range(vout_count):
|
for n_out in range(vout_count):
|
||||||
|
|||||||
Reference in New Issue
Block a user