From 5f6585eb4544752e60c86e4419a531e11632a9e5 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 18 Dec 2019 13:44:58 +0000 Subject: [PATCH] fee reserve defaults to 0. --- .env.example | 2 ++ lnbits/__init__.py | 8 ++++---- lnbits/settings.py | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index e84d2ec..704eeb8 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,5 @@ FLASK_ENV=development LNTXBOT_API_ENDPOINT=https://lntxbot.bigsun.xyz/ LNTXBOT_ADMIN_KEY=LNTXBOT_ADMIN_KEY LNTXBOT_INVOICE_KEY=LNTXBOT_INVOICE_KEY + +FEE_RESERVE=0.01 diff --git a/lnbits/__init__.py b/lnbits/__init__.py index 65fdded..879e240 100644 --- a/lnbits/__init__.py +++ b/lnbits/__init__.py @@ -9,7 +9,7 @@ from lnurl import Lnurl, LnurlWithdrawResponse from . import bolt11 from .db import Database from .helpers import megajson -from .settings import LNBITS_PATH, WALLET, DEFAULT_USER_WALLET_NAME +from .settings import LNBITS_PATH, WALLET, DEFAULT_USER_WALLET_NAME, FEE_RESERVE app = Flask(__name__) @@ -187,12 +187,12 @@ def wallet(): coalesce( (SELECT balance/1000 FROM balances WHERE wallet = wallets.id), 0 - ) AS balance, + ) * ? AS balance, * FROM wallets WHERE user = ? AND id = ? """, - (usr, wallet_id), + (FEE_RESERVE, usr, wallet_id), ) transactions = db.fetchall("SELECT * FROM apipayments WHERE wallet = ? AND pending = 0", (wallet_id,)) @@ -275,7 +275,7 @@ def api_transactions(): ( invoice.payment_hash, -int(invoice.amount_msat), - -int(invoice.amount_msat * 0.01), + -int(invoice.amount_msat) * FEE_RESERVE, wallet["id"], invoice.description, ), diff --git a/lnbits/settings.py b/lnbits/settings.py index 6ac1a23..f714a86 100644 --- a/lnbits/settings.py +++ b/lnbits/settings.py @@ -15,3 +15,5 @@ WALLET = LntxbotWallet( LNBITS_PATH = os.path.dirname(os.path.realpath(__file__)) DATABASE_PATH = os.getenv("DATABASE_PATH") or os.path.join(LNBITS_PATH, "data", "database.sqlite3") DEFAULT_USER_WALLET_NAME = os.getenv("DEFAULT_USER_WALLET_NAME") or "Bitcoin LN Wallet" + +FEE_RESERVE = float(os.getenv("FEE_RESERVE") or 0)