electrum

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

commit 8104a47a3e276c17a171cab1e7c33ca70499ec05
parent 19d19d9a00795f8002d5f08344c994a1b16d5b81
Author: ecdsa <ecdsa@github>
Date:   Thu,  2 May 2013 10:10:22 +0200

wallet.add_contact method

Diffstat:
Mgui/gui_android.py | 3+--
Mgui/gui_classic.py | 4+---
Mgui/gui_gtk.py | 4+---
Mlib/wallet.py | 8++++++++
4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/gui/gui_android.py b/gui/gui_android.py @@ -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) diff --git a/gui/gui_classic.py b/gui/gui_classic.py @@ -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() @@ -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() diff --git a/gui/gui_gtk.py b/gui/gui_gtk.py @@ -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( diff --git a/lib/wallet.py b/lib/wallet.py @@ -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)