diff --git a/mint/ledger.py b/mint/ledger.py index d1adcc1..c9aca62 100644 --- a/mint/ledger.py +++ b/mint/ledger.py @@ -155,13 +155,13 @@ class Ledger: await update_lightning_invoice(payment_hash, issued=True, db=self.db) return status.paid - async def _pay_lightning_invoice(self, invoice): + async def _pay_lightning_invoice(self, invoice, amount): """Returns an invoice from the Lightning backend.""" error, balance = await WALLET.status() if error: raise Exception(f"Lightning wallet not responding: {error}") ok, checking_id, fee_msat, preimage, error_message = await WALLET.pay_invoice( - invoice, fee_limit_msat=10 + invoice, fee_limit_msat=amount * (1 - LIGHTNING_FEE) ) return ok, preimage @@ -217,7 +217,7 @@ class Ledger: "provided proofs not enough for Lightning payment." ) - status, preimage = await self._pay_lightning_invoice(invoice) + status, preimage = await self._pay_lightning_invoice(invoice, amount) if status == True: await self._invalidate_proofs(proofs) return status, preimage diff --git a/wallet/cashu.py b/wallet/cashu.py index b601461..e8f2667 100755 --- a/wallet/cashu.py +++ b/wallet/cashu.py @@ -72,7 +72,10 @@ async def mint(ctx, amount: int, hash: str): if "pr" in r: print(f"Pay this invoice to mint {amount} sat:") print(f"Invoice: {r['pr']}") - print(f"Hash: {r['hash']}") + print("") + print( + f"After paying the invoice, run this command:\ncashu mint {amount} --hash {r['hash']}" + ) elif amount and hash: await wallet.mint(amount, hash) wallet.status() @@ -142,7 +145,7 @@ async def pay(ctx, invoice: str): decoded_invoice.amount_msat / 1000 * LIGHTNING_FEE ) # 1% fee for Lightning print( - f"Paying Lightning invoice of {decoded_invoice.amount_msat // 1000} sat ({amount} sat with fees)" + f"Paying Lightning invoice of {decoded_invoice.amount_msat // 1000} sat ({amount} sat incl. fees)" ) assert amount > 0, "amount is not positive" if wallet.available_balance < amount: