mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-02 08:58:33 +02:00
Core: reserve fee as an .env variable (#631)
* reserve fee as an .env variable * fixed bad import * Update .env.example Co-authored-by: calle <93376500+callebtc@users.noreply.github.com> * Update lnbits/core/services.py Co-authored-by: calle <93376500+callebtc@users.noreply.github.com> * Update lnbits/core/services.py Co-authored-by: calle <93376500+callebtc@users.noreply.github.com> * Update lnbits/settings.py Co-authored-by: calle <93376500+callebtc@users.noreply.github.com> * variable consistent names * fix services.py variable names * percent default fix * Update lnbits/settings.py int to float * Update lnbits/settings.py int to float * Update .env.example int to float * make format * fixed failing bleskomat test, expecting 2000 msats fee * Update tests/extensions/bleskomat/test_lnurl_api.py revert to 2 sat * Update .env.example * Update lnbits/settings.py Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
parent
d989441587
commit
197ff7d054
@ -25,6 +25,8 @@ LNBITS_DATA_FOLDER="./data"
|
||||
|
||||
LNBITS_FORCE_HTTPS=true
|
||||
LNBITS_SERVICE_FEE="0.0"
|
||||
LNBITS_RESERVE_FEE_MIN=2000 # value in millisats
|
||||
LNBITS_RESERVE_FEE_PERCENT=1.0 # value in percent
|
||||
|
||||
# Change theme
|
||||
LNBITS_SITE_TITLE="LNbits"
|
||||
|
@ -21,7 +21,7 @@ from lnbits.decorators import (
|
||||
)
|
||||
from lnbits.helpers import url_for, urlsafe_short_hash
|
||||
from lnbits.requestvars import g
|
||||
from lnbits.settings import FAKE_WALLET, WALLET
|
||||
from lnbits.settings import FAKE_WALLET, RESERVE_FEE_MIN, RESERVE_FEE_PERCENT, WALLET
|
||||
from lnbits.wallets.base import PaymentResponse, PaymentStatus
|
||||
|
||||
from . import db
|
||||
@ -160,7 +160,7 @@ async def pay_invoice(
|
||||
logger.debug("balance is too low, deleting temporary payment")
|
||||
if not internal_checking_id and wallet.balance_msat > -fee_reserve_msat:
|
||||
raise PaymentFailure(
|
||||
f"You must reserve at least 1% ({round(fee_reserve_msat/1000)} sat) to cover potential routing fees."
|
||||
f"You must reserve at least ({round(fee_reserve_msat/1000)} sat) to cover potential routing fees."
|
||||
)
|
||||
raise PermissionError("Insufficient balance.")
|
||||
|
||||
@ -366,4 +366,4 @@ async def check_transaction_status(
|
||||
|
||||
# WARN: this same value must be used for balance check and passed to WALLET.pay_invoice(), it may cause a vulnerability if the values differ
|
||||
def fee_reserve(amount_msat: int) -> int:
|
||||
return max(2000, int(amount_msat * 0.01))
|
||||
return max(int(RESERVE_FEE_MIN), int(amount_msat * RESERVE_FEE_PERCENT / 100.0))
|
||||
|
@ -55,6 +55,8 @@ FAKE_WALLET = getattr(wallets_module, "FakeWallet")()
|
||||
DEFAULT_WALLET_NAME = env.str("LNBITS_DEFAULT_WALLET_NAME", default="LNbits wallet")
|
||||
PREFER_SECURE_URLS = env.bool("LNBITS_FORCE_HTTPS", default=True)
|
||||
|
||||
RESERVE_FEE_MIN = env.int("LNBITS_RESERVE_FEE_MIN", default=2000)
|
||||
RESERVE_FEE_PERCENT = env.float("LNBITS_RESERVE_FEE_PERCENT", default=1.0)
|
||||
SERVICE_FEE = env.float("LNBITS_SERVICE_FEE", default=0.0)
|
||||
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user