diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py index 3f315c28d..7b082c571 100644 --- a/gui/kivy/uix/screens.py +++ b/gui/kivy/uix/screens.py @@ -330,12 +330,15 @@ class ReceiveScreen(CScreen): def get_new_address(self): if not self.app.wallet: return False + self.clear() addr = self.app.wallet.get_unused_address() if addr is None: - return False - self.clear() + addr = self.app.wallet.get_receiving_address() + b = False + else: + b = True self.screen.address = addr - return True + return b def on_address(self, addr): req = self.app.wallet.get_payment_request(addr, self.app.electrum_config) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 007dc0ede..2b4db2816 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -877,8 +877,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.receive_amount_e.setAmount(None) def clear_receive_tab(self): - addr = self.wallet.get_unused_address() - self.receive_address_e.setText(addr if addr else '') + addr = self.wallet.get_receiving_address() + self.receive_address_e.setText(addr) self.receive_message_e.setText('') self.receive_amount_e.setAmount(None) self.expires_label.hide() diff --git a/gui/text.py b/gui/text.py index f477beb2d..4680f5441 100644 --- a/gui/text.py +++ b/gui/text.py @@ -146,7 +146,7 @@ class ElectrumGui: self.stdscr.addstr(self.maxy -1, self.maxx-30, ' '.join([_("Settings"), _("Network"), _("Quit")])) def print_receive(self): - addr = self.wallet.get_unused_address() + addr = self.wallet.get_receiving_address() self.stdscr.addstr(2, 1, "Address: "+addr) self.print_qr(addr) diff --git a/lib/wallet.py b/lib/wallet.py index 10eb1ec95..4e89008c0 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -1119,6 +1119,18 @@ class Abstract_Wallet(PrintError): if addrs: return addrs[0] + def get_receiving_address(self): + # always return an address + domain = self.get_receiving_addresses() + choice = domain[0] + for addr in domain: + if addr not in self.history.keys(): + if addr not in self.receive_requests.keys(): + return addr + else: + choice = addr + return choice + def get_payment_status(self, address, amount): local_height = self.get_local_height() received, sent = self.get_addr_io(address)