1
0

show warning icon if unconfirmed tx has low fee. fixes 1798

This commit is contained in:
ThomasV
2016-05-30 18:26:58 +02:00
parent bce42cb496
commit 599906eef6
4 changed files with 86 additions and 58 deletions

View File

@@ -88,6 +88,20 @@ class CScreen(Factory.Screen):
self.add_widget(self.context_menu)
TX_ICONS = [
"close",
"close",
"close",
"unconfirmed",
"close",
"clock1",
"clock2",
"clock3",
"clock4",
"clock5",
"confirmed",
]
class HistoryScreen(CScreen):
tab = ObjectProperty(None)
@@ -119,30 +133,8 @@ class HistoryScreen(CScreen):
def parse_history(self, items):
for item in items:
tx_hash, height, conf, timestamp, value, balance = item
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] if timestamp else _("unknown")
if conf == 0:
tx = self.app.wallet.transactions.get(tx_hash)
is_final = tx.is_final()
else:
is_final = True
if not is_final:
time_str = _('Replaceable')
icon = "atlas://gui/kivy/theming/light/close"
elif height < 0:
time_str = _('Unconfirmed inputs')
icon = "atlas://gui/kivy/theming/light/close"
elif height == 0:
time_str = _('Unconfirmed')
icon = "atlas://gui/kivy/theming/light/unconfirmed"
elif conf == 0:
time_str = _('Not Verified')
icon = "atlas://gui/kivy/theming/light/close"
elif conf < 6:
conf = max(1, conf)
icon = "atlas://gui/kivy/theming/light/clock{}".format(conf)
else:
icon = "atlas://gui/kivy/theming/light/confirmed"
status, status_str = self.app.wallet.get_tx_status(tx_hash, height, conf, timestamp)
icon = "atlas://gui/kivy/theming/light/" + TX_ICONS[status]
label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
date = timestamp_to_datetime(timestamp)
quote_text = ''
@@ -151,7 +143,7 @@ class HistoryScreen(CScreen):
if rate:
s = run_hook('value_str', value, rate)
quote_text = '' if s is None else s + ' ' + self.app.fiat_unit
yield (conf, icon, time_str, label, value, tx_hash, quote_text)
yield (conf, icon, status_str, label, value, tx_hash, quote_text)
def update(self, see_all=False):
if self.app.wallet is None:

View File

@@ -32,6 +32,21 @@ from electrum.util import block_explorer_URL, format_satoshis, format_time
from electrum.plugins import run_hook
TX_ICONS = [
"warning.png",
"warning.png",
"warning.png",
"unconfirmed.png",
"unconfirmed.png",
"clock1.png",
"clock2.png",
"clock3.png",
"clock4.png",
"clock5.png",
"confirmed.png",
]
class HistoryList(MyTreeWidget):
def __init__(self, parent=None):
@@ -40,31 +55,10 @@ class HistoryList(MyTreeWidget):
self.setColumnHidden(1, True)
def refresh_headers(self):
headers = ['', '', _('Date'), _('Description') , _('Amount'),
_('Balance')]
headers = ['', '', _('Date'), _('Description') , _('Amount'), _('Balance')]
run_hook('history_tab_headers', headers)
self.update_headers(headers)
def get_icon(self, height, conf, timestamp, is_final):
time_str = format_time(timestamp) if timestamp else _("unknown")
if not is_final:
time_str = _('Replaceable')
icon = QIcon(":icons/warning.png")
elif height < 0:
time_str = _('Unconfirmed inputs')
icon = QIcon(":icons/warning.png")
elif height == 0:
time_str = _('Unconfirmed')
icon = QIcon(":icons/unconfirmed.png")
elif conf == 0:
time_str = _('Not Verified')
icon = QIcon(":icons/unconfirmed.png")
elif conf < 6:
icon = QIcon(":icons/clock%d.png"%conf)
else:
icon = QIcon(":icons/confirmed.png")
return icon, time_str
def get_domain(self):
'''Replaced in address_dialog.py'''
return self.wallet.get_account_addresses(self.parent.current_account)
@@ -78,16 +72,12 @@ class HistoryList(MyTreeWidget):
run_hook('history_tab_update_begin')
for h_item in h:
tx_hash, height, conf, timestamp, value, balance = h_item
if conf == 0:
tx = self.wallet.transactions.get(tx_hash)
is_final = tx and tx.is_final()
else:
is_final = True
icon, time_str = self.get_icon(height, conf, timestamp, is_final)
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
icon = QIcon(":icons/" + TX_ICONS[status])
v_str = self.parent.format_amount(value, True, whitespaces=True)
balance_str = self.parent.format_amount(balance, whitespaces=True)
label = self.wallet.get_label(tx_hash)
entry = ['', tx_hash, time_str, label, v_str, balance_str]
entry = ['', tx_hash, status_str, label, v_str, balance_str]
run_hook('history_tab_update', h_item, entry)
item = QTreeWidgetItem(entry)
item.setIcon(0, icon)
@@ -106,7 +96,8 @@ class HistoryList(MyTreeWidget):
self.setCurrentItem(item)
def update_item(self, tx_hash, height, conf, timestamp):
icon, time_str = self.get_icon(height, conf, timestamp, True)
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
icon = QIcon(":icons/" + TX_ICONS[status])
items = self.findItems(tx_hash, Qt.UserRole|Qt.MatchContains|Qt.MatchRecursive, column=1)
if items:
item = items[0]