From f08fbc2487948ef2fce951c5f55fa9bf714b76ff Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 10 May 2022 21:48:24 +0200 Subject: [PATCH 1/2] core: check_invoice_status for outgoing payments --- lnbits/core/services.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 3d54e218d..875f7644c 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -321,7 +321,10 @@ async def check_invoice_status( payment = await get_wallet_payment(wallet_id, payment_hash, conn=conn) if not payment: return PaymentStatus(None) - status = await WALLET.get_invoice_status(payment.checking_id) + if payment.is_out: + status = await WALLET.get_payment_status(payment.checking_id) + else: + status = await WALLET.get_invoice_status(payment.checking_id) if not payment.pending: return status if payment.is_out and status.failed: From ebd6d6d58b7b54d9171d0bd303b80a86525a264d Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 10 May 2022 22:00:50 +0200 Subject: [PATCH 2/2] key check --- lnbits/core/views/api.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 0e88b5c85..ff46f29ee 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -365,14 +365,13 @@ async def api_payments_sse( @core_app.get("/api/v1/payments/{payment_hash}") async def api_payment(payment_hash, X_Api_Key: Optional[str] = Header(None)): - wallet = None - try: - if X_Api_Key.extra: - print("No key") - except: + if X_Api_Key is not None: wallet = await get_wallet_for_key(X_Api_Key) + else: + wallet = None payment = await get_standalone_payment(payment_hash) - await check_invoice_status(payment.wallet_id, payment_hash) + if payment: + await check_invoice_status(payment.wallet_id, payment_hash) payment = await get_standalone_payment(payment_hash) if not payment: raise HTTPException(