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