twallet.add_contact method - electrum - Electrum Bitcoin wallet (HTM) git clone https://git.parazyd.org/electrum (DIR) Log (DIR) Files (DIR) Refs (DIR) Submodules --- (DIR) commit 8104a47a3e276c17a171cab1e7c33ca70499ec05 (DIR) parent 19d19d9a00795f8002d5f08344c994a1b16d5b81 (HTM) Author: ecdsa <ecdsa@github> Date: Thu, 2 May 2013 10:10:22 +0200 wallet.add_contact method Diffstat: M gui/gui_android.py | 3 +-- M gui/gui_classic.py | 4 +--- M gui/gui_gtk.py | 4 +--- M lib/wallet.py | 8 ++++++++ 4 files changed, 11 insertions(+), 8 deletions(-) --- (DIR) diff --git a/gui/gui_android.py b/gui/gui_android.py t@@ -491,8 +491,7 @@ def make_new_contact(): address = None if address: if modal_question('Add to contacts?', address): - wallet.addressbook.append(address) - wallet.save() + wallet.add_contact(address) else: modal_dialog('Invalid address', data) (DIR) diff --git a/gui/gui_classic.py b/gui/gui_classic.py t@@ -929,7 +929,6 @@ class ElectrumWindow(QMainWindow): self.save_column_widths() self.expert_mode = (i == 1) self.config.set_key('classic_expert_mode', self.expert_mode, True) - self.wallet.save() self.update_receive_tab() t@@ -1233,8 +1232,7 @@ class ElectrumWindow(QMainWindow): address = unicode(text) if ok: if is_valid(address): - self.wallet.addressbook.append(address) - self.wallet.save() + self.wallet.add_contact(address) self.update_contacts_tab() self.update_history_tab() self.update_completions() (DIR) diff --git a/gui/gui_gtk.py b/gui/gui_gtk.py t@@ -1260,9 +1260,7 @@ class ElectrumWindow: if result == 1: if is_valid(address): - self.wallet.addressbook.append(address) - if label: self.wallet.labels[address] = label - self.wallet.save() + self.wallet.add_contact(address,label) self.update_sending_tab() else: errorDialog = gtk.MessageDialog( (DIR) diff --git a/lib/wallet.py b/lib/wallet.py t@@ -412,6 +412,14 @@ class Wallet: return self.history.values() != [[]] * len(self.history) + def add_contact(self, address, label=None): + self.addressbook.append(address) + self.config.set_key('addressbook', self.addressbook, True) + if label: + self.labels[address] = label + self.config.set_key('labels',self.labels) + + def fill_addressbook(self): for tx_hash, tx in self.transactions.items(): is_relevant, is_send, _, _ = self.get_tx_value(tx)