electrum

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

commit c3676cc6e6eef26b9fcddf681fb6a6c5c8e9284e
parent a66df2a3fa77d85434a6fc36bc03df8ff8f58bb4
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 12 May 2014 11:28:00 +0200

wallet.is_used() method

Diffstat:
Mgui/qt/main_window.py | 13++++++-------
Mlib/wallet.py | 7+++++++
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1187,6 +1187,7 @@ class ElectrumWindow(QMainWindow): l = self.receive_list # extend the syntax for consistency l.addChild = l.addTopLevelItem + l.insertChild = l.insertTopLevelItem l.clear() for i,width in enumerate(self.column_widths['receive']): @@ -1229,23 +1230,21 @@ class ElectrumWindow(QMainWindow): gap = 0 for address in account.get_addresses(is_change): - h = self.wallet.history.get(address,[]) - if h == []: + num, is_used = self.wallet.is_used(address) + if num == 0: gap += 1 if gap > self.wallet.gap_limit: is_red = True else: gap = 0 - c, u = self.wallet.get_addr_balance(address) - num_tx = '*' if h == ['*'] else "%d"%len(h) - - item = QTreeWidgetItem( [ address, '', '', num_tx] ) + item = QTreeWidgetItem( [ address, '', '', "%d"%num] ) self.update_receive_item(item) if is_red: item.setBackgroundColor(1, QColor('red')) - if len(h) > 0 and c == -u: + + if is_used: if not used_flag: seq_item.insertChild(0,used_item) used_flag = True diff --git a/lib/wallet.py b/lib/wallet.py @@ -1073,6 +1073,10 @@ class Abstract_Wallet: def can_import(self): return not self.is_watching_only() + def is_used(self, address): + h = self.history.get(address,[]) + c, u = self.get_addr_balance(address) + return len(h), len(h) > 0 and c == -u class Imported_Wallet(Abstract_Wallet): @@ -1098,6 +1102,9 @@ class Imported_Wallet(Abstract_Wallet): def check_password(self, password): self.accounts[IMPORTED_ACCOUNT].get_private_key((0,0), self, password) + def is_used(self, address): + h = self.history.get(address,[]) + return len(h), False class Deterministic_Wallet(Abstract_Wallet):