tprioritized coins - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit aa7183c6ac29ba9b09575b3f6e9b74125629383c DIR parent 785075cf08f856f4b7663736c55f26077b37eb7b HTML Author: thomasv <thomasv@gitorious> Date: Wed, 6 Jun 2012 15:40:57 +0200 prioritized coins Diffstat: M lib/gui_qt.py | 20 +++++++++++++++++++- M lib/wallet.py | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) --- DIR diff --git a/lib/gui_qt.py b/lib/gui_qt.py t@@ -555,6 +555,19 @@ class ElectrumWindow(QMainWindow): self.freezeButton = b = EnterButton(_("Freeze"), toggle_freeze) hbox.addWidget(b) + + def toggle_priority(): + addr = self.get_current_addr(True) + if not addr: return + if addr in self.wallet.prioritized_addresses: + self.wallet.prioritized_addresses.remove(addr) + else: + self.wallet.prioritized_addresses.append(addr) + self.wallet.save() + self.update_receive_tab() + + self.prioritizeButton = b = EnterButton(_("Set priority"), toggle_priority) + hbox.addWidget(b) hbox.addStretch(1) t@@ -578,7 +591,10 @@ class ElectrumWindow(QMainWindow): addr = self.get_current_addr(True) t = _("Unfreeze") if addr in self.wallet.frozen_addresses else _("Freeze") self.freezeButton.setText(t) - + + t = _("Remove priority") if addr in self.wallet.prioritized_addresses else _("Set priority") + self.prioritizeButton.setText(t) + def create_list_tab(self, headers): "generic tab creatino method" t@@ -660,6 +676,8 @@ class ElectrumWindow(QMainWindow): item = QTreeWidgetItem( [ address, label, balance, tx] ) if address in self.wallet.frozen_addresses: item.setBackgroundColor(0, QColor('lightblue')) + elif address in self.wallet.prioritized_addresses: + item.setBackgroundColor(0, QColor('lightgreen')) item.setFont(0, QFont(MONOSPACE_FONT)) if gap > self.wallet.gap_limit and l == self.receive_list: DIR diff --git a/lib/wallet.py b/lib/wallet.py t@@ -260,6 +260,7 @@ class Wallet: self.aliases = {} # aliases for addresses self.authorities = {} # trusted addresses self.frozen_addresses = [] + self.prioritized_addresses = [] self.receipts = {} # signed URIs self.receipt = None # next receipt t@@ -569,6 +570,7 @@ class Wallet: 'receipts':self.receipts, 'num_zeros':self.num_zeros, 'frozen_addresses':self.frozen_addresses, + 'prioritized_addresses':self.prioritized_addresses, } f = open(self.path,"w") f.write( repr(s) ) t@@ -606,6 +608,7 @@ class Wallet: self.receipts = d.get('receipts',{}) self.num_zeros = d.get('num_zeros',0) self.frozen_addresses = d.get('frozen_addresses',[]) + self.prioritized_addresses = d.get('prioritized_addresses',[]) except: raise BaseException("cannot read wallet file") t@@ -648,10 +651,14 @@ class Wallet: fee = self.fee if fixed_fee is None else fixed_fee coins = [] + prioritized_coins = [] domain = [from_addr] if from_addr else self.all_addresses() for i in self.frozen_addresses: if i in domain: domain.remove(i) + for i in self.prioritized_addresses: + if i in domain: domain.remove(i) + for addr in domain: h = self.history.get(addr) if h is None: continue t@@ -660,7 +667,19 @@ class Wallet: coins.append( (addr,item)) coins = sorted( coins, key = lambda x: x[1]['timestamp'] ) + + for addr in prioritized_addresses: + h = self.history.get(addr) + if h is None: continue + for item in h: + if item.get('raw_output_script'): + prioritized_coins.append( (addr,item)) + + prioritized_coins = sorted( prioritized_coins, key = lambda x: x[1]['timestamp'] ) + inputs = [] + coins = prioritized_coins + coins + for c in coins: addr, item = c v = item.get('value')