Browse Source

Default to unused address for privkey sweeps

Fixes #1506

- New function wallet.get_unused_addresses
- Have wallet.get_unused_address use it
- Use it for the sweep key dialog
283
Neil Booth 9 years ago
parent
commit
97568bedf5
  1. 3
      gui/qt/main_window.py
  2. 12
      lib/wallet.py

3
gui/qt/main_window.py

@ -2482,7 +2482,8 @@ class ElectrumWindow(QMainWindow, PrintError):
keys_e.setTabChangesFocus(True)
vbox.addWidget(keys_e)
h, address_e = address_field(self.wallet.addresses(False))
addresses = self.wallet.get_unused_addresses(self.current_account)
h, address_e = address_field(addresses)
vbox.addLayout(h)
vbox.addStretch(1)

12
lib/wallet.py

@ -1258,12 +1258,16 @@ class Abstract_Wallet(PrintError):
def can_change_password(self):
return not self.is_watching_only()
def get_unused_address(self, account):
def get_unused_addresses(self, account):
# fixme: use slots from expired requests
domain = self.get_account_addresses(account, include_change=False)
for addr in domain:
if not self.history.get(addr) and addr not in self.receive_requests.keys():
return addr
return [addr for addr in domain if not self.history.get(addr)
and addr not in self.receive_requests.keys()]
def get_unused_address(self, account):
addrs = self.get_unused_addresses(account)
if addrs:
return addrs[0]
def get_payment_request(self, addr, config):
import util

Loading…
Cancel
Save