feat: remove FEE_RESERVE
This commit is contained in:
parent
5806beaeb7
commit
efb9deb028
|
@ -2,9 +2,10 @@ FLASK_APP=lnbits
|
||||||
FLASK_ENV=development
|
FLASK_ENV=development
|
||||||
|
|
||||||
LNBITS_SITE_TITLE=LNbits
|
LNBITS_SITE_TITLE=LNbits
|
||||||
LNBITS_WITH_ONION=0
|
|
||||||
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
|
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
|
||||||
LNBITS_FEE_RESERVE=0
|
LNBITS_DATA_FOLDER="/your_custom_data_folder"
|
||||||
|
LNBITS_SERVICE_FEE="0.0"
|
||||||
|
LNBITS_WITH_ONION=0
|
||||||
|
|
||||||
# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet, CLightningWallet, LnbitsWallet
|
# Choose from LNPayWallet, OpenNodeWallet, LntxbotWallet, LndWallet, CLightningWallet, LnbitsWallet
|
||||||
LNBITS_BACKEND_WALLET_CLASS=LntxbotWallet
|
LNBITS_BACKEND_WALLET_CLASS=LntxbotWallet
|
||||||
|
|
|
@ -2,7 +2,7 @@ from typing import List, Optional
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from lnbits.db import open_db
|
from lnbits.db import open_db
|
||||||
from lnbits.settings import DEFAULT_WALLET_NAME, FEE_RESERVE
|
from lnbits.settings import DEFAULT_WALLET_NAME
|
||||||
|
|
||||||
from .models import User, Wallet, Payment
|
from .models import User, Wallet, Payment
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ def get_user(user_id: str) -> Optional[User]:
|
||||||
extensions = db.fetchall("SELECT extension FROM extensions WHERE user = ? AND active = 1", (user_id,))
|
extensions = db.fetchall("SELECT extension FROM extensions WHERE user = ? AND active = 1", (user_id,))
|
||||||
wallets = db.fetchall(
|
wallets = db.fetchall(
|
||||||
"""
|
"""
|
||||||
SELECT *, COALESCE((SELECT balance FROM balances WHERE wallet = wallets.id), 0) * ? AS balance_msat
|
SELECT *, COALESCE((SELECT balance FROM balances WHERE wallet = wallets.id), 0) AS balance_msat
|
||||||
FROM wallets
|
FROM wallets
|
||||||
WHERE user = ?
|
WHERE user = ?
|
||||||
""",
|
""",
|
||||||
(1 - FEE_RESERVE, user_id),
|
(user_id,),
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -96,11 +96,11 @@ def get_wallet(wallet_id: str) -> Optional[Wallet]:
|
||||||
with open_db() as db:
|
with open_db() as db:
|
||||||
row = db.fetchone(
|
row = db.fetchone(
|
||||||
"""
|
"""
|
||||||
SELECT *, COALESCE((SELECT balance FROM balances WHERE wallet = wallets.id), 0) * ? AS balance_msat
|
SELECT *, COALESCE((SELECT balance FROM balances WHERE wallet = wallets.id), 0) AS balance_msat
|
||||||
FROM wallets
|
FROM wallets
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
""",
|
""",
|
||||||
(1 - FEE_RESERVE, wallet_id),
|
(wallet_id,),
|
||||||
)
|
)
|
||||||
|
|
||||||
return Wallet(**row) if row else None
|
return Wallet(**row) if row else None
|
||||||
|
@ -111,11 +111,11 @@ def get_wallet_for_key(key: str, key_type: str = "invoice") -> Optional[Wallet]:
|
||||||
check_field = "adminkey" if key_type == "admin" else "inkey"
|
check_field = "adminkey" if key_type == "admin" else "inkey"
|
||||||
row = db.fetchone(
|
row = db.fetchone(
|
||||||
f"""
|
f"""
|
||||||
SELECT *, COALESCE((SELECT balance FROM balances WHERE wallet = wallets.id), 0) * ? AS balance_msat
|
SELECT *, COALESCE((SELECT balance FROM balances WHERE wallet = wallets.id), 0) AS balance_msat
|
||||||
FROM wallets
|
FROM wallets
|
||||||
WHERE {check_field} = ?
|
WHERE {check_field} = ?
|
||||||
""",
|
""",
|
||||||
(1 - FEE_RESERVE, key),
|
(key,),
|
||||||
)
|
)
|
||||||
|
|
||||||
return Wallet(**row) if row else None
|
return Wallet(**row) if row else None
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
from lnbits.bolt11 import decode as bolt11_decode
|
from lnbits.bolt11 import decode as bolt11_decode
|
||||||
from lnbits.settings import WALLET, FEE_RESERVE
|
from lnbits.settings import WALLET
|
||||||
|
|
||||||
from .crud import create_payment
|
from .crud import create_payment
|
||||||
from .models import Wallet
|
from .models import Wallet
|
||||||
|
@ -38,11 +38,7 @@ def pay_invoice(*, wallet: Wallet, bolt11: str, max_sat: Optional[int] = None) -
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
create_payment(
|
create_payment(
|
||||||
wallet_id=wallet.id,
|
wallet_id=wallet.id, checking_id=checking_id, amount=-invoice.amount_msat, memo=invoice.description
|
||||||
checking_id=checking_id,
|
|
||||||
amount=-invoice.amount_msat,
|
|
||||||
memo=invoice.description,
|
|
||||||
fee=-invoice.amount_msat * FEE_RESERVE,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
|
|
||||||
wallets_module = importlib.import_module("lnbits.wallets")
|
wallets_module = importlib.import_module("lnbits.wallets")
|
||||||
wallet_class = getattr(wallets_module, os.getenv("LNBITS_BACKEND_WALLET_CLASS", "LntxbotWallet"))
|
wallet_class = getattr(wallets_module, os.getenv("LNBITS_BACKEND_WALLET_CLASS", "LntxbotWallet"))
|
||||||
|
@ -10,4 +12,4 @@ LNBITS_DATA_FOLDER = os.getenv("LNBITS_DATA_FOLDER", os.path.join(LNBITS_PATH, "
|
||||||
|
|
||||||
WALLET = wallet_class()
|
WALLET = wallet_class()
|
||||||
DEFAULT_WALLET_NAME = os.getenv("LNBITS_DEFAULT_WALLET_NAME", "LNbits wallet")
|
DEFAULT_WALLET_NAME = os.getenv("LNBITS_DEFAULT_WALLET_NAME", "LNbits wallet")
|
||||||
FEE_RESERVE = float(os.getenv("LNBITS_FEE_RESERVE", 0))
|
SERVICE_FEE = Decimal(os.getenv("LNBITS_SERVICE_FEE", "0.0"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user