electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 9d3162b1a16c140f86f5b12a57091c53ba80751d
parent 2990b1e86568cb3787cba63edd5f1962a0d0e043
Author: ThomasV <thomasv@electrum.org>
Date:   Tue, 15 Dec 2015 12:52:30 +0100

simplify get_label

Diffstat:
Mgui/android.py | 2+-
Mgui/gtk.py | 2+-
Mgui/kivy/uix/screens.py | 13+++----------
Mgui/qt/history_widget.py | 4+---
Mgui/qt/main_window.py | 2+-
Mgui/qt/transaction_dialog.py | 2+-
Mgui/qt/util.py | 6------
Mgui/stdio.py | 2+-
Mgui/text.py | 2+-
Mlib/wallet.py | 19++-----------------
10 files changed, 12 insertions(+), 42 deletions(-)

diff --git a/gui/android.py b/gui/android.py @@ -332,7 +332,7 @@ def get_history_values(n): except Exception: time_str = 'pending' conf_str = 'v' if conf else 'o' - label, is_default_label = wallet.get_label(tx_hash) + label = wallet.get_label(tx_hash) label = label.replace('<','').replace('>','') values.append((conf_str, ' ' + time_str, ' ' + format_satoshis(value, True), ' ' + label)) diff --git a/gui/gtk.py b/gui/gtk.py @@ -1185,7 +1185,7 @@ class ElectrumWindow: time_str = 'pending' conf_icon = Gtk.STOCK_EXECUTE - label, is_default_label = self.wallet.get_label(tx_hash) + label = self.wallet.get_label(tx_hash) tooltip = tx_hash + "\n%d confirmations"%conf if tx_hash else '' details = self.get_tx_details(tx_hash) diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -98,7 +98,7 @@ class HistoryScreen(CScreen): def label_dialog(self, obj): from dialogs.label_dialog import LabelDialog key = obj.tx_hash - text = self.app.wallet.get_label(key)[0] + text = self.app.wallet.get_label(key) def callback(text): self.app.wallet.set_label(key, text) self.update() @@ -127,12 +127,7 @@ class HistoryScreen(CScreen): else: icon = "atlas://gui/kivy/theming/light/confirmed" - if tx_hash: - label, is_default_label = self.app.wallet.get_label(tx_hash) - else: - label = _('Pruned transaction outputs') - is_default_label = False - + label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs') date = timestamp_to_datetime(timestamp) rate = run_hook('history_rate', date) if self.app.fiat_unit: @@ -430,9 +425,7 @@ class RequestsScreen(CScreen): signature = req.get('sig') ci = Factory.RequestItem() ci.address = req['address'] - label, is_default = self.app.wallet.get_label(address) - if label: - ci.memo = label + ci.memo = self.app.wallet.get_label(address) status = req.get('status') if status == PR_PAID: ci.icon = "atlas://gui/kivy/theming/light/confirmed" diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py @@ -74,7 +74,7 @@ class HistoryWidget(MyTreeWidget): icon, time_str = self.get_icon(conf, timestamp) v_str = self.parent.format_amount(value, True, whitespaces=True) balance_str = self.parent.format_amount(balance, whitespaces=True) - label, is_default_label = self.wallet.get_label(tx_hash) + label = self.wallet.get_label(tx_hash) entry = ['', tx_hash, time_str, label, v_str, balance_str] run_hook('history_tab_update', tx, entry) item = QTreeWidgetItem(entry) @@ -88,8 +88,6 @@ class HistoryWidget(MyTreeWidget): item.setForeground(4, QBrush(QColor("#BC1E1E"))) if tx_hash: item.setData(0, Qt.UserRole, tx_hash) - if is_default_label: - item.setForeground(3, QBrush(QColor('grey'))) self.insertTopLevelItem(0, item) if current_tx == tx_hash: self.setCurrentItem(item) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -2435,7 +2435,7 @@ class ElectrumWindow(QMainWindow, PrintError): value_string = '--' if tx_hash: - label, is_default_label = wallet.get_label(tx_hash) + label = wallet.get_label(tx_hash) label = label.encode('utf-8') else: label = "" diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py @@ -173,7 +173,7 @@ class TxDialog(QDialog): status = _("Signed") if tx_hash in self.wallet.transactions.keys(): - desc, is_default = self.wallet.get_label(tx_hash) + desc = self.wallet.get_label(tx_hash) conf, timestamp = self.wallet.get_confirmations(tx_hash) if timestamp: time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3] diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -383,12 +383,6 @@ class MyTreeWidget(QTreeWidget): key = str(item.data(0, Qt.UserRole).toString()) text = unicode(item.text(column)) self.parent.wallet.set_label(key, text) - if text: - item.setForeground(column, QBrush(QColor('black'))) - else: - text = self.parent.wallet.get_default_label(key) - item.setText(column, text) - item.setForeground(column, QBrush(QColor('gray'))) self.parent.history_list.update() self.parent.update_completions() diff --git a/gui/stdio.py b/gui/stdio.py @@ -96,7 +96,7 @@ class ElectrumGui: else: time_str = 'pending' - label, is_default_label = self.wallet.get_label(tx_hash) + label = self.wallet.get_label(tx_hash) messages.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) ) self.print_list(messages[::-1], format_str%( _("Date"), _("Description"), _("Amount"), _("Balance"))) diff --git a/gui/text.py b/gui/text.py @@ -116,7 +116,7 @@ class ElectrumGui: else: time_str = 'pending' - label, is_default_label = self.wallet.get_label(tx_hash) + label = self.wallet.get_label(tx_hash) if len(label) > 40: label = label[0:37] + '...' self.history.append( format_str%( time_str, label, format_satoshis(value, whitespaces=True), format_satoshis(balance, whitespaces=True) ) ) diff --git a/lib/wallet.py b/lib/wallet.py @@ -867,24 +867,9 @@ class Abstract_Wallet(PrintError): return h2 - def get_label(self, tx_hash): - label = self.labels.get(tx_hash) - is_default = (label == '') or (label is None) - if is_default: - label = self.get_default_label(tx_hash) - return label, is_default - - def get_default_label(self, tx_hash): - if self.txi.get(tx_hash) == {}: - d = self.txo.get(tx_hash, {}) - labels = [] - for addr in d.keys(): - label = self.labels.get(addr) - if label: - labels.append(label) - return ', '.join(labels) - return '' + label = self.labels.get(tx_hash, '') + return label def fee_per_kb(self, config): b = config.get('dynamic_fees')