diff --git a/lib/gui_qt.py b/lib/gui_qt.py index f7e7917fc..a3d0ec718 100644 --- a/lib/gui_qt.py +++ b/lib/gui_qt.py @@ -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) @@ -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" @@ -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: diff --git a/lib/wallet.py b/lib/wallet.py index 540110c00..85e4bdf8a 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -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 @@ -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) ) @@ -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") @@ -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 @@ -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')