twallet: handle exception when deleting last addr from imported wallet - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 4961020e01c515735bb885704fb85c7ae6c73ab1 DIR parent a6b83edec96a2eb3bbb5aab52cb02b241e853438 HTML Author: SomberNight <somber.night@protonmail.com> Date: Wed, 8 Jul 2020 01:28:20 +0200 wallet: handle exception when deleting last addr from imported wallet fixes #6347 Diffstat: M electrum/gui/qt/main_window.py | 7 ++++++- M electrum/wallet.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) --- DIR diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py t@@ -1949,8 +1949,13 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return self.create_list_tab(l) def remove_address(self, addr): - if self.question(_("Do you want to remove {} from your wallet?").format(addr)): + if not self.question(_("Do you want to remove {} from your wallet?").format(addr)): + return + try: self.wallet.delete_address(addr) + except UserFacingException as e: + self.show_error(str(e)) + else: self.need_update.set() # history, addresses, coins self.clear_receive_tab() DIR diff --git a/electrum/wallet.py b/electrum/wallet.py t@@ -2215,7 +2215,7 @@ class Imported_Wallet(Simple_Wallet): if not self.db.has_imported_address(address): return if len(self.get_addresses()) <= 1: - raise Exception("cannot delete last remaining address from wallet") + raise UserFacingException("cannot delete last remaining address from wallet") transactions_to_remove = set() # only referred to by this address transactions_new = set() # txs that are not only referred to by address with self.lock: