electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 0200778ac1adbe6d2a4068c2afa86a25a786f8ac
parent 9a7f6afac3a9755f02a1418379a299e872a844d0
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 23 Mar 2015 11:50:13 +0100

require user to start daemon explicitly

Diffstat:
Melectrum | 14+++++++++-----
Mlib/daemon.py | 8++++----
2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/electrum b/electrum @@ -110,7 +110,6 @@ def arg_parser(): parser.add_option("-g", "--gui", dest="gui", help="User interface: qt, lite, gtk, text or stdio") parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path") parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline") - parser.add_option("-d", "--daemon", action="store_true", dest="daemon", default=False, help="use daemon") parser.add_option("-C", "--concealed", action="store_true", dest="concealed", default=False, help="don't echo seed to console when restoring") parser.add_option("-a", "--all", action="store_true", dest="show_all", default=False, help="show all addresses") parser.add_option("-l", "--labels", action="store_true", dest="show_labels", default=False, help="show the labels of listed addresses") @@ -148,7 +147,10 @@ def run_command(cmd, password=None, args=None): if args is None: args = [] # Do not use mutables as default values! if cmd.requires_network and not options.offline: - s = get_daemon(config, True) + s = get_daemon(config, False) + if not s: + print_msg("Network daemon is not running. Try 'electrum daemon start'") + sys.exit(1) network = NetworkProxy(s, config) network.start() while network.is_connecting(): @@ -238,7 +240,9 @@ if __name__ == '__main__': # network interface if not options.offline: - s = get_daemon(config, start_daemon=options.daemon) + s = get_daemon(config, False) + if s: + print_msg("Connected to daemon") network = NetworkProxy(s, config) network.start() else: @@ -335,8 +339,8 @@ if __name__ == '__main__': wallet.create_main_account(password) if not options.offline: - s = get_daemon(config, True) - network = NetworkProxy(s,config) + s = get_daemon(config, False) + network = NetworkProxy(s, config) network.start() wallet.start_threads(network) print_msg("Recovering wallet...") diff --git a/lib/daemon.py b/lib/daemon.py @@ -41,7 +41,7 @@ def do_start_daemon(config): -def get_daemon(config, start_daemon=True): +def get_daemon(config, start_daemon): import socket daemon_socket = os.path.join(config.path, DAEMON_SOCKET) daemon_started = False @@ -49,8 +49,6 @@ def get_daemon(config, start_daemon=True): try: s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) s.connect(daemon_socket) - if not daemon_started: - print_stderr("Connected to daemon") return s except socket.error: if not start_daemon: @@ -180,7 +178,7 @@ def daemon_loop(server): daemon_socket = os.path.join(server.config.path, DAEMON_SOCKET) if os.path.exists(daemon_socket): os.remove(daemon_socket) - daemon_timeout = server.config.get('daemon_timeout', 5*60) + daemon_timeout = server.config.get('daemon_timeout', None) s.bind(daemon_socket) s.listen(5) s.settimeout(1) @@ -189,6 +187,8 @@ def daemon_loop(server): try: connection, address = s.accept() except socket.timeout: + if daemon_timeout is None: + continue if not server.clients: if time.time() - t > daemon_timeout: print_error("Daemon timeout")