mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 17:01:34 +00:00
daemon: make sure wallet paths are standardised everywhere
This commit is contained in:
parent
d11481f360
commit
43583c1e28
1 changed files with 6 additions and 0 deletions
|
@ -138,6 +138,7 @@ class Daemon(DaemonThread):
|
||||||
if self.network:
|
if self.network:
|
||||||
self.network.start([self.fx.run])
|
self.network.start([self.fx.run])
|
||||||
self.gui = None
|
self.gui = None
|
||||||
|
# path -> wallet; make sure path is standardized.
|
||||||
self.wallets = {} # type: Dict[str, Abstract_Wallet]
|
self.wallets = {} # type: Dict[str, Abstract_Wallet]
|
||||||
# Setup JSONRPC server
|
# Setup JSONRPC server
|
||||||
self.server = None
|
self.server = None
|
||||||
|
@ -188,6 +189,7 @@ class Daemon(DaemonThread):
|
||||||
response = wallet is not None
|
response = wallet is not None
|
||||||
elif sub == 'close_wallet':
|
elif sub == 'close_wallet':
|
||||||
path = config.get_wallet_path()
|
path = config.get_wallet_path()
|
||||||
|
path = standardize_path(path)
|
||||||
if path in self.wallets:
|
if path in self.wallets:
|
||||||
self.stop_wallet(path)
|
self.stop_wallet(path)
|
||||||
response = True
|
response = True
|
||||||
|
@ -258,9 +260,11 @@ class Daemon(DaemonThread):
|
||||||
|
|
||||||
def add_wallet(self, wallet: Abstract_Wallet):
|
def add_wallet(self, wallet: Abstract_Wallet):
|
||||||
path = wallet.storage.path
|
path = wallet.storage.path
|
||||||
|
path = standardize_path(path)
|
||||||
self.wallets[path] = wallet
|
self.wallets[path] = wallet
|
||||||
|
|
||||||
def get_wallet(self, path):
|
def get_wallet(self, path):
|
||||||
|
path = standardize_path(path)
|
||||||
return self.wallets.get(path)
|
return self.wallets.get(path)
|
||||||
|
|
||||||
def delete_wallet(self, path):
|
def delete_wallet(self, path):
|
||||||
|
@ -271,6 +275,7 @@ class Daemon(DaemonThread):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def stop_wallet(self, path):
|
def stop_wallet(self, 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
|
||||||
wallet.stop_threads()
|
wallet.stop_threads()
|
||||||
|
@ -287,6 +292,7 @@ class Daemon(DaemonThread):
|
||||||
cmd = known_commands[cmdname]
|
cmd = known_commands[cmdname]
|
||||||
if cmd.requires_wallet:
|
if cmd.requires_wallet:
|
||||||
path = config.get_wallet_path()
|
path = config.get_wallet_path()
|
||||||
|
path = standardize_path(path)
|
||||||
wallet = self.wallets.get(path)
|
wallet = self.wallets.get(path)
|
||||||
if wallet is None:
|
if wallet is None:
|
||||||
return {'error': 'Wallet "%s" is not loaded. Use "electrum daemon load_wallet"'%os.path.basename(path) }
|
return {'error': 'Wallet "%s" is not loaded. Use "electrum daemon load_wallet"'%os.path.basename(path) }
|
||||||
|
|
Loading…
Add table
Reference in a new issue