|
|
@ -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) } |
|
|
|