From ea5aead2352e49b52d0e83aab4e109d0d5e82a43 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Tue, 4 Oct 2022 23:37:30 +0200 Subject: [PATCH] check Lightning --- README.md | 2 +- cashu/mint/ledger.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0d59f1d..add9593 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ pip install cashu To update Cashu, use `pip install cashu -U`. -If you have problems running the command above on Ubuntu, run `sudo apt install -y pip pkg-config libpq-dev`. On macOS, run `brew install postgresql`. +If you have problems running the command above on Ubuntu, run `sudo apt install -y pip pkg-config`. You can skip the entire next section about Poetry and jump right to [Using Cashu](#using-cashu). diff --git a/cashu/mint/ledger.py b/cashu/mint/ledger.py index 944c653..5419aed 100644 --- a/cashu/mint/ledger.py +++ b/cashu/mint/ledger.py @@ -237,10 +237,13 @@ class Ledger: async def mint(self, B_s: List[PublicKey], amounts: List[int], payment_hash=None): """Mints a promise for coins for B_.""" # check if lightning invoice was paid - if LIGHTNING and ( - payment_hash and not await self._check_lightning_invoice(payment_hash) - ): - raise Exception("Lightning invoice not paid yet.") + if LIGHTNING: + try: + paid = await self._check_lightning_invoice(payment_hash) + except: + raise Exception("could not check invoice.") + if not paid: + raise Exception("Lightning invoice not paid yet.") for amount in amounts: if amount not in [2**i for i in range(MAX_ORDER)]: