electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 07dc4ebc1c2f6eb819b2765ff7c86b5a69460aaf
parent ac53585a40e437743db168380e2478f6b9d0a337
Author: ThomasV <thomasv@electrum.org>
Date:   Sun, 22 Jan 2017 11:22:16 +0100

kivy: update fee slider

Diffstat:
Mgui/kivy/main.kv | 3++-
Mgui/kivy/uix/dialogs/fee_dialog.py | 26+++++++++++++++-----------
Mgui/kivy/uix/dialogs/settings.py | 6++----
3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/gui/kivy/main.kv b/gui/kivy/main.kv @@ -337,9 +337,10 @@ <ActionOvrButton@ActionButton> - on_release: + #on_release: # fixme: the following line was commented out because it does no seem to do what it is intended # Clock.schedule_once(lambda dt: self.parent.parent.dismiss() if self.parent else None, 0.05) + on_press: Clock.schedule_once(lambda dt: app.popup_dialog(self.name), 0.05) diff --git a/gui/kivy/uix/dialogs/fee_dialog.py b/gui/kivy/uix/dialogs/fee_dialog.py @@ -3,7 +3,6 @@ from kivy.factory import Factory from kivy.properties import ObjectProperty from kivy.lang import Builder -from electrum.bitcoin import FEE_STEP, RECOMMENDED_FEE from electrum.util import fee_levels from electrum_gui.kivy.i18n import _ @@ -59,6 +58,8 @@ class FeeDialog(Factory.Popup): Factory.Popup.__init__(self) self.app = app self.config = config + self.fee_step = self.config.max_fee_rate() / 10 + self.fee_rate = self.config.fee_per_kb() self.callback = callback self.dynfees = self.config.get('dynamic_fees', True) self.ids.dynfees.active = self.dynfees @@ -76,20 +77,23 @@ class FeeDialog(Factory.Popup): slider.step = 1 slider.value = self.config.get('fee_level', 2) else: - slider.range = (FEE_STEP, 2*RECOMMENDED_FEE) - slider.step = FEE_STEP - slider.value = self.config.get('fee_per_kb', RECOMMENDED_FEE) + slider.range = (1, 10) + slider.step = 1 + slider.value = min(self.fee_rate / self.fee_step, 10) def get_fee_text(self, value): if self.ids.dynfees.active: tooltip = fee_levels[value] - if self.app.network: - dynfee = self.app.network.dynfee(value) - if dynfee: - tooltip += '\n' + (self.app.format_amount_and_units(dynfee)) + '/kB' - return tooltip + if self.config.has_fee_estimates(): + dynfee = self.config.dynfee(value) + tooltip += '\n' + (self.app.format_amount_and_units(dynfee)) + '/kB' else: - return self.app.format_amount_and_units(value) + '/kB' + fee_rate = value * self.fee_step + tooltip = self.app.format_amount_and_units(fee_rate) + '/kB' + if self.config.has_fee_estimates(): + i = self.config.reverse_dynfee(fee_rate) + tooltip += '\n' + (_('low fee') if i < 0 else 'Within %d blocks'%i) + return tooltip def on_ok(self): value = int(self.ids.slider.value) @@ -97,7 +101,7 @@ class FeeDialog(Factory.Popup): if self.dynfees: self.config.set_key('fee_level', value, True) else: - self.config.set_key('fee_per_kb', value, True) + self.config.set_key('fee_per_kb', value * self.fee_step, True) self.callback() def on_slider(self, value): diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py @@ -7,8 +7,8 @@ from electrum.util import base_units from electrum.i18n import languages from electrum_gui.kivy.i18n import _ from electrum.plugins import run_hook -from electrum.bitcoin import RECOMMENDED_FEE from electrum import coinchooser +from electrum.util import fee_levels from choice_dialog import ChoiceDialog @@ -211,11 +211,9 @@ class SettingsDialog(Factory.Popup): def fee_status(self): if self.config.get('dynamic_fees', True): - from electrum.util import fee_levels return fee_levels[self.config.get('fee_level', 2)] else: - F = self.config.get('fee_per_kb', RECOMMENDED_FEE) - return self.app.format_amount_and_units(F) + '/kB' + return self.app.format_amount_and_units(self.config.fee_per_kb()) + '/kB' def fee_dialog(self, label, dt): if self._fee_dialog is None: