1
0

qt settings: expose LIGHTNING_PAYMENT_BUDGET_FEE_MAX_MILLIONTHS

Expose as a slider; perhaps it is less footgunny this way?
This commit is contained in:
SomberNight
2024-05-06 22:08:30 +00:00
parent c82918a456
commit 2152347ba8
2 changed files with 37 additions and 2 deletions

View File

@@ -30,7 +30,7 @@ from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QComboBox, QTabWidget, QDialog,
QSpinBox, QFileDialog, QCheckBox, QLabel,
QVBoxLayout, QGridLayout, QLineEdit,
QPushButton, QWidget, QHBoxLayout)
QPushButton, QWidget, QHBoxLayout, QSlider)
from electrum.i18n import _, languages
from electrum import util, paymentrequest
@@ -155,6 +155,37 @@ class SettingsDialog(QDialog, QtEventListener):
self.config.WATCHTOWER_CLIENT_URL = url
self.watchtower_url_e.editingFinished.connect(on_wt_url)
lnfee_hlabel = HelpLabel.from_configvar(self.config.cv.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS)
lnfee_map = [500, 1_000, 3_000, 5_000, 10_000, 20_000, 30_000, 50_000]
def lnfee_update_vlabel(fee_val: int):
lnfee_vlabel.setText(_("{}% of payment").format(f"{fee_val / 10 ** 4:.2f}"))
def lnfee_slider_moved():
pos = lnfee_slider.sliderPosition()
fee_val = lnfee_map[pos]
lnfee_update_vlabel(fee_val)
def lnfee_slider_released():
pos = lnfee_slider.sliderPosition()
fee_val = lnfee_map[pos]
self.config.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS = fee_val
lnfee_slider = QSlider(Qt.Horizontal)
lnfee_slider.setRange(0, len(lnfee_map)-1)
lnfee_slider.setTracking(True)
try:
lnfee_spos = lnfee_map.index(self.config.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS)
except ValueError:
lnfee_spos = 0
lnfee_slider.setSliderPosition(lnfee_spos)
lnfee_vlabel = QLabel("")
lnfee_update_vlabel(self.config.LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS)
lnfee_slider.valueChanged.connect(lnfee_slider_moved)
lnfee_slider.sliderReleased.connect(lnfee_slider_released)
lnfee_hbox = QHBoxLayout()
lnfee_hbox.setContentsMargins(0, 0, 0, 0)
lnfee_hbox.addWidget(lnfee_vlabel)
lnfee_hbox.addWidget(lnfee_slider)
lnfee_hbox_w = QWidget()
lnfee_hbox_w.setLayout(lnfee_hbox)
alias_label = HelpLabel.from_configvar(self.config.cv.OPENALIAS_ID)
alias = self.config.OPENALIAS_ID
self.alias_e = QLineEdit(alias)
@@ -351,6 +382,7 @@ class SettingsDialog(QDialog, QtEventListener):
lightning_widgets.append((trampoline_cb, None))
lightning_widgets.append((legacy_add_trampoline_cb, None))
lightning_widgets.append((remote_wt_cb, self.watchtower_url_e))
lightning_widgets.append((lnfee_hlabel, lnfee_hbox_w))
fiat_widgets = []
fiat_widgets.append((QLabel(_('Fiat currency')), ccy_combo))
fiat_widgets.append((QLabel(_('Source')), ex_combo))

View File

@@ -1042,7 +1042,10 @@ This will result in longer routes; it might increase your fees and decrease the
LIGHTNING_PAYMENT_FEE_MAX_MILLIONTHS = ConfigVar(
'lightning_payment_fee_max_millionths', default=10_000, # 1%
type_=int,
short_desc=lambda: _("Max lightning fees (%) to pay"),
short_desc=lambda: _("Max lightning fees to pay"),
long_desc=lambda: _("""When sending lightning payments, this value is an upper bound for the fees we allow paying, proportional to the payment amount. The fees are paid in addition to the payment amount, by the sender.
Warning: setting this to too low will result in lots of payment failures."""),
)
LIGHTNING_PAYMENT_FEE_CUTOFF_MSAT = ConfigVar(
'lightning_payment_fee_cutoff_msat', default=10_000, # 10 sat