Browse Source

use config.is_dynfee and config.use_mempool_fees

also fixes #3894
3.1
SomberNight 7 years ago
parent
commit
15f7e09131
  1. 2
      gui/kivy/uix/dialogs/bump_fee_dialog.py
  2. 4
      gui/kivy/uix/dialogs/fee_dialog.py
  3. 6
      gui/qt/fee_slider.py
  4. 4
      gui/qt/main_window.py
  5. 6
      lib/simple_config.py

2
gui/kivy/uix/dialogs/bump_fee_dialog.py

@ -73,7 +73,7 @@ class BumpFeeDialog(Factory.Popup):
self.callback = callback
self.config = app.electrum_config
self.fee_step = self.config.max_fee_rate() / 10
self.dynfees = self.config.get('dynamic_fees', True) and self.app.network
self.dynfees = self.config.is_dynfee() and self.app.network
self.ids.old_fee.value = self.app.format_amount_and_units(self.init_fee)
self.update_slider()
self.update_text()

4
gui/kivy/uix/dialogs/fee_dialog.py

@ -78,8 +78,8 @@ class FeeDialog(Factory.Popup):
self.config = config
self.fee_rate = self.config.fee_per_kb()
self.callback = callback
self.mempool = self.config.get('mempool_fees', False)
self.dynfees = self.config.get('dynamic_fees', True)
self.mempool = self.config.use_mempool_fees()
self.dynfees = self.config.is_dynfee()
self.ids.mempool.active = self.mempool
self.ids.dynfees.active = self.dynfees
self.update_slider()

6
gui/qt/fee_slider.py

@ -21,7 +21,7 @@ class FeeSlider(QSlider):
def moved(self, pos):
with self.lock:
if self.dyn:
fee_rate = self.config.depth_to_fee(pos) if self.config.get('mempool_fees') else self.config.eta_to_fee(pos)
fee_rate = self.config.depth_to_fee(pos) if self.config.use_mempool_fees() else self.config.eta_to_fee(pos)
else:
fee_rate = self.config.static_fee(pos)
tooltip = self.get_tooltip(pos, fee_rate)
@ -30,7 +30,7 @@ class FeeSlider(QSlider):
self.callback(self.dyn, pos, fee_rate)
def get_tooltip(self, pos, fee_rate):
mempool = self.config.get('mempool_fees')
mempool = self.config.use_mempool_fees()
target, estimate = self.config.get_fee_text(pos, self.dyn, mempool, fee_rate)
if self.dyn:
return _('Target') + ': ' + target + '\n' + _('Current rate') + ': ' + estimate
@ -40,7 +40,7 @@ class FeeSlider(QSlider):
def update(self):
with self.lock:
self.dyn = self.config.is_dynfee()
mempool = self.config.get('mempool_fees')
mempool = self.config.use_mempool_fees()
maxp, pos, fee_rate = self.config.get_fee_slider(self.dyn, mempool)
self.setRange(0, maxp)
self.setValue(pos)

4
gui/qt/main_window.py

@ -1081,7 +1081,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
def fee_cb(dyn, pos, fee_rate):
if dyn:
if self.config.get('mempool_fees'):
if self.config.use_mempool_fees():
self.config.set_key('depth_level', pos, False)
else:
self.config.set_key('fee_level', pos, False)
@ -2669,7 +2669,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
fee_type_label = HelpLabel(_('Fee estimation') + ':', msg)
fee_type_combo = QComboBox()
fee_type_combo.addItems([_('Time based'), _('Mempool based')])
fee_type_combo.setCurrentIndex(1 if self.config.get('mempool_fees') else 0)
fee_type_combo.setCurrentIndex(1 if self.config.use_mempool_fees() else 0)
def on_fee_type(x):
self.config.set_key('mempool_fees', x==1)
self.fee_slider.update()

6
lib/simple_config.py

@ -324,7 +324,7 @@ class SimpleConfig(PrintError):
def get_fee_status(self):
dyn = self.is_dynfee()
mempool = self.get('mempool_fees')
mempool = self.use_mempool_fees()
pos = self.get_depth_level() if mempool else self.get_fee_level()
fee_rate = self.fee_per_kb()
target, tooltip = self.get_fee_text(pos, dyn, mempool, fee_rate)
@ -395,10 +395,10 @@ class SimpleConfig(PrintError):
return bool(self.mempool_fees)
def is_dynfee(self):
return self.get('dynamic_fees', True)
return bool(self.get('dynamic_fees', True))
def use_mempool_fees(self):
return self.get('mempool_fees', False)
return bool(self.get('mempool_fees', False))
def fee_per_kb(self):
"""Returns sat/kvB fee to pay for a txn.

Loading…
Cancel
Save