From 907714838bc921cac0dda732b462792705b13884 Mon Sep 17 00:00:00 2001 From: benarc Date: Thu, 2 Dec 2021 21:22:30 +0000 Subject: [PATCH] Added check to explain fee reserve --- lnbits/core/services.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lnbits/core/services.py b/lnbits/core/services.py index 1fd8a5932..f4570c7f6 100644 --- a/lnbits/core/services.py +++ b/lnbits/core/services.py @@ -95,6 +95,10 @@ async def pay_invoice( if max_sat and invoice.amount_msat > max_sat * 1000: raise ValueError("Amount in invoice is too high.") + wallet = await get_wallet(wallet_id, conn=conn) + if invoice.amount_msat > wallet.balance_msat - (wallet.balance_msat / 100 * 2): + raise PermissionError("LNbits requires you keep at least 2% reserve to cover potential routing fees.") + # put all parameters that don't change here PaymentKwargs = TypedDict( "PaymentKwargs",