From 7c3b3ac200cbe5518fa66e66266f5935526037ba Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Mon, 31 Jan 2022 11:07:29 +0000 Subject: [PATCH] Fake wallet working --- .env.example | 4 ++++ lnbits/wallets/fake.py | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 7c3d9c0d..53cf79b5 100644 --- a/.env.example +++ b/.env.example @@ -72,3 +72,7 @@ LNTXBOT_KEY=LNTXBOT_ADMIN_KEY # OpenNodeWallet OPENNODE_API_ENDPOINT=https://api.opennode.com/ OPENNODE_KEY=OPENNODE_ADMIN_KEY + +# FakeWallet +FAKE_WALLET_KEY=E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67FC233AA33262 +FAKE_WALLET_ADMIN="" \ No newline at end of file diff --git a/lnbits/wallets/fake.py b/lnbits/wallets/fake.py index f97bf306..1c702a79 100644 --- a/lnbits/wallets/fake.py +++ b/lnbits/wallets/fake.py @@ -8,7 +8,7 @@ import random import string from lnbits.helpers import urlsafe_short_hash import hashlib -from ..bolt11 import encode +from ..bolt11 import encode, decode from .base import ( StatusResponse, InvoiceResponse, @@ -62,19 +62,20 @@ class FakeWallet(Wallet): async def pay_invoice(self, bolt11: str) -> PaymentResponse: - - return "" + invoice = decode(bolt11) + return PaymentResponse(True, invoice.payment_hash, 0) async def get_invoice_status(self, checking_id: str) -> PaymentStatus: - - return "" + return PaymentStatus(True) async def get_payment_status(self, checking_id: str) -> PaymentStatus: - - return "" + return PaymentStatus(True) async def paid_invoices_stream(self) -> AsyncGenerator[str, None]: - yield "" + self.queue = asyncio.Queue(0) + while True: + value = await self.queue.get() + yield value # invoice = "lnbc"