electrum

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

commit 4d7b68658b8b50203de4c7a6722ac88af999d134
parent 27d871277abafa8e8445629446f68d2f554a8bd9
Author: ThomasV <thomasv@gitorious>
Date:   Tue, 31 Mar 2015 11:29:18 +0200

fix delete_contact

Diffstat:
Mlib/wallet.py | 27++++-----------------------
1 file changed, 4 insertions(+), 23 deletions(-)

diff --git a/lib/wallet.py b/lib/wallet.py @@ -159,7 +159,7 @@ class Abstract_Wallet(object): self.seed = storage.get('seed', '') # encrypted self.labels = storage.get('labels', {}) self.frozen_addresses = storage.get('frozen_addresses',[]) - self.addressbook = storage.get('contacts', []) + self.addressbook = set(storage.get('contacts', [])) self.history = storage.get('addr_history',{}) # address -> list(txid, height) self.fee_per_kb = int(storage.get('fee_per_kb', RECOMMENDED_FEE)) @@ -381,34 +381,19 @@ class Abstract_Wallet(object): return self.history.values() != [[]] * len(self.history) def add_contact(self, address, label=None): - self.addressbook.append(address) - self.storage.put('contacts', self.addressbook, True) + self.addressbook.add(address) + self.storage.put('contacts', list(self.addressbook), True) if label: self.set_label(address, label) def delete_contact(self, addr): if addr in self.addressbook: self.addressbook.remove(addr) - self.storage.put('addressbook', self.addressbook, True) - - def fill_addressbook(self): - # todo: optimize this - for tx_hash, tx in self.transactions.viewitems(): - _, is_send, _, _ = self.get_tx_value(tx) - if is_send: - for addr in tx.get_output_addresses(): - if not self.is_mine(addr) and addr not in self.addressbook: - self.addressbook.append(addr) - # redo labels - # self.update_tx_labels() + self.storage.put('contacts', list(self.addressbook), True) def get_num_tx(self, address): """ return number of transactions where address is involved """ return len(self.history.get(address, [])) - #n = 0 - #for tx in self.transactions.values(): - # if address in tx.get_output_addresses(): n += 1 - #return n def get_tx_delta(self, tx_hash, address): "effect of tx on address" @@ -1316,10 +1301,6 @@ class Deterministic_Wallet(Abstract_Wallet): else: self.synchronize() - # disable this because it crashes android - #self.fill_addressbook() - - def is_beyond_limit(self, address, account, is_change): if type(account) == ImportedAccount: return False