electrum

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

commit 0c440ee6a6dfc246d943b90ebcf70874cec50e7f
parent 2e410a63687d4299fc3cb3e3deceae7f8d387a8a
Author: ThomasV <thomasv@gitorious>
Date:   Tue, 24 Jun 2014 20:47:44 +0200

wallet.is_beyond_limit (False for imported accounts)

Diffstat:
Mgui/qt/main_window.py | 50+++++++++++++-------------------------------------
Mlib/wallet.py | 18++++++++++++++++++
2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -1491,24 +1491,6 @@ class ElectrumWindow(QMainWindow): menu.exec_(self.invoices_list.viewport().mapToGlobal(position)) - def update_address_item(self, item): - item.setFont(0, QFont(MONOSPACE_FONT)) - address = str(item.data(0,0).toString()) - label = self.wallet.labels.get(address,'') - item.setData(1,0,label) - item.setData(0,32, True) # is editable - - run_hook('update_address_item', address, item) - - if not self.wallet.is_mine(address): return - - c, u = self.wallet.get_addr_balance(address) - balance = self.format_amount(c + u) - item.setData(2,0,balance) - - if address in self.wallet.frozen_addresses: - item.setBackgroundColor(0, QColor('lightblue')) - def update_address_tab(self): l = self.address_list @@ -1551,27 +1533,22 @@ class ElectrumWindow(QMainWindow): used_item = QTreeWidgetItem( [ _("Used"), '', '', '', ''] ) used_flag = False - is_red = False - gap = 0 - - for address in account.get_addresses(is_change): - + addr_list = account.get_addresses(is_change) + for address in addr_list: 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 - - item = QTreeWidgetItem( [ address, '', '', "%d"%num] ) - self.update_address_item(item) - if is_red: - item.setBackgroundColor(1, QColor('red')) - + label = self.wallet.labels.get(address,'') + c, u = self.wallet.get_addr_balance(address) + balance = self.format_amount(c + u) + item = QTreeWidgetItem( [ address, label, balance, "%d"%num] ) + item.setFont(0, QFont(MONOSPACE_FONT)) + item.setData(0, 32, True) # label can be edited + if address in self.wallet.frozen_addresses: + item.setBackgroundColor(0, QColor('lightblue')) + if self.wallet.is_beyond_limit(address, account, is_change): + item.setBackgroundColor(0, QColor('red')) if is_used: if not used_flag: - seq_item.insertChild(0,used_item) + seq_item.insertChild(0, used_item) used_flag = True used_item.addChild(item) else: @@ -1600,7 +1577,6 @@ class ElectrumWindow(QMainWindow): l.setCurrentItem(l.topLevelItem(0)) - def create_console_tab(self): from console import Console self.console = console = Console() diff --git a/lib/wallet.py b/lib/wallet.py @@ -1051,6 +1051,8 @@ class Imported_Wallet(Abstract_Wallet): def get_master_public_keys(self): return {} + def is_beyond_limit(self, address, account, is_change): + return False class Deterministic_Wallet(Abstract_Wallet): @@ -1239,6 +1241,22 @@ class Deterministic_Wallet(Abstract_Wallet): self.accounts[account_id] = PendingAccount({'pending':addr}) self.save_accounts() + def is_beyond_limit(self, address, account, is_change): + if type(account) == ImportedAccount: + return False + addr_list = account.get_addresses(is_change) + i = addr_list.index(address) + prev_addresses = addr_list[:max(0, i)] + limit = self.gap_limit_for_change if is_change else self.gap_limit + if len(prev_addresses) < limit: + return False + prev_addresses = prev_addresses[max(0, i - limit):] + for addr in prev_addresses: + num, is_used = self.is_used(addr) + if num > 0: + return False + return True + class NewWallet(Deterministic_Wallet):