electrum

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

commit 01eaf0fe4ee7eae1f8f0fdf9a835a4ad75466234
parent b06b8753e6c88a6d1074ca59fbd2e8c85f234129
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  8 Feb 2019 15:53:28 +0100

Merge pull request #5052 from JeremyRand/utxolist-for-loop

Refactor for loop in UTXOList
Diffstat:
Melectrum/gui/qt/utxo_list.py | 35+++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/electrum/gui/qt/utxo_list.py b/electrum/gui/qt/utxo_list.py @@ -47,22 +47,25 @@ class UTXOList(MyTreeView): self.model().clear() self.update_headers(self.__class__.headers) for idx, x in enumerate(utxos): - address = x.get('address') - height = x.get('height') - name = x.get('prevout_hash') + ":%d"%x.get('prevout_n') - self.utxo_dict[name] = x - label = self.wallet.get_label(x.get('prevout_hash')) - amount = self.parent.format_amount(x['value'], whitespaces=True) - labels = [address, label, amount, '%d'%height, name[0:10] + '...' + name[-2:]] - utxo_item = [QStandardItem(x) for x in labels] - self.set_editability(utxo_item) - utxo_item[0].setFont(QFont(MONOSPACE_FONT)) - utxo_item[2].setFont(QFont(MONOSPACE_FONT)) - utxo_item[4].setFont(QFont(MONOSPACE_FONT)) - utxo_item[0].setData(name, Qt.UserRole) - if self.wallet.is_frozen(address): - utxo_item[0].setBackground(ColorScheme.BLUE.as_color(True)) - self.model().insertRow(idx, utxo_item) + self.insert_utxo(idx, x) + + def insert_utxo(self, idx, x): + address = x.get('address') + height = x.get('height') + name = x.get('prevout_hash') + ":%d"%x.get('prevout_n') + self.utxo_dict[name] = x + label = self.wallet.get_label(x.get('prevout_hash')) + amount = self.parent.format_amount(x['value'], whitespaces=True) + labels = [address, label, amount, '%d'%height, name[0:10] + '...' + name[-2:]] + utxo_item = [QStandardItem(x) for x in labels] + self.set_editability(utxo_item) + utxo_item[0].setFont(QFont(MONOSPACE_FONT)) + utxo_item[2].setFont(QFont(MONOSPACE_FONT)) + utxo_item[4].setFont(QFont(MONOSPACE_FONT)) + utxo_item[0].setData(name, Qt.UserRole) + if self.wallet.is_frozen(address): + utxo_item[0].setBackground(ColorScheme.BLUE.as_color(True)) + self.model().insertRow(idx, utxo_item) def selected_column_0_user_roles(self) -> Optional[List[str]]: if not self.model():