URI: 
       tsimplify get_label - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 9d3162b1a16c140f86f5b12a57091c53ba80751d
   DIR parent 2990b1e86568cb3787cba63edd5f1962a0d0e043
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Tue, 15 Dec 2015 12:52:30 +0100
       
       simplify get_label
       
       Diffstat:
         M gui/android.py                      |       2 +-
         M gui/gtk.py                          |       2 +-
         M gui/kivy/uix/screens.py             |      13 +++----------
         M gui/qt/history_widget.py            |       4 +---
         M gui/qt/main_window.py               |       2 +-
         M gui/qt/transaction_dialog.py        |       2 +-
         M gui/qt/util.py                      |       6 ------
         M gui/stdio.py                        |       2 +-
         M gui/text.py                         |       2 +-
         M lib/wallet.py                       |      19 ++-----------------
       
       10 files changed, 12 insertions(+), 42 deletions(-)
       ---
   DIR diff --git a/gui/android.py b/gui/android.py
       t@@ -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))
        
   DIR diff --git a/gui/gtk.py b/gui/gtk.py
       t@@ -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)
        
   DIR diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py
       t@@ -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()
       t@@ -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:
       t@@ -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"
   DIR diff --git a/gui/qt/history_widget.py b/gui/qt/history_widget.py
       t@@ -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)
       t@@ -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)
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -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 = ""
   DIR diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py
       t@@ -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]
   DIR diff --git a/gui/qt/util.py b/gui/qt/util.py
       t@@ -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()
        
   DIR diff --git a/gui/stdio.py b/gui/stdio.py
       t@@ -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")))
   DIR diff --git a/gui/text.py b/gui/text.py
       t@@ -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) ) )
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -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')