mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-14 02:41:06 +02:00
FEAT: proper failing invoice/payment responses for VoidWallet (#1805)
before that change anyone using the api just got a 500 error without any error message. there was also a bug stacetrace in the logs each time. flake8
This commit is contained in:
parent
427f155c76
commit
6ce0387e1c
@ -1,4 +1,4 @@
|
|||||||
from typing import AsyncGenerator, Optional
|
from typing import AsyncGenerator
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
@ -7,20 +7,15 @@ from .base import (
|
|||||||
PaymentResponse,
|
PaymentResponse,
|
||||||
PaymentStatus,
|
PaymentStatus,
|
||||||
StatusResponse,
|
StatusResponse,
|
||||||
Unsupported,
|
|
||||||
Wallet,
|
Wallet,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class VoidWallet(Wallet):
|
class VoidWallet(Wallet):
|
||||||
async def create_invoice(
|
async def create_invoice(self, *_, **__) -> InvoiceResponse:
|
||||||
self,
|
return InvoiceResponse(
|
||||||
amount: int,
|
ok=False, error_message="VoidWallet cannot create invoices."
|
||||||
memo: Optional[str] = None,
|
)
|
||||||
description_hash: Optional[bytes] = None,
|
|
||||||
**kwargs,
|
|
||||||
) -> InvoiceResponse:
|
|
||||||
raise Unsupported("")
|
|
||||||
|
|
||||||
async def status(self) -> StatusResponse:
|
async def status(self) -> StatusResponse:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
@ -31,13 +26,15 @@ class VoidWallet(Wallet):
|
|||||||
)
|
)
|
||||||
return StatusResponse(None, 0)
|
return StatusResponse(None, 0)
|
||||||
|
|
||||||
async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:
|
async def pay_invoice(self, *_, **__) -> PaymentResponse:
|
||||||
raise Unsupported("")
|
return PaymentResponse(
|
||||||
|
ok=False, error_message="VoidWallet cannot pay invoices."
|
||||||
|
)
|
||||||
|
|
||||||
async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
|
async def get_invoice_status(self, *_, **__) -> PaymentStatus:
|
||||||
return PaymentStatus(None)
|
return PaymentStatus(None)
|
||||||
|
|
||||||
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
async def get_payment_status(self, *_, **__) -> PaymentStatus:
|
||||||
return PaymentStatus(None)
|
return PaymentStatus(None)
|
||||||
|
|
||||||
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user