mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-23 03:34:19 +01:00
Dev: Update ruff precommit hooks (#434)
* update ruff * test * update ruff * only ruff check * CI rename
This commit is contained in:
@@ -27,7 +27,8 @@ BLINK_MAX_FEE_PERCENT = 0.5
|
||||
|
||||
|
||||
class BlinkWallet(LightningBackend):
|
||||
"""https://dev.blink.sv/
|
||||
"""
|
||||
https://dev.blink.sv/
|
||||
Create API Key at: https://dashboard.blink.sv/
|
||||
"""
|
||||
|
||||
@@ -54,10 +55,7 @@ class BlinkWallet(LightningBackend):
|
||||
try:
|
||||
r = await self.client.post(
|
||||
url=self.endpoint,
|
||||
data=(
|
||||
'{"query":"query me { me { defaultAccount { wallets { id'
|
||||
' walletCurrency balance }}}}", "variables":{}}'
|
||||
),
|
||||
data=('{"query":"query me { me { defaultAccount { wallets { id' ' walletCurrency balance }}}}", "variables":{}}'),
|
||||
)
|
||||
r.raise_for_status()
|
||||
except Exception as exc:
|
||||
@@ -71,9 +69,7 @@ class BlinkWallet(LightningBackend):
|
||||
resp: dict = r.json()
|
||||
except Exception:
|
||||
return StatusResponse(
|
||||
error_message=(
|
||||
f"Received invalid response from {self.endpoint}: {r.text}"
|
||||
),
|
||||
error_message=(f"Received invalid response from {self.endpoint}: {r.text}"),
|
||||
balance=0,
|
||||
)
|
||||
|
||||
@@ -137,9 +133,7 @@ class BlinkWallet(LightningBackend):
|
||||
|
||||
resp = r.json()
|
||||
assert resp, "invalid response"
|
||||
payment_request = resp["data"]["lnInvoiceCreateOnBehalfOfRecipient"]["invoice"][
|
||||
"paymentRequest"
|
||||
]
|
||||
payment_request = resp["data"]["lnInvoiceCreateOnBehalfOfRecipient"]["invoice"]["paymentRequest"]
|
||||
checking_id = payment_request
|
||||
|
||||
return InvoiceResponse(
|
||||
@@ -148,9 +142,7 @@ class BlinkWallet(LightningBackend):
|
||||
payment_request=payment_request,
|
||||
)
|
||||
|
||||
async def pay_invoice(
|
||||
self, quote: MeltQuote, fee_limit_msat: int
|
||||
) -> PaymentResponse:
|
||||
async def pay_invoice(self, quote: MeltQuote, fee_limit_msat: int) -> PaymentResponse:
|
||||
variables = {
|
||||
"input": {
|
||||
"paymentRequest": quote.request,
|
||||
@@ -185,9 +177,7 @@ class BlinkWallet(LightningBackend):
|
||||
return PaymentResponse(ok=False, error_message=str(e))
|
||||
|
||||
resp: dict = r.json()
|
||||
paid = self.payment_execution_statuses[
|
||||
resp["data"]["lnInvoicePaymentSend"]["status"]
|
||||
]
|
||||
paid = self.payment_execution_statuses[resp["data"]["lnInvoicePaymentSend"]["status"]]
|
||||
fee = resp["data"]["lnInvoicePaymentSend"]["transaction"]["settlementFee"]
|
||||
checking_id = quote.request
|
||||
|
||||
@@ -222,9 +212,7 @@ class BlinkWallet(LightningBackend):
|
||||
return PaymentStatus(paid=None)
|
||||
resp: dict = r.json()
|
||||
if resp["data"]["lnInvoicePaymentStatus"]["errors"]:
|
||||
logger.error(
|
||||
"Blink Error", resp["data"]["lnInvoicePaymentStatus"]["errors"]
|
||||
)
|
||||
logger.error("Blink Error", resp["data"]["lnInvoicePaymentStatus"]["errors"])
|
||||
return PaymentStatus(paid=None)
|
||||
paid = self.invoice_statuses[resp["data"]["lnInvoicePaymentStatus"]["status"]]
|
||||
return PaymentStatus(paid=paid)
|
||||
@@ -267,19 +255,11 @@ class BlinkWallet(LightningBackend):
|
||||
|
||||
resp: dict = r.json()
|
||||
# no result found
|
||||
if not resp["data"]["me"]["defaultAccount"]["walletById"][
|
||||
"transactionsByPaymentHash"
|
||||
]:
|
||||
if not resp["data"]["me"]["defaultAccount"]["walletById"]["transactionsByPaymentHash"]:
|
||||
return PaymentStatus(paid=None)
|
||||
|
||||
paid = self.payment_statuses[
|
||||
resp["data"]["me"]["defaultAccount"]["walletById"][
|
||||
"transactionsByPaymentHash"
|
||||
][0]["status"]
|
||||
]
|
||||
fee = resp["data"]["me"]["defaultAccount"]["walletById"][
|
||||
"transactionsByPaymentHash"
|
||||
][0]["settlementFee"]
|
||||
paid = self.payment_statuses[resp["data"]["me"]["defaultAccount"]["walletById"]["transactionsByPaymentHash"][0]["status"]]
|
||||
fee = resp["data"]["me"]["defaultAccount"]["walletById"]["transactionsByPaymentHash"][0]["settlementFee"]
|
||||
|
||||
return PaymentStatus(
|
||||
paid=paid,
|
||||
@@ -326,9 +306,7 @@ class BlinkWallet(LightningBackend):
|
||||
|
||||
fees_response_msat = int(resp["data"]["lnInvoiceFeeProbe"]["amount"]) * 1000
|
||||
# we either take fee_msat_response or the BLINK_MAX_FEE_PERCENT, whichever is higher
|
||||
fees_msat = max(
|
||||
fees_response_msat, math.ceil(amount_msat * BLINK_MAX_FEE_PERCENT)
|
||||
)
|
||||
fees_msat = max(fees_response_msat, math.ceil(amount_msat * BLINK_MAX_FEE_PERCENT))
|
||||
|
||||
fees = Amount(unit=Unit.msat, amount=fees_msat)
|
||||
amount = Amount(unit=Unit.msat, amount=amount_msat)
|
||||
|
||||
Reference in New Issue
Block a user