From: ecdsa Date: Sat, 16 Mar 2013 17:17:50 +0000 (+0100) Subject: define wallet.get_num_tx() X-Git-Url: https://git.novaco.in/?a=commitdiff_plain;h=d6952228be6d269a81025397eaddef0ed502338d;p=electrum-nvc.git define wallet.get_num_tx() --- diff --git a/gui/gui_classic.py b/gui/gui_classic.py index ef2958b..0b28f4e 100644 --- a/gui/gui_classic.py +++ b/gui/gui_classic.py @@ -1131,10 +1131,7 @@ class ElectrumWindow(QMainWindow): for address in self.wallet.addressbook: label = self.wallet.labels.get(address,'') - n = 0 - for tx in self.wallet.transactions.values(): - if address in map(lambda x: x[0], tx.outputs): n += 1 - + n = self.wallet.get_num_tx(address) item = QTreeWidgetItem( [ address, label, "%d"%n] ) item.setFont(0, QFont(MONOSPACE_FONT)) # 32 = label can be edited (bool) diff --git a/gui/gui_gtk.py b/gui/gui_gtk.py index 55b9342..88de6ec 100644 --- a/gui/gui_gtk.py +++ b/gui/gui_gtk.py @@ -1152,10 +1152,7 @@ class ElectrumWindow: for address in self.wallet.addressbook: label = self.wallet.labels.get(address) - n = 0 - for tx in self.wallet.transactions.values(): - if address in map(lambda x:x[0], tx.outputs): n += 1 - + n = self.wallet.get_num_tx(address) self.addressbook_list.append((address, label, "%d"%n)) def update_history_tab(self): diff --git a/lib/wallet.py b/lib/wallet.py index 9e3b519..b39770e 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -407,6 +407,12 @@ class Wallet: # redo labels # self.update_tx_labels() + def get_num_tx(self, address): + n = 0 + for tx in self.transactions.values(): + if address in map(lambda x:x[0], tx.outputs): n += 1 + return n + def get_address_flags(self, addr): flags = "C" if self.is_change(addr) else "I" if addr in self.imported_keys.keys() else "-"