Browse Source

daemon: make sure wallet paths are standardised everywhere

sqlite_db
SomberNight 6 years ago
parent
commit
43583c1e28
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/daemon.py

6
electrum/daemon.py

@ -138,6 +138,7 @@ class Daemon(DaemonThread):
if self.network:
self.network.start([self.fx.run])
self.gui = None
# path -> wallet; make sure path is standardized.
self.wallets = {} # type: Dict[str, Abstract_Wallet]
# Setup JSONRPC server
self.server = None
@ -188,6 +189,7 @@ class Daemon(DaemonThread):
response = wallet is not None
elif sub == 'close_wallet':
path = config.get_wallet_path()
path = standardize_path(path)
if path in self.wallets:
self.stop_wallet(path)
response = True
@ -258,9 +260,11 @@ class Daemon(DaemonThread):
def add_wallet(self, wallet: Abstract_Wallet):
path = wallet.storage.path
path = standardize_path(path)
self.wallets[path] = wallet
def get_wallet(self, path):
path = standardize_path(path)
return self.wallets.get(path)
def delete_wallet(self, path):
@ -271,6 +275,7 @@ class Daemon(DaemonThread):
return False
def stop_wallet(self, path):
path = standardize_path(path)
wallet = self.wallets.pop(path, None)
if not wallet: return
wallet.stop_threads()
@ -287,6 +292,7 @@ class Daemon(DaemonThread):
cmd = known_commands[cmdname]
if cmd.requires_wallet:
path = config.get_wallet_path()
path = standardize_path(path)
wallet = self.wallets.get(path)
if wallet is None:
return {'error': 'Wallet "%s" is not loaded. Use "electrum daemon load_wallet"'%os.path.basename(path) }

Loading…
Cancel
Save