mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-05 18:29:26 +00:00
Workarounds to run Decred in windows.
Running BSX in windows is highly discouraged. If you have no choice at least use the WSL docker setup instead.
This commit is contained in:
parent
b077561a6f
commit
42fa4d49d4
2 changed files with 46 additions and 25 deletions
|
@ -11,15 +11,21 @@ import subprocess
|
||||||
|
|
||||||
def createDCRWallet(args, hex_seed, logging, delay_event):
|
def createDCRWallet(args, hex_seed, logging, delay_event):
|
||||||
logging.info('Creating DCR wallet')
|
logging.info('Creating DCR wallet')
|
||||||
|
|
||||||
(pipe_r, pipe_w) = os.pipe() # subprocess.PIPE is buffered, blocks when read
|
(pipe_r, pipe_w) = os.pipe() # subprocess.PIPE is buffered, blocks when read
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
str_args = ' '.join(args)
|
||||||
|
p = subprocess.Popen(str_args, shell=True, stdin=subprocess.PIPE, stdout=pipe_w, stderr=pipe_w)
|
||||||
|
else:
|
||||||
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=pipe_w, stderr=pipe_w)
|
p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=pipe_w, stderr=pipe_w)
|
||||||
|
|
||||||
try:
|
def readOutput():
|
||||||
while p.poll() is None:
|
|
||||||
while len(select.select([pipe_r], [], [], 0)[0]) == 1:
|
|
||||||
buf = os.read(pipe_r, 1024).decode('utf-8')
|
buf = os.read(pipe_r, 1024).decode('utf-8')
|
||||||
response = None
|
response = None
|
||||||
if 'Use the existing configured private passphrase' in buf:
|
if 'Opened wallet' in buf:
|
||||||
|
pass
|
||||||
|
elif 'Use the existing configured private passphrase' in buf:
|
||||||
response = b'y\n'
|
response = b'y\n'
|
||||||
elif 'Do you want to add an additional layer of encryption' in buf:
|
elif 'Do you want to add an additional layer of encryption' in buf:
|
||||||
response = b'n\n'
|
response = b'n\n'
|
||||||
|
@ -33,11 +39,22 @@ def createDCRWallet(args, hex_seed, logging, delay_event):
|
||||||
pass
|
pass
|
||||||
elif 'Ticket commitments db upgrade done' in buf:
|
elif 'Ticket commitments db upgrade done' in buf:
|
||||||
pass
|
pass
|
||||||
|
elif 'The wallet has been created successfully' in buf:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'Unexpected output: {buf}')
|
raise ValueError(f'Unexpected output: {buf}')
|
||||||
if response is not None:
|
if response is not None:
|
||||||
p.stdin.write(response)
|
p.stdin.write(response)
|
||||||
p.stdin.flush()
|
p.stdin.flush()
|
||||||
|
|
||||||
|
try:
|
||||||
|
while p.poll() is None:
|
||||||
|
if os.name == 'nt':
|
||||||
|
readOutput()
|
||||||
|
delay_event.wait(0.1)
|
||||||
|
continue
|
||||||
|
while len(select.select([pipe_r], [], [], 0)[0]) == 1:
|
||||||
|
readOutput()
|
||||||
delay_event.wait(0.1)
|
delay_event.wait(0.1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f'dcrwallet --create failed: {e}')
|
logging.error(f'dcrwallet --create failed: {e}')
|
||||||
|
|
|
@ -91,6 +91,9 @@ def startDaemon(node_dir, bin_dir, daemon_bin, opts=[], extra_config={}):
|
||||||
stdout_dest = subprocess.PIPE
|
stdout_dest = subprocess.PIPE
|
||||||
stderr_dest = subprocess.PIPE
|
stderr_dest = subprocess.PIPE
|
||||||
|
|
||||||
|
if extra_config.get('use_shell', False):
|
||||||
|
str_args = ' '.join(args)
|
||||||
|
return Daemon(subprocess.Popen(str_args, shell=True, stdin=subprocess.PIPE, stdout=stdout_dest, stderr=stderr_dest, cwd=datadir_path), opened_files)
|
||||||
return Daemon(subprocess.Popen(args, stdin=subprocess.PIPE, stdout=stdout_dest, stderr=stderr_dest, cwd=datadir_path), opened_files)
|
return Daemon(subprocess.Popen(args, stdin=subprocess.PIPE, stdout=stdout_dest, stderr=stderr_dest, cwd=datadir_path), opened_files)
|
||||||
|
|
||||||
|
|
||||||
|
@ -245,11 +248,12 @@ def runClient(fp, data_dir, chain, start_only_coins):
|
||||||
if c == 'decred':
|
if c == 'decred':
|
||||||
appdata = v['datadir']
|
appdata = v['datadir']
|
||||||
extra_opts = [f'--appdata="{appdata}"', ]
|
extra_opts = [f'--appdata="{appdata}"', ]
|
||||||
|
use_shell: bool = True if os.name == 'nt' else False
|
||||||
if v['manage_daemon'] is True:
|
if v['manage_daemon'] is True:
|
||||||
swap_client.log.info(f'Starting {display_name} daemon')
|
swap_client.log.info(f'Starting {display_name} daemon')
|
||||||
filename = 'dcrd' + ('.exe' if os.name == 'nt' else '')
|
filename = 'dcrd' + ('.exe' if os.name == 'nt' else '')
|
||||||
|
|
||||||
extra_config = {'add_datadir': False, 'stdout_to_file': True, 'stdout_filename': 'dcrd_stdout.log'}
|
extra_config = {'add_datadir': False, 'stdout_to_file': True, 'stdout_filename': 'dcrd_stdout.log', 'use_shell': use_shell}
|
||||||
daemons.append(startDaemon(appdata, v['bindir'], filename, opts=extra_opts, extra_config=extra_config))
|
daemons.append(startDaemon(appdata, v['bindir'], filename, opts=extra_opts, extra_config=extra_config))
|
||||||
pid = daemons[-1].handle.pid
|
pid = daemons[-1].handle.pid
|
||||||
swap_client.log.info('Started {} {}'.format(filename, pid))
|
swap_client.log.info('Started {} {}'.format(filename, pid))
|
||||||
|
@ -264,7 +268,7 @@ def runClient(fp, data_dir, chain, start_only_coins):
|
||||||
wallet_pwd = os.getenv('WALLET_ENCRYPTION_PWD', '')
|
wallet_pwd = os.getenv('WALLET_ENCRYPTION_PWD', '')
|
||||||
if wallet_pwd != '':
|
if wallet_pwd != '':
|
||||||
extra_opts.append(f'--pass="{wallet_pwd}"')
|
extra_opts.append(f'--pass="{wallet_pwd}"')
|
||||||
extra_config = {'add_datadir': False, 'stdout_to_file': True, 'stdout_filename': 'dcrwallet_stdout.log'}
|
extra_config = {'add_datadir': False, 'stdout_to_file': True, 'stdout_filename': 'dcrwallet_stdout.log', 'use_shell': use_shell}
|
||||||
daemons.append(startDaemon(appdata, v['bindir'], filename, opts=extra_opts, extra_config=extra_config))
|
daemons.append(startDaemon(appdata, v['bindir'], filename, opts=extra_opts, extra_config=extra_config))
|
||||||
pid = daemons[-1].handle.pid
|
pid = daemons[-1].handle.pid
|
||||||
swap_client.log.info('Started {} {}'.format(filename, pid))
|
swap_client.log.info('Started {} {}'.format(filename, pid))
|
||||||
|
|
Loading…
Reference in a new issue