feat: remove FEE_RESERVE

This commit is contained in:
Eneko Illarramendi 2020-04-21 15:44:02 +02:00
parent 5806beaeb7
commit efb9deb028
4 changed files with 15 additions and 16 deletions

View File

@ -2,9 +2,10 @@ FLASK_APP=lnbits
FLASK_ENV=development
LNBITS_SITE_TITLE=LNbits
LNBITS_WITH_ONION=0
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
LNBITS_BACKEND_WALLET_CLASS=LntxbotWallet

View File

@ -2,7 +2,7 @@ from typing import List, Optional
from uuid import uuid4
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
@ -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,))
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
WHERE user = ?
""",
(1 - FEE_RESERVE, user_id),
(user_id,),
)
return (
@ -96,11 +96,11 @@ def get_wallet(wallet_id: str) -> Optional[Wallet]:
with open_db() as db:
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
WHERE id = ?
""",
(1 - FEE_RESERVE, wallet_id),
(wallet_id,),
)
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"
row = db.fetchone(
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
WHERE {check_field} = ?
""",
(1 - FEE_RESERVE, key),
(key,),
)
return Wallet(**row) if row else None

View File

@ -1,7 +1,7 @@
from typing import Optional, Tuple
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 .models import Wallet
@ -38,11 +38,7 @@ def pay_invoice(*, wallet: Wallet, bolt11: str, max_sat: Optional[int] = None) -
if ok:
create_payment(
wallet_id=wallet.id,
checking_id=checking_id,
amount=-invoice.amount_msat,
memo=invoice.description,
fee=-invoice.amount_msat * FEE_RESERVE,
wallet_id=wallet.id, checking_id=checking_id, amount=-invoice.amount_msat, memo=invoice.description
)
except Exception as e:

View File

@ -1,6 +1,8 @@
import importlib
import os
from decimal import Decimal
wallets_module = importlib.import_module("lnbits.wallets")
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()
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"))