From 0d33da2f95951a4b13755927876c9a17b9485f82 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Wed, 12 Feb 2020 17:07:04 +0100 Subject: [PATCH] wallet: (sanity) is_mine now guaranteed to handle 'None' input --- electrum/address_synchronizer.py | 7 ++++--- electrum/wallet.py | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index 0090fec87..e8b2a02b8 100644 --- a/electrum/address_synchronizer.py +++ b/electrum/address_synchronizer.py @@ -40,7 +40,7 @@ from .logging import Logger if TYPE_CHECKING: from .network import Network - from .json_db import JsonDB + from .wallet_db import WalletDB TX_HEIGHT_FUTURE = -3 @@ -70,7 +70,7 @@ class AddressSynchronizer(Logger): inherited by wallet """ - def __init__(self, db: 'JsonDB'): + def __init__(self, db: 'WalletDB'): self.db = db self.network = None # type: Network Logger.__init__(self) @@ -104,7 +104,8 @@ class AddressSynchronizer(Logger): self.load_unverified_transactions() self.remove_local_transactions_we_dont_have() - def is_mine(self, address) -> bool: + def is_mine(self, address: Optional[str]) -> bool: + if not address: return False return self.db.is_addr_in_history(address) def get_addresses(self): diff --git a/electrum/wallet.py b/electrum/wallet.py index 963722f70..07cda97f2 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -407,6 +407,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): return def is_mine(self, address) -> bool: + if not address: return False return bool(self.get_address_index(address)) def is_change(self, address) -> bool: @@ -1985,6 +1986,7 @@ class Imported_Wallet(Simple_Wallet): self.save_db() def is_mine(self, address) -> bool: + if not address: return False return self.db.has_imported_address(address) def get_address_index(self, address) -> Optional[str]: