commit 1020449684a4a12eea85e7f51670a8eb35316873
parent 7c702b518d7188d3ca5ccbb68d35a913d3ab061a
Author: ThomasV <thomasv@electrum.org>
Date: Sun, 7 Jan 2018 23:53:25 +0100
disable jsonrpc commands in the GUI
Diffstat:
2 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/electrum b/electrum
@@ -372,7 +372,7 @@ if __name__ == '__main__':
fd, server = daemon.get_fd_or_server(config)
if fd is not None:
plugins = init_plugins(config, config.get('gui', 'qt'))
- d = daemon.Daemon(config, fd, is_android)
+ d = daemon.Daemon(config, fd, True)
d.start()
d.init_gui(config, plugins)
sys.exit(0)
@@ -393,7 +393,7 @@ if __name__ == '__main__':
print_stderr("starting daemon (PID %d)" % pid)
sys.exit(0)
init_plugins(config, 'cmdline')
- d = daemon.Daemon(config, fd, is_android)
+ d = daemon.Daemon(config, fd, False)
d.start()
if config.get('websocket_server'):
from electrum import websockets
@@ -425,7 +425,6 @@ if __name__ == '__main__':
else:
init_plugins(config, 'cmdline')
result = run_offline_command(config, config_options)
-
# print result
if isinstance(result, str):
print_msg(result)
diff --git a/lib/daemon.py b/lib/daemon.py
@@ -89,7 +89,7 @@ def get_server(config):
class Daemon(DaemonThread):
- def __init__(self, config, fd, is_android):
+ def __init__(self, config, fd, is_gui):
DaemonThread.__init__(self)
self.config = config
if config.get('offline'):
@@ -103,14 +103,10 @@ class Daemon(DaemonThread):
self.gui = None
self.wallets = {}
- if not is_android:
- # Setup JSONRPC server
- self.cmd_runner = Commands(self.config, None, self.network)
- self.init_server(config, fd)
- else:
- self.server = None
+ # Setup JSONRPC server
+ self.init_server(config, fd, is_gui)
- def init_server(self, config, fd):
+ def init_server(self, config, fd, is_gui):
host = config.get('rpchost', '127.0.0.1')
port = config.get('rpcport', 0)
try:
@@ -122,14 +118,17 @@ class Daemon(DaemonThread):
return
os.write(fd, bytes(repr((server.socket.getsockname(), time.time())), 'utf8'))
os.close(fd)
+ self.server = server
server.timeout = 0.1
- for cmdname in known_commands:
- server.register_function(getattr(self.cmd_runner, cmdname), cmdname)
- server.register_function(self.run_cmdline, 'run_cmdline')
server.register_function(self.ping, 'ping')
- server.register_function(self.run_daemon, 'daemon')
- server.register_function(self.run_gui, 'gui')
- self.server = server
+ if is_gui:
+ server.register_function(self.run_gui, 'gui')
+ else:
+ server.register_function(self.run_daemon, 'daemon')
+ self.cmd_runner = Commands(self.config, None, self.network)
+ for cmdname in known_commands:
+ server.register_function(getattr(self.cmd_runner, cmdname), cmdname)
+ server.register_function(self.run_cmdline, 'run_cmdline')
def ping(self):
return True
@@ -178,12 +177,13 @@ class Daemon(DaemonThread):
def run_gui(self, config_options):
config = SimpleConfig(config_options)
if self.gui:
- if hasattr(self.gui, 'new_window'):
- path = config.get_wallet_path()
- self.gui.new_window(path, config.get('url'))
- response = "ok"
- else:
- response = "error: current GUI does not support multiple windows"
+ #if hasattr(self.gui, 'new_window'):
+ # path = config.get_wallet_path()
+ # self.gui.new_window(path, config.get('url'))
+ # response = "ok"
+ #else:
+ # response = "error: current GUI does not support multiple windows"
+ response = "error: Electrum GUI already running"
else:
response = "Error: Electrum is running in daemon mode. Please stop the daemon first."
return response