electrum

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

commit 34be8520619269fe01890c79c2116815065d924f
parent e463968da3373a5d8b2a68652c757da414a2debd
Author: thomasv <thomasv@gitorious>
Date:   Thu,  7 Jun 2012 11:18:11 +0200

move freeze and prioritize functions into wallet class

Diffstat:
Melectrum | 30+++++-------------------------
Mlib/gui_qt.py | 10++++------
Mlib/wallet.py | 29+++++++++++++++++++++++++++++
3 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/electrum b/electrum @@ -505,37 +505,17 @@ if __name__ == '__main__': elif cmd == 'freeze': addr = args[1] - if addr in self.wallet.all_addresses() and addr not in self.wallet.frozen_addresses: - self.wallet.frozen_addresses.append(addr) - self.wallet.save() - print True - else: - print False - + print self.wallet.freeze(addr) + elif cmd == 'unfreeze': addr = args[1] - if addr in self.wallet.all_addresses() and addr in self.wallet.frozen_addresses: - self.wallet.frozen_addresses.remove(addr) - self.wallet.save() - print True - else: - print False + print self.wallet.unfreeze(addr) elif cmd == 'prioritize': addr = args[1] - if addr in self.wallet.all_addresses() and addr not in self.wallet.frozen_addresses: - self.wallet.prioritized_addresses.append(addr) - self.wallet.save() - print True - else: - print False + print self.wallet.prioritize(addr) elif cmd == 'unprioritize': addr = args[1] - if addr in self.wallet.all_addresses() and addr in self.wallet.frozen_addresses: - self.wallet.prioritized_addresses.remove(addr) - self.wallet.save() - print True - else: - print False + print self.wallet.unprioritize(addr) diff --git a/lib/gui_qt.py b/lib/gui_qt.py @@ -547,10 +547,9 @@ class ElectrumWindow(QMainWindow): addr = self.get_current_addr(True) if not addr: return if addr in self.wallet.frozen_addresses: - self.wallet.frozen_addresses.remove(addr) + self.wallet.unfreeze(addr) else: - self.wallet.frozen_addresses.append(addr) - self.wallet.save() + self.wallet.freeze(addr) self.update_receive_tab() self.freezeButton = b = EnterButton(_("Freeze"), toggle_freeze) @@ -560,10 +559,9 @@ class ElectrumWindow(QMainWindow): addr = self.get_current_addr(True) if not addr: return if addr in self.wallet.prioritized_addresses: - self.wallet.prioritized_addresses.remove(addr) + self.wallet.unprioritize(addr) else: - self.wallet.prioritized_addresses.append(addr) - self.wallet.save() + self.wallet.prioritize(addr) self.update_receive_tab() self.prioritizeButton = b = EnterButton(_("Prioritize"), toggle_priority) diff --git a/lib/wallet.py b/lib/wallet.py @@ -995,5 +995,34 @@ class Wallet: self.interface.subscribe(self.all_addresses()) + def freeze(self,addr): + if addr in self.all_addresses() and addr not in self.frozen_addresses: + self.frozen_addresses.append(addr) + self.save() + return True + else: + return False + def unfreeze(self,addr): + if addr in self.all_addresses() and addr in self.frozen_addresses: + self.frozen_addresses.remove(addr) + self.save() + return True + else: + return False + def prioritize(self,addr): + if addr in self.all_addresses() and addr not in self.frozen_addresses and addr not in self.prioritized_addresses: + self.prioritized_addresses.append(addr) + self.save() + return True + else: + return False + + def unprioritize(self,addr): + if addr in self.all_addresses() and addr in self.prioritized_addresses: + self.prioritized_addresses.remove(addr) + self.save() + return True + else: + return False