From 91c5a68cccb254665318adbf128f36e39dda1292 Mon Sep 17 00:00:00 2001 From: dni Date: Tue, 19 Jul 2022 19:20:20 +0200 Subject: [PATCH] mypy fakewallet, macaroon, bolt11 invoice --- lnbits/bolt11.py | 1 + lnbits/wallets/fake.py | 10 +++++++--- lnbits/wallets/macaroon/macaroon.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lnbits/bolt11.py b/lnbits/bolt11.py index cc8415852..cc8c60401 100644 --- a/lnbits/bolt11.py +++ b/lnbits/bolt11.py @@ -23,6 +23,7 @@ class Route(NamedTuple): class Invoice(object): payment_hash: str + checking_id: Optional[str] = None amount_msat: int = 0 description: Optional[str] = None description_hash: Optional[str] = None diff --git a/lnbits/wallets/fake.py b/lnbits/wallets/fake.py index 3859d33c5..c2b2307ab 100644 --- a/lnbits/wallets/fake.py +++ b/lnbits/wallets/fake.py @@ -28,7 +28,7 @@ class FakeWallet(Wallet): logger.info( "FakeWallet funding source is for using LNbits as a centralised, stand-alone payment system with brrrrrr." ) - return StatusResponse(None, float("inf")) + return StatusResponse(None, 1000000000) async def create_invoice( self, @@ -80,8 +80,12 @@ class FakeWallet(Wallet): async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse: invoice = decode(bolt11) + # TODO: no data here? + data: Dict = { + "privkey": "missing" + } if ( - hasattr(invoice, "checking_id") + invoice.checking_id is not None and invoice.checking_id[6:] == data["privkey"][:6] ): return PaymentResponse(True, invoice.payment_hash, 0) @@ -97,7 +101,7 @@ class FakeWallet(Wallet): return PaymentStatus(None) async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: - self.queue = asyncio.Queue(0) + self.queue: asyncio.Queue = asyncio.Queue(0) while True: value = await self.queue.get() yield value diff --git a/lnbits/wallets/macaroon/macaroon.py b/lnbits/wallets/macaroon/macaroon.py index 2183dacb8..aa00cd3e6 100644 --- a/lnbits/wallets/macaroon/macaroon.py +++ b/lnbits/wallets/macaroon/macaroon.py @@ -73,7 +73,7 @@ class AESCipher(object): final_key += key return final_key[:output] - def decrypt(self, encrypted: str) -> str: + def decrypt(self, encrypted) -> str: """Decrypts a string using AES-256-CBC.""" passphrase = self.passphrase encrypted = base64.b64decode(encrypted)