commit 97568bedf59d6c738b19691c81b2ecd74035c08c
parent 7d0d2f20976c7f0867f88f28b0d000ec9158b9ad
Author: Neil Booth <kyuupichan@gmail.com>
Date: Mon, 26 Oct 2015 20:31:41 +0900
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
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/gui/qt/main_window.py b/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)
diff --git a/lib/wallet.py b/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