tx dialog: fix confirmation time estimate

This commit is contained in:
ThomasV 2016-06-08 11:22:58 +02:00
parent b94a7920af
commit 7f7aa97e2e
3 changed files with 16 additions and 12 deletions

View File

@ -104,17 +104,24 @@ class TxDialog(Factory.Popup):
self.update()
def update(self):
self.tx_hash, self.status_str, self.description, self.can_broadcast, amount, fee, height, conf, timestamp = self.wallet.get_tx_info(self.tx)
self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] if timestamp else ''
format_amount = self.app.format_amount_and_units
self.tx_hash, self.status_str, self.description, self.can_broadcast, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
if timestamp:
self.date_str = datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
elif exp_n:
self.date_str = _('Within %d blocks') % exp_n
else:
self.date_str = ''
if amount is None:
self.amount_str = _("Transaction unrelated to your wallet")
elif amount > 0:
self.is_mine = False
self.amount_str = self.app.format_amount_and_units(amount)
self.amount_str = format_amount(amount)
else:
self.is_mine = True
self.amount_str = self.app.format_amount_and_units(-amount)
self.fee_str = self.app.format_amount_and_units(fee) if fee is not None else _('unknown')
self.amount_str = format_amount(-amount)
self.fee_str = format_amount(fee) if fee is not None else _('unknown')
self.can_sign = self.wallet.can_sign(self.tx)
self.ids.output_list.update(self.tx.outputs())

View File

@ -178,13 +178,10 @@ class TxDialog(QDialog, MessageBoxMixin):
desc = self.desc
base_unit = self.main_window.base_unit()
format_amount = self.main_window.format_amount
tx_hash, status, label, can_broadcast, amount, fee, height, conf, timestamp = self.wallet.get_tx_info(self.tx)
tx_hash, status, label, can_broadcast, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
if can_broadcast:
self.broadcast_button.show()
# cannot broadcast when offline
if self.main_window.network is None:
self.broadcast_button.setEnabled(False)
else:
self.broadcast_button.hide()
@ -201,12 +198,12 @@ class TxDialog(QDialog, MessageBoxMixin):
self.tx_desc.show()
self.status_label.setText(_('Status:') + ' ' + status)
if timestamp is not None:
if timestamp:
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
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.setText(_('Expected confirmation time: %d blocks'%(exp_n)))
self.date_label.show()
else:
self.date_label.hide()

View File

@ -643,7 +643,7 @@ class Abstract_Wallet(PrintError):
else:
amount = None
return tx_hash, status, label, can_broadcast, amount, fee, height, conf, timestamp
return tx_hash, status, label, can_broadcast, amount, fee, height, conf, timestamp, exp_n
def get_addr_io(self, address):