2% reserve only for external payments
This commit is contained in:
parent
32ea1106f9
commit
cdeccec01b
1 changed files with 12 additions and 8 deletions
|
|
@ -96,8 +96,6 @@ async def pay_invoice(
|
||||||
raise ValueError("Amount in invoice is too high.")
|
raise ValueError("Amount in invoice is too high.")
|
||||||
|
|
||||||
wallet = await get_wallet(wallet_id, conn=conn)
|
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
|
# put all parameters that don't change here
|
||||||
PaymentKwargs = TypedDict(
|
PaymentKwargs = TypedDict(
|
||||||
|
|
@ -141,11 +139,17 @@ async def pay_invoice(
|
||||||
**payment_kwargs,
|
**payment_kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
# do the balance check
|
# do the balance check if internal payment
|
||||||
wallet = await get_wallet(wallet_id, conn=conn)
|
if internal_checking_id:
|
||||||
assert wallet
|
wallet = await get_wallet(wallet_id, conn=conn)
|
||||||
if wallet.balance_msat < 0:
|
assert wallet
|
||||||
raise PermissionError("Insufficient balance.")
|
if wallet.balance_msat < 0:
|
||||||
|
raise PermissionError("Insufficient balance.")
|
||||||
|
|
||||||
|
# do the balance check if external payment
|
||||||
|
else:
|
||||||
|
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.")
|
||||||
|
|
||||||
if internal_checking_id:
|
if internal_checking_id:
|
||||||
# mark the invoice from the other side as not pending anymore
|
# mark the invoice from the other side as not pending anymore
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue