electrum

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

commit 9d65120e596afd0e5805ce420b098e8b656e9505
parent 1bd9b3a66aac28d2ff2c556370c26138bf23de09
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed,  4 Sep 2019 20:16:47 +0200

commands: fix "close_wallet"

Diffstat:
Melectrum/commands.py | 12++++--------
Melectrum/daemon.py | 7+++++--
2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/electrum/commands.py b/electrum/commands.py @@ -58,6 +58,7 @@ from .simple_config import SimpleConfig if TYPE_CHECKING: from .network import Network + from .daemon import Daemon known_commands = {} @@ -111,7 +112,8 @@ class Commands: def __init__(self, config: 'SimpleConfig', wallet: Abstract_Wallet, - network: Optional['Network'], daemon=None, callback=None): + network: Optional['Network'], + daemon: 'Daemon' = None, callback=None): self.config = config self.wallet = wallet self.daemon = daemon @@ -190,13 +192,7 @@ class Commands: async def close_wallet(self): """Close wallet""" path = self.config.get_wallet_path() - path = standardize_path(path) - if path in self.wallets: - self.stop_wallet(path) - response = True - else: - response = False - return response + return self.daemon.stop_wallet(path) @command('') async def create(self, passphrase=None, password=None, encrypt_file=True, seed_type=None): diff --git a/electrum/daemon.py b/electrum/daemon.py @@ -394,11 +394,14 @@ class Daemon(Logger): return True return False - def stop_wallet(self, path): + def stop_wallet(self, path) -> bool: + """Returns True iff a wallet was found.""" path = standardize_path(path) wallet = self.wallets.pop(path, None) - if not wallet: return + if not wallet: + return False wallet.stop_threads() + return True async def run_cmdline(self, config_options): password = config_options.get('password')