mypy fixes.

This commit is contained in:
fiatjaf 2020-10-13 14:46:23 -03:00
parent cf0bd7ece8
commit bcdc065cc0
6 changed files with 13 additions and 16 deletions

View File

@ -1,7 +1,7 @@
import httpx
from typing import Optional, Tuple, Dict
from quart import g
from lnurl import LnurlWithdrawResponse
from lnurl import LnurlWithdrawResponse # type: ignore
try:
from typing import TypedDict # type: ignore
@ -116,7 +116,7 @@ def pay_invoice(
else:
# actually pay the external invoice
payment: PaymentResponse = WALLET.pay_invoice(payment_request)
if payment.ok:
if payment.ok and payment.checking_id:
create_payment(
checking_id=payment.checking_id,
fee=payment.fee_msat,
@ -132,13 +132,10 @@ def pay_invoice(
async def redeem_lnurl_withdraw(wallet_id: str, res: LnurlWithdrawResponse, memo: Optional[str] = None) -> None:
if not memo:
memo = res.default_description
_, payment_request = create_invoice(
wallet_id=wallet_id,
amount=res.max_sats,
memo=memo,
memo=memo or res.default_description or "",
extra={"tag": "lnurlwallet"},
)

View File

@ -347,8 +347,8 @@
{% raw %}
<q-form @submit="payLnurl" class="q-gutter-md">
<p v-if="parse.lnurlpay.fixed" class="q-my-none text-h6">
<b>{{ parse.lnurlpay.domain }}</b> is requesting
{{ parse.lnurlpay.maxSendable | msatoshiFormat }} sat
<b>{{ parse.lnurlpay.domain }}</b> is requesting {{
parse.lnurlpay.maxSendable | msatoshiFormat }} sat
</p>
<p v-else class="q-my-none text-h6 text-center">
<b>{{ parse.lnurlpay.domain }}</b> is requesting <br />

View File

@ -1,6 +1,6 @@
import trio # type: ignore
import json
import lnurl
import lnurl # type: ignore
import httpx
import traceback
from urllib.parse import urlparse, urlunparse, urlencode, parse_qs, ParseResult
@ -306,11 +306,11 @@ async def api_lnurlscan(code: str):
params.update(fixed=data.min_withdrawable == data.max_withdrawable)
# callback with k1 already in it
url: ParseResult = urlparse(data.callback)
qs: Dict = parse_qs(url.query)
parsed_callback: ParseResult = urlparse(data.callback)
qs: Dict = parse_qs(parsed_callback.query)
qs["k1"] = data.k1
url = url._replace(query=urlencode(qs, doseq=True))
params.update(callback=urlunparse(url))
parsed_callback = parsed_callback._replace(query=urlencode(qs, doseq=True))
params.update(callback=urlunparse(parsed_callback))
if type(data) is lnurl.LnurlPayResponse:
params.update(kind="pay")

View File

@ -32,7 +32,7 @@ class PaymentStatus(NamedTuple):
class Wallet(ABC):
@abstractmethod
def status() -> StatusResponse:
def status(self) -> StatusResponse:
pass
@abstractmethod

View File

@ -23,7 +23,7 @@ class LNPayWallet(Wallet):
try:
r = httpx.get(url, headers=self.auth)
except (httpx.ConnectError, httpx.RequestError):
return StatusResponse(f"Unable to connect to '{url}'")
return StatusResponse(f"Unable to connect to '{url}'", 0)
if r.is_error:
return StatusResponse(r.text[:250], 0)

View File

@ -24,7 +24,7 @@ class OpenNodeWallet(Wallet):
try:
r = httpx.get(f"{self.endpoint}/v1/account/balance", headers=self.auth)
except (httpx.ConnectError, httpx.RequestError):
return StatusResponse(f"Unable to connect to '{self.endpoint}'")
return StatusResponse(f"Unable to connect to '{self.endpoint}'", 0)
data = r.json()["message"]
if r.is_error: