Merge pull request #1281 from lnbits/fix/mypy-tpos
FIX: tpos mypy issues
This commit is contained in:
commit
8931cceb97
|
@ -20,10 +20,11 @@ async def wait_for_paid_invoices():
|
|||
|
||||
|
||||
async def on_invoice_paid(payment: Payment) -> None:
|
||||
if not payment.extra:
|
||||
return
|
||||
if payment.extra.get("tag") != "tpos":
|
||||
return
|
||||
|
||||
tpos = await get_tpos(payment.extra.get("tposId"))
|
||||
tipAmount = payment.extra.get("tipAmount")
|
||||
|
||||
strippedPayment = {
|
||||
|
@ -34,14 +35,23 @@ async def on_invoice_paid(payment: Payment) -> None:
|
|||
"bolt11": payment.bolt11,
|
||||
}
|
||||
|
||||
await websocketUpdater(payment.extra.get("tposId"), str(strippedPayment))
|
||||
tpos_id = payment.extra.get("tposId")
|
||||
assert tpos_id
|
||||
|
||||
if tipAmount is None:
|
||||
tpos = await get_tpos(tpos_id)
|
||||
assert tpos
|
||||
|
||||
await websocketUpdater(tpos_id, str(strippedPayment))
|
||||
|
||||
if not tipAmount:
|
||||
# no tip amount
|
||||
return
|
||||
|
||||
wallet_id = tpos.tip_wallet
|
||||
assert wallet_id
|
||||
|
||||
payment_hash, payment_request = await create_invoice(
|
||||
wallet_id=tpos.tip_wallet,
|
||||
wallet_id=wallet_id,
|
||||
amount=int(tipAmount), # sats
|
||||
internal=True,
|
||||
memo=f"tpos tip",
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from http import HTTPStatus
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi.params import Depends
|
||||
from fastapi import Depends, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from starlette.exceptions import HTTPException
|
||||
from starlette.responses import HTMLResponse
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from http import HTTPStatus
|
||||
|
||||
import httpx
|
||||
from fastapi import Query
|
||||
from fastapi.params import Depends
|
||||
from fastapi import Depends, Query
|
||||
from lnurl import decode as decode_lnurl
|
||||
from loguru import logger
|
||||
from starlette.exceptions import HTTPException
|
||||
|
@ -25,7 +24,8 @@ async def api_tposs(
|
|||
):
|
||||
wallet_ids = [wallet.wallet.id]
|
||||
if all_wallets:
|
||||
wallet_ids = (await get_user(wallet.wallet.user)).wallet_ids
|
||||
user = await get_user(wallet.wallet.user)
|
||||
wallet_ids = user.wallet_ids if user else []
|
||||
|
||||
return [tpos.dict() for tpos in await get_tposs(wallet_ids)]
|
||||
|
||||
|
@ -58,8 +58,9 @@ async def api_tpos_delete(
|
|||
|
||||
@tpos_ext.post("/api/v1/tposs/{tpos_id}/invoices", status_code=HTTPStatus.CREATED)
|
||||
async def api_tpos_create_invoice(
|
||||
amount: int = Query(..., ge=1), tipAmount: int = None, tpos_id: str = None
|
||||
):
|
||||
tpos_id: str, amount: int = Query(..., ge=1), tipAmount: int = 0
|
||||
) -> dict:
|
||||
|
||||
tpos = await get_tpos(tpos_id)
|
||||
|
||||
if not tpos:
|
||||
|
@ -67,7 +68,7 @@ async def api_tpos_create_invoice(
|
|||
status_code=HTTPStatus.NOT_FOUND, detail="TPoS does not exist."
|
||||
)
|
||||
|
||||
if tipAmount:
|
||||
if tipAmount > 0:
|
||||
amount += tipAmount
|
||||
|
||||
try:
|
||||
|
@ -84,7 +85,7 @@ async def api_tpos_create_invoice(
|
|||
|
||||
|
||||
@tpos_ext.get("/api/v1/tposs/{tpos_id}/invoices")
|
||||
async def api_tpos_get_latest_invoices(tpos_id: str = None):
|
||||
async def api_tpos_get_latest_invoices(tpos_id: str):
|
||||
try:
|
||||
payments = [
|
||||
Payment.from_row(row)
|
||||
|
@ -111,7 +112,7 @@ async def api_tpos_get_latest_invoices(tpos_id: str = None):
|
|||
"/api/v1/tposs/{tpos_id}/invoices/{payment_request}/pay", status_code=HTTPStatus.OK
|
||||
)
|
||||
async def api_tpos_pay_invoice(
|
||||
lnurl_data: PayLnurlWData, payment_request: str = None, tpos_id: str = None
|
||||
lnurl_data: PayLnurlWData, payment_request: str, tpos_id: str
|
||||
):
|
||||
tpos = await get_tpos(tpos_id)
|
||||
|
||||
|
|
|
@ -100,7 +100,6 @@ exclude = """(?x)(
|
|||
| ^lnbits/extensions/offlineshop.
|
||||
| ^lnbits/extensions/satspay.
|
||||
| ^lnbits/extensions/streamalerts.
|
||||
| ^lnbits/extensions/tpos.
|
||||
| ^lnbits/extensions/watchonly.
|
||||
| ^lnbits/extensions/withdraw.
|
||||
| ^lnbits/wallets/lnd_grpc_files.
|
||||
|
|
Loading…
Reference in New Issue
Block a user