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:
dni ⚡ 2023-07-25 15:13:34 +02:00 committed by GitHub
parent 427f155c76
commit 6ce0387e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
from typing import AsyncGenerator, Optional
from typing import AsyncGenerator
from loguru import logger
@ -7,20 +7,15 @@ from .base import (
PaymentResponse,
PaymentStatus,
StatusResponse,
Unsupported,
Wallet,
)
class VoidWallet(Wallet):
async def create_invoice(
self,
amount: int,
memo: Optional[str] = None,
description_hash: Optional[bytes] = None,
**kwargs,
) -> InvoiceResponse:
raise Unsupported("")
async def create_invoice(self, *_, **__) -> InvoiceResponse:
return InvoiceResponse(
ok=False, error_message="VoidWallet cannot create invoices."
)
async def status(self) -> StatusResponse:
logger.warning(
@ -31,13 +26,15 @@ class VoidWallet(Wallet):
)
return StatusResponse(None, 0)
async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:
raise Unsupported("")
async def pay_invoice(self, *_, **__) -> PaymentResponse:
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)
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
async def get_payment_status(self, *_, **__) -> PaymentStatus:
return PaymentStatus(None)
async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: