basicswap-prepare tries to initialise coin wallets from Particl mnemonic

Bitcoin 0.20: 'Cannot set a new HD seed while still in Initial Block Download.' Removed in 0.21
This commit is contained in:
tecnovert
2020-12-04 01:46:01 +02:00
parent 3bbb483a0a
commit 5a163e0f86
18 changed files with 754 additions and 93 deletions

View File

@@ -19,7 +19,6 @@ import logging
import traceback
import subprocess
import basicswap.config as cfg
from basicswap import __version__
from basicswap.basicswap import BasicSwap
@@ -31,7 +30,6 @@ logger.level = logging.DEBUG
if not len(logger.handlers):
logger.addHandler(logging.StreamHandler(sys.stdout))
ALLOW_CORS = False
swap_client = None
@@ -50,6 +48,29 @@ def startDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def startXmrDaemon(node_dir, bin_dir, daemon_bin, opts=[]):
daemon_bin = os.path.expanduser(os.path.join(bin_dir, daemon_bin))
args = [daemon_bin, '--config-file=' + os.path.join(os.path.expanduser(node_dir), 'monerod.conf')] + opts
logging.info('Starting node {} --data-dir={}'.format(daemon_bin, node_dir))
return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
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)
args = [daemon_bin, '--config-file=' + os.path.join(os.path.expanduser(node_dir), 'monero_wallet.conf')] + opts
args += opts
logging.info('Starting wallet daemon {} --wallet-dir={}'.format(daemon_bin, node_dir))
#return subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=data_dir)
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)
def runClient(fp, data_dir, chain):
global swap_client
settings_path = os.path.join(data_dir, cfg.CONFIG_FILENAME)
@@ -79,6 +100,20 @@ def runClient(fp, data_dir, chain):
try:
# Try start daemons
for c, v in settings['chainclients'].items():
if c == 'monero':
if v['manage_daemon'] is True:
logger.info('Starting {} daemon'.format(c.capitalize()))
daemons.append(startXmrDaemon(v['datadir'], v['bindir'], 'monerod'))
pid = daemons[-1].pid
logger.info('Started {} {}'.format('monerod', pid))
if v['manage_wallet_daemon'] is True:
logger.info('Starting {} wallet daemon'.format(c.capitalize()))
daemons.append(startXmrWalletDaemon(v['datadir'], v['bindir'], 'monero-wallet-rpc'))
pid = daemons[-1].pid
logger.info('Started {} {}'.format('monero-wallet-rpc', pid))
continue
if v['manage_daemon'] is True:
logger.info('Starting {} daemon'.format(c.capitalize()))
@@ -99,7 +134,7 @@ def runClient(fp, data_dir, chain):
if 'htmlhost' in settings:
swap_client.log.info('Starting server at %s:%d.' % (settings['htmlhost'], settings['htmlport']))
allow_cors = settings['allowcors'] if 'allowcors' in settings else ALLOW_CORS
allow_cors = settings['allowcors'] if 'allowcors' in settings else cfg.DEFAULT_ALLOW_CORS
tS1 = HttpThread(fp, settings['htmlhost'], settings['htmlport'], allow_cors, swap_client)
threads.append(tS1)
tS1.start()
@@ -118,8 +153,7 @@ def runClient(fp, data_dir, chain):
closed_pids = []
for d in daemons:
int_pid = d.pid
logging.info('Interrupting {}'.format(int_pid))
logging.info('Interrupting {}'.format(d.pid))
try:
d.send_signal(signal.SIGINT)
except Exception as e:
@@ -127,13 +161,10 @@ def runClient(fp, data_dir, chain):
for d in daemons:
try:
d.wait(timeout=120)
if d.stdout:
d.stdout.close()
if d.stderr:
d.stderr.close()
if d.stdin:
d.stdin.close()
closed_pids.append(int_pid)
for fp in (d.stdout, d.stderr, d.stdin):
if fp:
fp.close()
closed_pids.append(d.pid)
except Exception as ex:
logger.error('Error: {}'.format(ex))