electrum

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

commit 0273936b07d21f09be7c91bb3b6640320fdd340c
parent 3f2c70878939dde5d8cef139bde2d086c4de4e3b
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 26 May 2016 09:23:42 +0200

Discretize fee levels (follow-up 3314b3a). Fixes #1753

Diffstat:
Mgui/kivy/uix/dialogs/fee_dialog.py | 22+++++++++++++---------
Mgui/kivy/uix/dialogs/settings.py | 4++--
Mgui/qt/main_window.py | 3++-
Mlib/bitcoin.py | 1+
Mlib/util.py | 1+
5 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/gui/kivy/uix/dialogs/fee_dialog.py b/gui/kivy/uix/dialogs/fee_dialog.py @@ -3,7 +3,8 @@ from kivy.factory import Factory from kivy.properties import ObjectProperty from kivy.lang import Builder -from electrum.bitcoin import RECOMMENDED_FEE +from electrum.bitcoin import FEE_STEP, RECOMMENDED_FEE +from electrum.util import fee_levels from electrum_gui.kivy.i18n import _ Builder.load_string(''' @@ -22,7 +23,8 @@ Builder.load_string(''' text: '' Slider: id: slider - range: 0, 100 + range: 0, 4 + step: 1 on_value: root.on_slider(self.value) BoxLayout: orientation: 'horizontal' @@ -68,7 +70,7 @@ class FeeDialog(Factory.Popup): self.callback = callback self.dynfees = self.config.get('dynamic_fees', False) - self.fee_factor = self.config.get('fee_factor', 50) + self.fee_level = self.config.get('fee_level', 2) self.static_fee = self.config.get('fee_per_kb', RECOMMENDED_FEE) self.ids.dynfees.active = self.dynfees @@ -84,29 +86,31 @@ class FeeDialog(Factory.Popup): def update_slider(self): slider = self.ids.slider if self.dynfees: - slider.value = self.fee_factor - slider.range = (0, 100) + slider.value = self.fee_level + slider.range = (0, 4) + slider.step = 1 else: slider.value = self.static_fee - slider.range = (0, 2*RECOMMENDED_FEE) + slider.range = (FEE_STEP, 2*RECOMMENDED_FEE) + slider.step = FEE_STEP def get_fee_text(self): if self.ids.dynfees.active: - return 'Recommendation x %d%%'%(self.fee_factor + 50) + return fee_levels[self.fee_level] + ' (%d%%)'% (100 * (self.fee_level + 1)/3) else: return self.app.format_amount_and_units(self.static_fee) + '/kB' def on_ok(self): self.config.set_key('dynamic_fees', self.dynfees, False) if self.dynfees: - self.config.set_key('fee_factor', self.fee_factor, True) + self.config.set_key('fee_level', self.fee_level, True) else: self.config.set_key('fee_per_kb', self.static_fee, True) self.callback() def on_slider(self, value): if self.dynfees: - self.fee_factor = int(value) + self.fee_level = int(value) else: self.static_fee = int(value) self.update_text() diff --git a/gui/kivy/uix/dialogs/settings.py b/gui/kivy/uix/dialogs/settings.py @@ -204,8 +204,8 @@ class SettingsDialog(Factory.Popup): def fee_status(self): if self.config.get('dynamic_fees'): - f = self.config.get('fee_factor', 50) + 50 - return 'Dynamic, %d%%'%f + 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' diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1032,8 +1032,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.fee_slider.setRange(0, 4) self.fee_slider.setToolTip(_('')) def slider_moved(): + from electrum.util import fee_levels i = self.fee_slider.sliderPosition() - tooltip = ['very slow', 'slow', 'within 2 blocks', 'fast', 'very fast'][i] + tooltip = fee_levels[i] + ' (%d%%)'% (100 * (i + 1)/3) QToolTip.showText(QCursor.pos(), tooltip, self.fee_slider) def slider_released(): self.config.set_key('fee_level', self.fee_slider.sliderPosition(), False) diff --git a/lib/bitcoin.py b/lib/bitcoin.py @@ -37,6 +37,7 @@ import aes ################################## transactions +FEE_STEP = 10000 RECOMMENDED_FEE = 50000 COINBASE_MATURITY = 100 COIN = 100000000 diff --git a/lib/util.py b/lib/util.py @@ -36,6 +36,7 @@ import threading from i18n import _ base_units = {'BTC':8, 'mBTC':5, 'uBTC':2} +fee_levels = [_('Very low'), _('Low'), _('Normal'), _('High'), _('Very high')] def normalize_version(v): return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]