diff --git a/electrum/gui/kivy/uix/dialogs/tx_dialog.py b/electrum/gui/kivy/uix/dialogs/tx_dialog.py index 3f6486a72..7f0204d29 100644 --- a/electrum/gui/kivy/uix/dialogs/tx_dialog.py +++ b/electrum/gui/kivy/uix/dialogs/tx_dialog.py @@ -125,6 +125,7 @@ class TxDialog(Factory.Popup): self.app = app # type: ElectrumWindow self.wallet = self.app.wallet self.tx = tx # type: Transaction + self.config = self.app.electrum_config # If the wallet can populate the inputs with more info, do it now. # As a result, e.g. we might learn an imported address tx is segwit, @@ -154,7 +155,7 @@ class TxDialog(Factory.Popup): self.date_str = datetime.fromtimestamp(tx_mined_status.timestamp).isoformat(' ')[:-3] elif exp_n is not None: self.date_label = _('Mempool depth') - self.date_str = _('{} from tip').format('%.2f MB'%(exp_n/1000000)) + self.date_str = self.config.depth_tooltip(exp_n) else: self.date_label = '' self.date_str = '' diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py index 0260a8d46..850c693a1 100644 --- a/electrum/gui/qt/transaction_dialog.py +++ b/electrum/gui/qt/transaction_dialog.py @@ -476,8 +476,10 @@ class BaseTxDialog(QDialog, MessageBoxMixin): self.date_label.setText(_("Date: {}").format(time_str)) self.date_label.show() elif exp_n is not None: - text = '%.2f MB'%(exp_n/1000000) - self.date_label.setText(_('Position in mempool: {} from tip').format(text)) + text = "{}: {}".format( + _('Position in mempool'), + self.config.depth_tooltip(exp_n)) + self.date_label.setText(text) self.date_label.show() else: self.date_label.hide() diff --git a/electrum/simple_config.py b/electrum/simple_config.py index b57591771..d9adb1cc5 100644 --- a/electrum/simple_config.py +++ b/electrum/simple_config.py @@ -437,11 +437,17 @@ class SimpleConfig(Logger): min_target = -1 return min_target + def get_depth_mb_str(self, depth: int) -> str: + # e.g. 500_000 -> "0.50 MB" + depth_mb = "{:.2f}".format(depth / 1_000_000) # maybe .rstrip("0") ? + return f"{depth_mb} MB" + def depth_tooltip(self, depth: Optional[int]) -> str: """Returns text tooltip for given mempool depth (in vbytes).""" if depth is None: return "unknown from tip" - return "%.1f MB from tip" % (depth/1_000_000) + depth_mb = self.get_depth_mb_str(depth) + return _("{} from tip").format(depth_mb) def eta_tooltip(self, x): if x < 0: diff --git a/electrum/wallet.py b/electrum/wallet.py index 5a7d1dd07..49fe023b8 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -1198,7 +1198,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): and self.config.has_fee_mempool(): exp_n = self.config.fee_to_depth(fee_per_byte) if exp_n is not None: - extra.append('%.2f MB'%(exp_n/1000000)) + extra.append(self.config.get_depth_mb_str(exp_n)) if height == TX_HEIGHT_LOCAL: status = 3 elif height == TX_HEIGHT_UNCONF_PARENT: