commit f2d2d61894d1dcbf9929060e9ae2be005d52575e
parent 017afd95dc1e8eb721e421a49c970e54053a2ff2
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 7 Jun 2016 17:12:31 +0200
add expected confirmation time to tx dialog
Diffstat:
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py
@@ -77,11 +77,10 @@ class TxDialog(QDialog, MessageBoxMixin):
self.tx_hash_e.addButton(":icons/qrcode.png", qr_show, _("Show as QR code"))
self.tx_hash_e.setReadOnly(True)
vbox.addWidget(self.tx_hash_e)
- self.status_label = QLabel()
- vbox.addWidget(self.status_label)
-
self.tx_desc = QLabel()
vbox.addWidget(self.tx_desc)
+ self.status_label = QLabel()
+ vbox.addWidget(self.status_label)
self.date_label = QLabel()
vbox.addWidget(self.date_label)
self.amount_label = QLabel()
@@ -176,9 +175,12 @@ class TxDialog(QDialog, MessageBoxMixin):
def update(self):
+ base_unit = self.main_window.base_unit()
+ format_amount = self.main_window.format_amount
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(self.tx)
desc = self.desc
time_str = None
+ exp_n = None
self.broadcast_button.hide()
if self.tx.is_complete():
@@ -196,6 +198,10 @@ class TxDialog(QDialog, MessageBoxMixin):
status = _('Unconfirmed')
if fee is None:
fee = self.wallet.tx_fees.get(tx_hash)
+ if fee:
+ size = self.tx.estimated_size()
+ fee_per_kb = fee * 1000 / size
+ exp_n = self.wallet.network.reverse_dynfee(fee_per_kb)
else:
status = _("Signed")
self.broadcast_button.show()
@@ -223,6 +229,9 @@ class TxDialog(QDialog, MessageBoxMixin):
if time_str is not None:
self.date_label.setText(_("Date: %s")%time_str)
self.date_label.show()
+ elif exp_n:
+ self.date_label.setText(_('Expected confirmation time: %d blocks (%s)'%(exp_n, format_amount(fee_per_kb) + ' ' + base_unit + '/kb')))
+ self.date_label.show()
else:
self.date_label.hide()
@@ -230,9 +239,6 @@ class TxDialog(QDialog, MessageBoxMixin):
if not self.wallet.up_to_date:
return
- base_unit = self.main_window.base_unit()
- format_amount = self.main_window.format_amount
-
if is_relevant:
if is_mine:
if fee is not None:
diff --git a/lib/network.py b/lib/network.py
@@ -349,6 +349,12 @@ class Network(util.DaemonThread):
fee = min(10*RECOMMENDED_FEE, fee)
return fee
+ def reverse_dynfee(self, fee_per_kb):
+ import operator
+ dist = map(lambda x: (x[0], abs(x[1] - fee_per_kb)), self.fee_estimates.items())
+ min_target, min_value = min(dist, key=operator.itemgetter(1))
+ return min_target
+
def notify(self, key):
if key in ['status', 'updated']:
self.trigger_callback(key)