electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit a8c23f9bf08a206904c7d1892ad1bf583660e6ad
parent 0f424a9da4fbfba11d20fbe465f75661893093e9
Author: ThomasV <thomasv@electrum.org>
Date:   Wed,  4 Jan 2017 19:09:14 +0100

always display a receiving address (fix #2031)

Diffstat:
Mgui/kivy/uix/screens.py | 9++++++---
Mgui/qt/main_window.py | 4++--
Mgui/text.py | 2+-
Mlib/wallet.py | 12++++++++++++
4 files changed, 21 insertions(+), 6 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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)