Browse Source

commands: fix "close_wallet"

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 5 years ago
parent
commit
9d65120e59
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 12
      electrum/commands.py
  2. 7
      electrum/daemon.py

12
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):

7
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')

Loading…
Cancel
Save