From 4f6c0c2c61f236f610befe829ae706208db01053 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 19 Apr 2021 16:06:43 +0200 Subject: [PATCH] kivy bump fee dialog: handle no dynamic fee estimates fix #7220 --- electrum/gui/kivy/uix/dialogs/bump_fee_dialog.py | 11 ++++++++--- electrum/gui/kivy/uix/dialogs/dscancel_dialog.py | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/electrum/gui/kivy/uix/dialogs/bump_fee_dialog.py b/electrum/gui/kivy/uix/dialogs/bump_fee_dialog.py index c242d566f..456c26513 100644 --- a/electrum/gui/kivy/uix/dialogs/bump_fee_dialog.py +++ b/electrum/gui/kivy/uix/dialogs/bump_fee_dialog.py @@ -102,11 +102,16 @@ class BumpFeeDialog(FeeSliderDialog, Factory.Popup): def update_text(self): target, tooltip, dyn = self.config.get_fee_target() self.ids.fee_target.text = target - feerate = self.config.fee_per_kb() / 1000 - self.ids.new_feerate.value = f'{feerate:.1f} sat/B' + fee_per_kb = self.config.fee_per_kb() + if fee_per_kb is None: + self.ids.new_feerate.value = "unknown" + else: + fee_per_byte = fee_per_kb / 1000 + self.ids.new_feerate.value = f'{fee_per_byte:.1f} sat/B' def on_ok(self): - new_fee_rate = self.config.fee_per_kb() / 1000 + fee_per_kb = self.config.fee_per_kb() + new_fee_rate = fee_per_kb / 1000 if fee_per_kb is not None else None is_final = self.ids.final_cb.active self.callback(new_fee_rate, is_final) diff --git a/electrum/gui/kivy/uix/dialogs/dscancel_dialog.py b/electrum/gui/kivy/uix/dialogs/dscancel_dialog.py index 272e7955d..59672f952 100644 --- a/electrum/gui/kivy/uix/dialogs/dscancel_dialog.py +++ b/electrum/gui/kivy/uix/dialogs/dscancel_dialog.py @@ -1,4 +1,4 @@ -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, Optional from kivy.app import App from kivy.factory import Factory @@ -95,7 +95,7 @@ class DSCancelDialog(Factory.Popup): slider.step = 1 slider.value = pos - def get_fee_rate(self): + def get_fee_rate(self) -> Optional[int]: pos = int(self.ids.slider.value) if self.dynfees: fee_rate = self.config.depth_to_fee(pos) if self.mempool else self.config.eta_to_fee(pos) @@ -104,7 +104,8 @@ class DSCancelDialog(Factory.Popup): return fee_rate # sat/kbyte def on_ok(self): - new_fee_rate = self.get_fee_rate() / 1000 + fee_per_kb = self.get_fee_rate() + new_fee_rate = fee_per_kb / 1000 if fee_per_kb is not None else None self.callback(new_fee_rate) def on_slider(self, value):