prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Switching to `FakeWallet` deletes pending outgoing payments from another backend.
  Needs investigation.
  
  What I observed: create outgoing pending payment from other wallet, stop LNbits, change to `FakeWallet`, start LNbits. 
  
  -> Payments get deleted because of a `failed` state that is returned in `lnbits.core.models:check_pending:148`.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `lnbits/wallets/fake.py`
  Content:
  ```
  1 import asyncio
  2 import hashlib
  3 import random
  4 from datetime import datetime
  5 from os import getenv
  6 from typing import AsyncGenerator, Dict, Optional
  7 
  8 from environs import Env  # type: ignore
  9 from loguru import logger
  10 
  11 from lnbits.helpers import urlsafe_short_hash
  12 
  13 from ..bolt11 import decode, encode
  14 from .base import (
  15     InvoiceResponse,
  16     PaymentResponse,
  17     PaymentStatus,
  18     StatusResponse,
  19     Wallet,
  20 )
  21 
  22 env = Env()
  23 env.read_env()
  24 
  25 
  26 class FakeWallet(Wallet):
  27     async def status(self) -> StatusResponse:
  28         logger.info(
  29             "FakeWallet funding source is for using LNbits as a centralised, stand-alone payment system with brrrrrr."
  30         )
  31         return StatusResponse(None, float("inf"))
  32 
  33     async def create_invoice(
  34         self,
  35         amount: int,
  36         memo: Optional[str] = None,
  37         description_hash: Optional[bytes] = None,
  38     ) -> InvoiceResponse:
  39         # we set a default secret since FakeWallet is used for internal=True invoices
  40         # and the user might not have configured a secret yet
  41         secret = env.str("FAKE_WALLET_SECTRET", default="ToTheMoon1")
  42         data: Dict = {
  43             "out": False,
  44             "amount": amount,
  45             "currency": "bc",
  46             "privkey": hashlib.pbkdf2_hmac(
  47                 "sha256",
  48                 secret.encode("utf-8"),
  49                 ("FakeWallet").encode("utf-8"),
  50                 2048,
  51                 32,
  52             ).hex(),
  53             "memo": None,
  54             "description_hash": None,
  55             "description": "",
  56             "fallback": None,
  57             "expires": None,
  58             "route": None,
  59         }
  60         data["amount"] = amount * 1000
  61         data["timestamp"] = datetime.now().timestamp()
  62         if description_hash:
  63             data["tags_set"] = ["h"]
  64             data["description_hash"] = description_hash.hex()
  65         else:
  66             data["tags_set"] = ["d"]
  67             data["memo"] = memo
  68             data["description"] = memo
  69         randomHash = (
  70             data["privkey"][:6]
  71             + hashlib.sha256(str(random.getrandbits(256)).encode("utf-8")).hexdigest()[
  72                 6:
  73             ]
  74         )
  75         data["paymenthash"] = randomHash
  76         payment_request = encode(data)
  77         checking_id = randomHash
  78 
  79         return InvoiceResponse(True, checking_id, payment_request)
  80 
  81     async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:
  82         invoice = decode(bolt11)
  83         if (
  84             hasattr(invoice, "checking_id")
  85             and invoice.checking_id[6:] == data["privkey"][:6]
  86         ):
  87             return PaymentResponse(True, invoice.payment_hash, 0)
  88         else:
  89             return PaymentResponse(
  90                 ok=False, error_message="Only internal invoices can be used!"
  91             )
  92 
  93     async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
  94         return PaymentStatus(False)
  95 
  96     async def get_payment_status(self, checking_id: str) -> PaymentStatus:
  97         return PaymentStatus(False)
  98 
  99     async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
  100         self.queue = asyncio.Queue(0)
  101         while True:
  102             value = await self.queue.get()
  103             yield value
  104
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/lnbits/wallets/fake.py b/lnbits/wallets/fake.py
  --- a/lnbits/wallets/fake.py
  +++ b/lnbits/wallets/fake.py
  @@ -91,10 +91,10 @@
               )
   
       async def get_invoice_status(self, checking_id: str) -> PaymentStatus:
  -        return PaymentStatus(False)
  +        return PaymentStatus(None)
   
       async def get_payment_status(self, checking_id: str) -> PaymentStatus:
  -        return PaymentStatus(False)
  +        return PaymentStatus(None)
   
       async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:
           self.queue = asyncio.Queue(0)
  
verification_info: {"golden_diff": "diff --git a/lnbits/wallets/fake.py b/lnbits/wallets/fake.py\n--- a/lnbits/wallets/fake.py\n+++ b/lnbits/wallets/fake.py\n@@ -91,10 +91,10 @@\n             )\n \n     async def get_invoice_status(self, checking_id: str) -> PaymentStatus:\n-        return PaymentStatus(False)\n+        return PaymentStatus(None)\n \n     async def get_payment_status(self, checking_id: str) -> PaymentStatus:\n-        return PaymentStatus(False)\n+        return PaymentStatus(None)\n \n     async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:\n         self.queue = asyncio.Queue(0)\n", "issue": "Switching to `FakeWallet` deletes pending outgoing payments from another backend.\nNeeds investigation.\r\n\r\nWhat I observed: create outgoing pending payment from other wallet, stop LNbits, change to `FakeWallet`, start LNbits. \r\n\r\n-> Payments get deleted because of a `failed` state that is returned in `lnbits.core.models:check_pending:148`.\n", "before_files": [{"content": "import asyncio\nimport hashlib\nimport random\nfrom datetime import datetime\nfrom os import getenv\nfrom typing import AsyncGenerator, Dict, Optional\n\nfrom environs import Env  # type: ignore\nfrom loguru import logger\n\nfrom lnbits.helpers import urlsafe_short_hash\n\nfrom ..bolt11 import decode, encode\nfrom .base import (\n    InvoiceResponse,\n    PaymentResponse,\n    PaymentStatus,\n    StatusResponse,\n    Wallet,\n)\n\nenv = Env()\nenv.read_env()\n\n\nclass FakeWallet(Wallet):\n    async def status(self) -> StatusResponse:\n        logger.info(\n            \"FakeWallet funding source is for using LNbits as a centralised, stand-alone payment system with brrrrrr.\"\n        )\n        return StatusResponse(None, float(\"inf\"))\n\n    async def create_invoice(\n        self,\n        amount: int,\n        memo: Optional[str] = None,\n        description_hash: Optional[bytes] = None,\n    ) -> InvoiceResponse:\n        # we set a default secret since FakeWallet is used for internal=True invoices\n        # and the user might not have configured a secret yet\n        secret = env.str(\"FAKE_WALLET_SECTRET\", default=\"ToTheMoon1\")\n        data: Dict = {\n            \"out\": False,\n            \"amount\": amount,\n            \"currency\": \"bc\",\n            \"privkey\": hashlib.pbkdf2_hmac(\n                \"sha256\",\n                secret.encode(\"utf-8\"),\n                (\"FakeWallet\").encode(\"utf-8\"),\n                2048,\n                32,\n            ).hex(),\n            \"memo\": None,\n            \"description_hash\": None,\n            \"description\": \"\",\n            \"fallback\": None,\n            \"expires\": None,\n            \"route\": None,\n        }\n        data[\"amount\"] = amount * 1000\n        data[\"timestamp\"] = datetime.now().timestamp()\n        if description_hash:\n            data[\"tags_set\"] = [\"h\"]\n            data[\"description_hash\"] = description_hash.hex()\n        else:\n            data[\"tags_set\"] = [\"d\"]\n            data[\"memo\"] = memo\n            data[\"description\"] = memo\n        randomHash = (\n            data[\"privkey\"][:6]\n            + hashlib.sha256(str(random.getrandbits(256)).encode(\"utf-8\")).hexdigest()[\n                6:\n            ]\n        )\n        data[\"paymenthash\"] = randomHash\n        payment_request = encode(data)\n        checking_id = randomHash\n\n        return InvoiceResponse(True, checking_id, payment_request)\n\n    async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:\n        invoice = decode(bolt11)\n        if (\n            hasattr(invoice, \"checking_id\")\n            and invoice.checking_id[6:] == data[\"privkey\"][:6]\n        ):\n            return PaymentResponse(True, invoice.payment_hash, 0)\n        else:\n            return PaymentResponse(\n                ok=False, error_message=\"Only internal invoices can be used!\"\n            )\n\n    async def get_invoice_status(self, checking_id: str) -> PaymentStatus:\n        return PaymentStatus(False)\n\n    async def get_payment_status(self, checking_id: str) -> PaymentStatus:\n        return PaymentStatus(False)\n\n    async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:\n        self.queue = asyncio.Queue(0)\n        while True:\n            value = await self.queue.get()\n            yield value\n", "path": "lnbits/wallets/fake.py"}], "after_files": [{"content": "import asyncio\nimport hashlib\nimport random\nfrom datetime import datetime\nfrom os import getenv\nfrom typing import AsyncGenerator, Dict, Optional\n\nfrom environs import Env  # type: ignore\nfrom loguru import logger\n\nfrom lnbits.helpers import urlsafe_short_hash\n\nfrom ..bolt11 import decode, encode\nfrom .base import (\n    InvoiceResponse,\n    PaymentResponse,\n    PaymentStatus,\n    StatusResponse,\n    Wallet,\n)\n\nenv = Env()\nenv.read_env()\n\n\nclass FakeWallet(Wallet):\n    async def status(self) -> StatusResponse:\n        logger.info(\n            \"FakeWallet funding source is for using LNbits as a centralised, stand-alone payment system with brrrrrr.\"\n        )\n        return StatusResponse(None, float(\"inf\"))\n\n    async def create_invoice(\n        self,\n        amount: int,\n        memo: Optional[str] = None,\n        description_hash: Optional[bytes] = None,\n    ) -> InvoiceResponse:\n        # we set a default secret since FakeWallet is used for internal=True invoices\n        # and the user might not have configured a secret yet\n        secret = env.str(\"FAKE_WALLET_SECTRET\", default=\"ToTheMoon1\")\n        data: Dict = {\n            \"out\": False,\n            \"amount\": amount,\n            \"currency\": \"bc\",\n            \"privkey\": hashlib.pbkdf2_hmac(\n                \"sha256\",\n                secret.encode(\"utf-8\"),\n                (\"FakeWallet\").encode(\"utf-8\"),\n                2048,\n                32,\n            ).hex(),\n            \"memo\": None,\n            \"description_hash\": None,\n            \"description\": \"\",\n            \"fallback\": None,\n            \"expires\": None,\n            \"route\": None,\n        }\n        data[\"amount\"] = amount * 1000\n        data[\"timestamp\"] = datetime.now().timestamp()\n        if description_hash:\n            data[\"tags_set\"] = [\"h\"]\n            data[\"description_hash\"] = description_hash.hex()\n        else:\n            data[\"tags_set\"] = [\"d\"]\n            data[\"memo\"] = memo\n            data[\"description\"] = memo\n        randomHash = (\n            data[\"privkey\"][:6]\n            + hashlib.sha256(str(random.getrandbits(256)).encode(\"utf-8\")).hexdigest()[\n                6:\n            ]\n        )\n        data[\"paymenthash\"] = randomHash\n        payment_request = encode(data)\n        checking_id = randomHash\n\n        return InvoiceResponse(True, checking_id, payment_request)\n\n    async def pay_invoice(self, bolt11: str, fee_limit_msat: int) -> PaymentResponse:\n        invoice = decode(bolt11)\n        if (\n            hasattr(invoice, \"checking_id\")\n            and invoice.checking_id[6:] == data[\"privkey\"][:6]\n        ):\n            return PaymentResponse(True, invoice.payment_hash, 0)\n        else:\n            return PaymentResponse(\n                ok=False, error_message=\"Only internal invoices can be used!\"\n            )\n\n    async def get_invoice_status(self, checking_id: str) -> PaymentStatus:\n        return PaymentStatus(None)\n\n    async def get_payment_status(self, checking_id: str) -> PaymentStatus:\n        return PaymentStatus(None)\n\n    async def paid_invoices_stream(self) -> AsyncGenerator[str, None]:\n        self.queue = asyncio.Queue(0)\n        while True:\n            value = await self.queue.get()\n            yield value\n", "path": "lnbits/wallets/fake.py"}]}