2019-07-21 18:50:32 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2024-02-07 20:48:34 +00:00
|
|
|
# Copyright (c) 2019-2024 tecnovert
|
2019-07-21 18:50:32 +00:00
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2020-10-30 08:55:45 +00:00
|
|
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
import os
|
2020-12-02 21:19:10 +00:00
|
|
|
import sys
|
2019-07-21 18:50:32 +00:00
|
|
|
import json
|
2021-11-15 08:48:43 +00:00
|
|
|
import shutil
|
2019-07-21 18:50:32 +00:00
|
|
|
import signal
|
|
|
|
import logging
|
2020-12-02 21:19:10 +00:00
|
|
|
import traceback
|
|
|
|
import subprocess
|
|
|
|
|
2020-02-01 18:57:20 +00:00
|
|
|
import basicswap.config as cfg
|
2019-07-21 18:50:32 +00:00
|
|
|
from basicswap import __version__
|
2022-10-24 18:49:36 +00:00
|
|
|
from basicswap.ui.util import getCoinName
|
2019-07-31 16:53:44 +00:00
|
|
|
from basicswap.basicswap import BasicSwap
|
2019-07-21 18:50:32 +00:00
|
|
|
from basicswap.http_server import HttpThread
|
2022-07-31 17:33:01 +00:00
|
|
|
from basicswap.contrib.websocket_server import WebsocketServer
|
2019-07-21 18:50:32 +00:00
|
|
|
|
2023-12-18 13:15:16 +00:00
|
|
|
|
2019-07-21 18:50:32 +00:00
|
|
|
logger = logging.getLogger()
|
|
|
|
logger.level = logging.DEBUG
|
|
|
|
if not len(logger.handlers):
|
|
|
|
logger.addHandler(logging.StreamHandler(sys.stdout))
|
|
|
|
|
|
|
|
swap_client = None
|
2023-12-18 13:15:16 +00:00
|
|
|
# TODO: deduplicate
|
|
|
|
known_coins = [
|
|
|
|
'particl',
|
|
|
|
'litecoin',
|
|
|
|
'bitcoin',
|
|
|
|
'namecoin',
|
|
|
|
'monero',
|
|
|
|
'pivx',
|
|
|
|
'dash',
|
|
|
|
'firo',
|
|
|
|
'navcoin',
|
|
|
|
]
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def signal_handler(sig, frame):
|
2019-08-15 22:31:39 +00:00
|
|
|
global swap_client
|
2019-07-21 18:50:32 +00:00
|
|
|
logger.info('Signal %d detected, ending program.' % (sig))
|
|
|
|
if swap_client is not None:
|
|
|
|
swap_client.stopRunning()
|
|
|
|
|
|
|
|
|
2019-07-21 21:27:46 +00:00
|
|
|
def startDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
|
2019-07-23 14:26:37 +00:00
|
|
|
daemon_bin = os.path.expanduser(os.path.join(bin_dir, daemon_bin))
|
2019-07-21 18:50:32 +00:00
|
|
|
|
2021-12-10 14:29:00 +00:00
|
|
|
datadir_path = os.path.expanduser(node_dir)
|
|
|
|
args = [daemon_bin, '-datadir=' + datadir_path] + opts
|
2020-11-07 11:08:07 +00:00
|
|
|
logging.info('Starting node ' + daemon_bin + ' ' + '-datadir=' + node_dir)
|
2021-12-10 14:29:00 +00:00
|
|
|
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=datadir_path)
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
|
2020-12-03 23:46:01 +00:00
|
|
|
def startXmrDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
|
|
|
|
daemon_bin = os.path.expanduser(os.path.join(bin_dir, daemon_bin))
|
|
|
|
|
2021-12-10 14:29:00 +00:00
|
|
|
datadir_path = os.path.expanduser(node_dir)
|
|
|
|
args = [daemon_bin, '--non-interactive', '--config-file=' + os.path.join(datadir_path, 'monerod.conf')] + opts
|
2020-12-03 23:46:01 +00:00
|
|
|
logging.info('Starting node {} --data-dir={}'.format(daemon_bin, node_dir))
|
|
|
|
|
2021-01-05 08:23:30 +00:00
|
|
|
# return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
2021-12-10 14:29:00 +00:00
|
|
|
file_stdout = open(os.path.join(datadir_path, 'core_stdout.log'), 'w')
|
|
|
|
file_stderr = open(os.path.join(datadir_path, 'core_stderr.log'), 'w')
|
|
|
|
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=file_stdout, stderr=file_stderr, cwd=datadir_path)
|
2020-12-03 23:46:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def startXmrWalletDaemon(node_dir, bin_dir, wallet_bin, opts=[]):
|
|
|
|
daemon_bin = os.path.expanduser(os.path.join(bin_dir, wallet_bin))
|
|
|
|
|
|
|
|
data_dir = os.path.expanduser(node_dir)
|
2021-11-15 08:48:43 +00:00
|
|
|
config_path = os.path.join(data_dir, 'monero_wallet.conf')
|
|
|
|
args = [daemon_bin, '--non-interactive', '--config-file=' + config_path] + opts
|
|
|
|
|
2024-02-10 02:09:08 +00:00
|
|
|
# Remove old config
|
|
|
|
needs_rewrite: bool = False
|
|
|
|
config_to_remove = ['daemon-address=', 'untrusted-daemon=', 'trusted-daemon=', 'proxy=']
|
2021-11-15 08:48:43 +00:00
|
|
|
with open(config_path) as fp:
|
|
|
|
for line in fp:
|
2024-02-10 02:09:08 +00:00
|
|
|
if any(line.startswith(config_line) for config_line in config_to_remove):
|
|
|
|
logging.warning('Found old config in monero_wallet.conf: {}'.format(line.strip()))
|
|
|
|
needs_rewrite = True
|
|
|
|
if needs_rewrite:
|
2021-11-15 08:48:43 +00:00
|
|
|
logging.info('Rewriting monero_wallet.conf')
|
|
|
|
shutil.copyfile(config_path, config_path + '.last')
|
|
|
|
with open(config_path + '.last') as fp_from, open(config_path, 'w') as fp_to:
|
|
|
|
for line in fp_from:
|
2024-02-10 02:09:08 +00:00
|
|
|
if not any(line.startswith(config_line) for config_line in config_to_remove):
|
2021-11-15 08:48:43 +00:00
|
|
|
fp_to.write(line)
|
2020-12-03 23:46:01 +00:00
|
|
|
|
|
|
|
logging.info('Starting wallet daemon {} --wallet-dir={}'.format(daemon_bin, node_dir))
|
|
|
|
|
2020-12-04 21:30:20 +00:00
|
|
|
# TODO: return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=data_dir)
|
2020-12-03 23:46:01 +00:00
|
|
|
wallet_stdout = open(os.path.join(data_dir, 'wallet_stdout.log'), 'w')
|
|
|
|
wallet_stderr = open(os.path.join(data_dir, 'wallet_stderr.log'), 'w')
|
|
|
|
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=wallet_stdout, stderr=wallet_stderr, cwd=data_dir)
|
|
|
|
|
2020-12-04 21:30:20 +00:00
|
|
|
|
2022-07-31 17:33:01 +00:00
|
|
|
def ws_new_client(client, server):
|
|
|
|
if swap_client:
|
|
|
|
swap_client.log.debug(f'ws_new_client {client["id"]}')
|
|
|
|
|
|
|
|
|
|
|
|
def ws_client_left(client, server):
|
|
|
|
if client is None:
|
|
|
|
return
|
|
|
|
if swap_client:
|
|
|
|
swap_client.log.debug(f'ws_client_left {client["id"]}')
|
|
|
|
|
|
|
|
|
|
|
|
def ws_message_received(client, server, message):
|
|
|
|
if len(message) > 200:
|
|
|
|
message = message[:200] + '..'
|
|
|
|
if swap_client:
|
|
|
|
swap_client.log.debug(f'ws_message_received {client["id"]} {message}')
|
|
|
|
|
|
|
|
|
2023-12-18 13:15:16 +00:00
|
|
|
def runClient(fp, data_dir, chain, start_only_coins):
|
2019-07-21 18:50:32 +00:00
|
|
|
global swap_client
|
2022-11-16 22:36:13 +00:00
|
|
|
daemons = []
|
|
|
|
pids = []
|
|
|
|
threads = []
|
2020-02-01 18:57:20 +00:00
|
|
|
settings_path = os.path.join(data_dir, cfg.CONFIG_FILENAME)
|
2019-07-25 13:28:44 +00:00
|
|
|
pids_path = os.path.join(data_dir, '.pids')
|
2019-07-21 18:50:32 +00:00
|
|
|
|
2022-11-16 22:36:13 +00:00
|
|
|
if os.getenv('WALLET_ENCRYPTION_PWD', '') != '':
|
|
|
|
raise ValueError('Please unset the WALLET_ENCRYPTION_PWD environment variable.')
|
|
|
|
|
2019-07-21 18:50:32 +00:00
|
|
|
if not os.path.exists(settings_path):
|
|
|
|
raise ValueError('Settings file not found: ' + str(settings_path))
|
|
|
|
|
|
|
|
with open(settings_path) as fs:
|
|
|
|
settings = json.load(fs)
|
|
|
|
|
2019-07-31 16:38:19 +00:00
|
|
|
swap_client = BasicSwap(fp, data_dir, settings, chain)
|
|
|
|
|
2019-07-25 13:28:44 +00:00
|
|
|
if os.path.exists(pids_path):
|
|
|
|
with open(pids_path) as fd:
|
|
|
|
for ln in fd:
|
|
|
|
# TODO: try close
|
|
|
|
logger.warning('Found pid for daemon {} '.format(ln.strip()))
|
2019-07-21 18:50:32 +00:00
|
|
|
|
2019-07-31 16:38:19 +00:00
|
|
|
# Ensure daemons are stopped
|
|
|
|
swap_client.stopDaemons()
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
try:
|
2019-07-31 16:38:19 +00:00
|
|
|
# Try start daemons
|
|
|
|
for c, v in settings['chainclients'].items():
|
2023-12-18 13:15:16 +00:00
|
|
|
|
|
|
|
if len(start_only_coins) > 0 and c not in start_only_coins:
|
|
|
|
continue
|
2022-10-24 18:49:36 +00:00
|
|
|
try:
|
|
|
|
coin_id = swap_client.getCoinIdFromName(c)
|
|
|
|
display_name = getCoinName(coin_id)
|
|
|
|
except Exception as e:
|
|
|
|
logger.warning('Error getting coin display name for {}: {}'.format(c, str(e)))
|
|
|
|
display_name = 'Unknown'
|
2020-12-03 23:46:01 +00:00
|
|
|
if c == 'monero':
|
|
|
|
if v['manage_daemon'] is True:
|
2022-10-24 18:49:36 +00:00
|
|
|
swap_client.log.info(f'Starting {display_name} daemon')
|
2022-12-02 23:07:41 +00:00
|
|
|
filename = 'monerod' + ('.exe' if os.name == 'nt' else '')
|
|
|
|
daemons.append(startXmrDaemon(v['datadir'], v['bindir'], filename))
|
2020-12-03 23:46:01 +00:00
|
|
|
pid = daemons[-1].pid
|
2022-12-02 23:07:41 +00:00
|
|
|
swap_client.log.info('Started {} {}'.format(filename, pid))
|
2020-12-03 23:46:01 +00:00
|
|
|
|
|
|
|
if v['manage_wallet_daemon'] is True:
|
2022-10-24 18:49:36 +00:00
|
|
|
swap_client.log.info(f'Starting {display_name} wallet daemon')
|
2021-11-15 08:48:43 +00:00
|
|
|
daemon_addr = '{}:{}'.format(v['rpchost'], v['rpcport'])
|
2024-02-08 20:40:14 +00:00
|
|
|
trusted_daemon: bool = swap_client.getXMRTrustedDaemon(coin_id, v['rpchost'])
|
2021-11-15 08:48:43 +00:00
|
|
|
opts = ['--daemon-address', daemon_addr, ]
|
2024-02-08 08:43:02 +00:00
|
|
|
|
|
|
|
proxy_log_str = ''
|
2024-02-08 20:40:14 +00:00
|
|
|
proxy_host, proxy_port = swap_client.getXMRWalletProxy(coin_id, v['rpchost'])
|
2024-02-08 08:43:02 +00:00
|
|
|
if proxy_host:
|
|
|
|
proxy_log_str = ' through proxy'
|
|
|
|
opts += ['--proxy', f'{proxy_host}:{proxy_port}', ]
|
|
|
|
|
|
|
|
swap_client.log.info('daemon-address: {} ({}){}'.format(daemon_addr, 'trusted' if trusted_daemon else 'untrusted', proxy_log_str))
|
|
|
|
|
2022-11-28 17:54:41 +00:00
|
|
|
daemon_rpcuser = v.get('rpcuser', '')
|
|
|
|
daemon_rpcpass = v.get('rpcpassword', '')
|
|
|
|
if daemon_rpcuser != '':
|
|
|
|
opts.append('--daemon-login')
|
|
|
|
opts.append(daemon_rpcuser + ':' + daemon_rpcpass)
|
2024-02-07 20:48:34 +00:00
|
|
|
|
|
|
|
opts.append('--trusted-daemon' if trusted_daemon else '--untrusted-daemon')
|
2022-12-02 23:07:41 +00:00
|
|
|
filename = 'monero-wallet-rpc' + ('.exe' if os.name == 'nt' else '')
|
|
|
|
daemons.append(startXmrWalletDaemon(v['datadir'], v['bindir'], filename, opts))
|
2020-12-03 23:46:01 +00:00
|
|
|
pid = daemons[-1].pid
|
2022-12-02 23:07:41 +00:00
|
|
|
swap_client.log.info('Started {} {}'.format(filename, pid))
|
2020-12-03 23:46:01 +00:00
|
|
|
|
|
|
|
continue
|
2019-07-31 16:38:19 +00:00
|
|
|
if v['manage_daemon'] is True:
|
2022-10-24 18:49:36 +00:00
|
|
|
swap_client.log.info(f'Starting {display_name} daemon')
|
2019-07-31 16:38:19 +00:00
|
|
|
|
|
|
|
filename = c + 'd' + ('.exe' if os.name == 'nt' else '')
|
|
|
|
daemons.append(startDaemon(v['datadir'], v['bindir'], filename))
|
|
|
|
pid = daemons[-1].pid
|
|
|
|
pids.append((c, pid))
|
|
|
|
swap_client.setDaemonPID(c, pid)
|
2021-12-30 13:25:18 +00:00
|
|
|
swap_client.log.info('Started {} {}'.format(filename, pid))
|
2019-07-31 16:38:19 +00:00
|
|
|
if len(pids) > 0:
|
|
|
|
with open(pids_path, 'w') as fd:
|
|
|
|
for p in pids:
|
|
|
|
fd.write('{}:{}\n'.format(*p))
|
|
|
|
|
2019-08-15 22:31:39 +00:00
|
|
|
signal.signal(signal.SIGINT, signal_handler)
|
|
|
|
signal.signal(signal.SIGTERM, signal_handler)
|
2022-07-31 17:33:01 +00:00
|
|
|
|
2023-12-18 13:15:16 +00:00
|
|
|
if len(start_only_coins) > 0:
|
|
|
|
logger.info(f'Only running {start_only_coins}. Manually exit with Ctrl + c when ready.')
|
|
|
|
while not swap_client.delay_event.wait(0.5):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
swap_client.start()
|
|
|
|
if 'htmlhost' in settings:
|
|
|
|
swap_client.log.info('Starting http server at http://%s:%d.' % (settings['htmlhost'], settings['htmlport']))
|
|
|
|
allow_cors = settings['allowcors'] if 'allowcors' in settings else cfg.DEFAULT_ALLOW_CORS
|
|
|
|
thread_http = HttpThread(fp, settings['htmlhost'], settings['htmlport'], allow_cors, swap_client)
|
|
|
|
threads.append(thread_http)
|
|
|
|
thread_http.start()
|
|
|
|
|
|
|
|
if 'wshost' in settings:
|
|
|
|
ws_url = 'ws://{}:{}'.format(settings['wshost'], settings['wsport'])
|
|
|
|
swap_client.log.info(f'Starting ws server at {ws_url}.')
|
|
|
|
|
|
|
|
swap_client.ws_server = WebsocketServer(host=settings['wshost'], port=settings['wsport'])
|
|
|
|
swap_client.ws_server.set_fn_new_client(ws_new_client)
|
|
|
|
swap_client.ws_server.set_fn_client_left(ws_client_left)
|
|
|
|
swap_client.ws_server.set_fn_message_received(ws_message_received)
|
|
|
|
swap_client.ws_server.run_forever(threaded=True)
|
|
|
|
|
|
|
|
logger.info('Exit with Ctrl + c.')
|
|
|
|
while not swap_client.delay_event.wait(0.5):
|
|
|
|
swap_client.update()
|
2022-07-31 17:33:01 +00:00
|
|
|
|
2019-07-31 16:38:19 +00:00
|
|
|
except Exception as ex:
|
2019-07-21 18:50:32 +00:00
|
|
|
traceback.print_exc()
|
|
|
|
|
2022-07-31 17:33:01 +00:00
|
|
|
if swap_client.ws_server:
|
|
|
|
try:
|
|
|
|
swap_client.log.info('Stopping websocket server.')
|
|
|
|
swap_client.ws_server.shutdown_gracefully()
|
|
|
|
except Exception as ex:
|
|
|
|
traceback.print_exc()
|
|
|
|
|
2020-12-13 13:43:46 +00:00
|
|
|
swap_client.finalise()
|
|
|
|
swap_client.log.info('Stopping HTTP threads.')
|
2019-07-21 18:50:32 +00:00
|
|
|
for t in threads:
|
2022-07-31 17:33:01 +00:00
|
|
|
try:
|
|
|
|
t.stop()
|
|
|
|
t.join()
|
|
|
|
except Exception as ex:
|
|
|
|
traceback.print_exc()
|
2019-07-21 18:50:32 +00:00
|
|
|
|
2019-07-25 13:28:44 +00:00
|
|
|
closed_pids = []
|
2019-07-21 18:50:32 +00:00
|
|
|
for d in daemons:
|
2021-12-30 13:25:18 +00:00
|
|
|
swap_client.log.info('Interrupting {}'.format(d.pid))
|
2020-11-07 11:08:07 +00:00
|
|
|
try:
|
2022-12-02 23:07:41 +00:00
|
|
|
d.send_signal(signal.CTRL_C_EVENT if os.name == 'nt' else signal.SIGINT)
|
2020-11-07 11:08:07 +00:00
|
|
|
except Exception as e:
|
2021-12-30 13:25:18 +00:00
|
|
|
swap_client.log.info('Interrupting %d, error %s', d.pid, str(e))
|
2020-11-07 11:08:07 +00:00
|
|
|
for d in daemons:
|
2019-07-25 13:28:44 +00:00
|
|
|
try:
|
|
|
|
d.wait(timeout=120)
|
2020-12-03 23:46:01 +00:00
|
|
|
for fp in (d.stdout, d.stderr, d.stdin):
|
|
|
|
if fp:
|
|
|
|
fp.close()
|
|
|
|
closed_pids.append(d.pid)
|
2019-07-25 13:28:44 +00:00
|
|
|
except Exception as ex:
|
2021-12-30 13:25:18 +00:00
|
|
|
swap_client.log.error('Error: {}'.format(ex))
|
2019-07-25 13:28:44 +00:00
|
|
|
|
|
|
|
if os.path.exists(pids_path):
|
|
|
|
with open(pids_path) as fd:
|
|
|
|
lines = fd.read().split('\n')
|
|
|
|
still_running = ''
|
|
|
|
for ln in lines:
|
|
|
|
try:
|
|
|
|
if not int(ln.split(':')[1]) in closed_pids:
|
|
|
|
still_running += ln + '\n'
|
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
with open(pids_path, 'w') as fd:
|
|
|
|
fd.write(still_running)
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def printVersion():
|
2021-01-10 18:30:07 +00:00
|
|
|
logger.info('Basicswap version: %s', __version__)
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def printHelp():
|
2023-12-18 13:15:16 +00:00
|
|
|
print('Usage: basicswap-run ')
|
|
|
|
print('\n--help, -h Print help.')
|
|
|
|
print('--version, -v Print version.')
|
|
|
|
print('--datadir=PATH Path to basicswap data directory, default:{}.'.format(cfg.BASICSWAP_DATADIR))
|
|
|
|
print('--mainnet Run in mainnet mode.')
|
|
|
|
print('--testnet Run in testnet mode.')
|
|
|
|
print('--regtest Run in regtest mode.')
|
|
|
|
print('--startonlycoin Only start the provides coin daemon/s, use this if a chain requires extra processing.')
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
data_dir = None
|
|
|
|
chain = 'mainnet'
|
2023-12-18 13:15:16 +00:00
|
|
|
start_only_coins = set()
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
for v in sys.argv[1:]:
|
|
|
|
if len(v) < 2 or v[0] != '-':
|
2019-07-21 19:20:36 +00:00
|
|
|
logger.warning('Unknown argument %s', v)
|
2019-07-21 18:50:32 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
s = v.split('=')
|
|
|
|
name = s[0].strip()
|
|
|
|
|
|
|
|
for i in range(2):
|
|
|
|
if name[0] == '-':
|
|
|
|
name = name[1:]
|
|
|
|
|
|
|
|
if name == 'v' or name == 'version':
|
|
|
|
printVersion()
|
|
|
|
return 0
|
|
|
|
if name == 'h' or name == 'help':
|
|
|
|
printHelp()
|
|
|
|
return 0
|
2019-07-27 17:26:06 +00:00
|
|
|
|
2023-12-18 13:15:16 +00:00
|
|
|
if name in ('mainnet', 'testnet', 'regtest'):
|
|
|
|
chain = name
|
2019-07-21 18:50:32 +00:00
|
|
|
continue
|
|
|
|
|
|
|
|
if len(s) == 2:
|
|
|
|
if name == 'datadir':
|
|
|
|
data_dir = os.path.expanduser(s[1])
|
|
|
|
continue
|
2023-12-18 13:15:16 +00:00
|
|
|
if name == 'startonlycoin':
|
|
|
|
for coin in [s.lower() for s in s[1].split(',')]:
|
|
|
|
if coin not in known_coins:
|
|
|
|
raise ValueError(f'Unknown coin: {coin}')
|
|
|
|
start_only_coins.add(coin)
|
|
|
|
continue
|
2019-07-21 18:50:32 +00:00
|
|
|
|
2019-07-21 19:20:36 +00:00
|
|
|
logger.warning('Unknown argument %s', v)
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
if data_dir is None:
|
2022-07-11 21:36:28 +00:00
|
|
|
data_dir = os.path.join(os.path.expanduser(cfg.BASICSWAP_DATADIR))
|
2019-07-21 19:20:36 +00:00
|
|
|
logger.info('Using datadir: %s', data_dir)
|
|
|
|
logger.info('Chain: %s', chain)
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
if not os.path.exists(data_dir):
|
|
|
|
os.makedirs(data_dir)
|
|
|
|
|
|
|
|
with open(os.path.join(data_dir, 'basicswap.log'), 'a') as fp:
|
|
|
|
logger.info(os.path.basename(sys.argv[0]) + ', version: ' + __version__ + '\n\n')
|
2023-12-18 13:15:16 +00:00
|
|
|
runClient(fp, data_dir, chain, start_only_coins)
|
2019-07-21 18:50:32 +00:00
|
|
|
|
|
|
|
logger.info('Done.')
|
|
|
|
return swap_client.fail_code if swap_client is not None else 0
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|